XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
=?utf-8?Q?Re=3A_=5Bxml-dev=5D_Here=E2=80=99s_why_you_should_be_c?==?utf-8?Q?reating_two_levels_of_syntax?=

The OSI networking reference model famously has seven layers of protocol/syntax in its stack. What makes you think that two is enough?

(The two you are describing are essentially layers 6 and 7 in the OSI model)

Michael Kay
Saxonica


On 4 Aug 2016, at 19:45, Costello, Roger L. <costello@mitre.org> wrote:

Hi Folks,

Would you provide a use case for creating two levels of syntax please?

I will provide two use cases, one from Lisp and the other from XML:Books.

Use Case #1: Recall from my previous message that the Lisp language defines two levels of syntax: s-expressions and Lisp forms. A list that is an s-expression may contain any elements, whereas a list that is a Lisp form must start with a symbol (This is a bit simplified Ė see John Cowanís post). Now hereís why the Lisp folks created two levels of syntax: Lisp has functions and macros. The arguments to a function must be Lisp forms, which are evaluated before calling the function. Conversely, the arguments to a macro only have to be s-expressions, the arguments are not evaluated before calling the macro; the macro assigns a meaning to the s-expression (very neat!). (I realize this explanation is a bit terse. Hopefully, however, it gives you some feel for why two levels of syntax are important/needed in Lisp.)

Use Case #2: Letís assume the data needed to describe a Book is its Title, Author, and Publication Year. Now hereís why you should create two levels of syntax: Create a first level of syntax which merely requires the three items be present, i.e., no order required. Create a second level of syntax that mandates a particular order for the three items.

<image001.png>

The following shows how to implement the two levels of syntax using XML Schema:

<xs:complexType name="Unordered-Book-Data">
   
<xs:all>
       
<xs:element name="Title" type="xs:string" />
       
<xs:element name="Author" type="xs:string" />
       
<xs:element name="PublicationYear" type="xs:gYear" />
   
</xs:all>
</xs:complexType>

<xs:complexType name="Ordered-Book-Data">
   
<xs:complexContent>
       
<xs:restriction base="Unordered-Book-Data">
           
<xs:sequence>
               
<xs:element name="Title" type="xs:string" />
               
<xs:element name="Author" type="xs:string" />
               
<xs:element name="PublicationYear" type="xs:gYear" />
           
</xs:sequence>
       
</xs:restriction>
   
</xs:complexContent>
</xs:complexType>

 

The second level of syntax (Ordered-Book-Data) is a restricted form of the first level of syntax (Unordered-Book-Data). Notice that thatís analogous to Lisp: Lisp forms are a restricted version of s-expressions.

Applications that are happy with the data in any order receive the data in the first level of syntax.

Applications that require ordered data receive the data in the second level of syntax.

--------------------

Okay, your turn. Please provide a use case for two levels of syntax.

/Roger




[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS