Coffeehouse Thread

11 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Basic Notation 1.0

Back to Forum: Coffeehouse
  • User profile image
    TommyCarlier

    Following this thread, I've uploaded a first version of the specification for Basic Notation. You can download the document in XPS format (195 KB) or PDF format (164 KB).

    I would really appreciate some feedback. Like suggestions, problems, possible usage scenarios, ...

  • User profile image
    littleguru

    Looks like XML to me... With a little bit of syntactic difference. What's so special about it?

  • User profile image
    TommyCarlier

    It's not just syntactic difference. BN is much simpler, has fewer concepts, is more efficient, and is designed to solve some of the problems XML has.

    XML has elements, attributes, text, comments, CDATA, DTD, entities, DOCTYPE declarations, processing instructions, ... BN just has elements, text and comments.

    An XML document can only have 1 root-element. A BN document is just a collection of 0 or more nodes (node = element, text or comment), so you can have as many root-nodes as you want.

    In XML, white space causes problems. It's not always obvious if white space is part of the data or not. In BN it's always clear if white space is significant or not.

    In XML, you can't put 2 text nodes next to each other. In BN, you can.

    And BN is also less verbose than XML.

  • User profile image
    littleguru

    TommyCarlier wrote:
    It's not just syntactic difference. BN is much simpler, has fewer concepts, is more efficient, and is designed to solve some of the problems XML has.

    XML has elements, attributes, text, comments, CDATA, DTD, entities, DOCTYPE declarations, processing instructions, ... BN just has elements, text and comments.


    Hmm.. That's up to you. I mean you can also create an xml document that has only elements, text and comments. It only offers you more, if you want. You are mixing stuff here.

    TommyCarlier wrote:
    An XML document can only have 1 root-element. A BN document is just a collection of 0 or more nodes (node = element, text or comment), so you can have as many root-nodes as you want.


    As sven pointed out you can have also a file with more then one root node. Just use entities. You can always read in an XML file and wrap a node around the whole content to have one root element.

    TommyCarlier wrote:
    In XML, white space causes problems. It's not always obvious if white space is part of the data or not. In BN it's always clear if white space is significant or not.


    huh?

    TommyCarlier wrote:
    In XML, you can't put 2 text nodes next to each other. In BN, you can.


    And what are the benefits of it? I mean I can have two nodes with text in it in XML. Something like this is also possible.

    <books>
    <book>Foo</book>
    <book>Bar</book>
    </book>

    TommyCarlier wrote:
    And BN is also less verbose than XML.


    Let it grow Wink I think that XML is well thought and there are quite a few people extending and designing XML.

  • User profile image
    John Melville-- MD

    I think the biggest advantage of  XML right now is also BN's biggest disadvantage and the reason XML gets bent into all kinds of wierd applications.

    Xml already has parsers / generators / searchers ... etc on almost every platofrm that already work and have been very well debugged and field tested.  Choose BN and you're on your own.

  • User profile image
    TommyCarlier

    John, that's right. But BN is still in progress. XML has the advantage that parsers and generators for it already exist. BN has the advantage that parsers and generators are a lot easier to develop. Have you ever tried to write a full XML parser? Have you seen the specification for XML? It has 89 EBNF productions. The BN spec currently has 12 productions.

  • User profile image
    Angus

    This is interesting, I will be reading the specification in more detail later, but what I read was pretty cool.

    Angus Higgins

  • User profile image
    Jarle Stabell

    XML (via SGML) was designed for marking up text, not for encoding data/object structures, so it's not surprising that it isn't particularily suited for the latter. There exists many alternatives similar to your Basic Notation.
    This Java guy has an interesting (and very powerful) alternative to XAML, look for F3 on this blog:
    http://blogs.sun.com/chrisoliver/

  • User profile image
    Sven Groot

    TommyCarlier wrote:
    In XML, white space causes problems. It's not always obvious if white space is part of the data or not.

    All white space in XML is significant, and thus part of the data, unless it's between two elements (no other text), or if an xml:space attribute says otherwise. Seems pretty simple to me.

  • User profile image
    TommyCarlier

    This afternoon, I've started writing a .NET library for reading, writing and manipulation data in Basic Notation. It only took me a few hours to finish a working parser.

    It looks very much like XmlReader, which is pretty easy to use. Here's an example of some code that shows how to use BNReader:

    // source can be a TextReader, Stream, string or FileInfo
    using(BNReader lReader = BNReader.Create(source))
       while(lReader.Read())
          switch(lReader.Location)
          {
             case BNReaderLocation.StartElement:
                Console.WriteLine("Start element {0}, depth {1}", lReader.Name, lReader.Depth);
                break;
             case BNReaderLocation.EndElement:
                Console.WriteLine("End element");
                break;
             case BNReaderLocation.Text:
                Console.WriteLine("Text: " + lReader.Value);
                break;
             case BNReaderLocation.Comment:
                Console.WriteLine("Comment: " + lReader.Value);
                break;
          }
  • User profile image
    TommyCarlier

    Sven, good point; but you forgot to mention Attribute-Value normalization (http://www.w3.org/TR/REC-xml/#AVNormalize), so white space in attribute values is also insignificant. But you're right that white space is not really a problem, there are just some rules you have to follow. In BN, there are fewer rules to follow: white space is only significant in a QuotedText.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.