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]
The meaning of “semantics” and “syntax” in XPath

Hi Folks,

The meaning of the word “semantics” is fuzzy in the realm of data interoperability. But in XPath the meaning of “semantics” and “syntax” is clear:

Semantics: the value returned from evaluating the XPath expression.

Syntax: the form of the XPath expression.

Example: Let’s illustrate the use of these terms with an XPath expression for querying this XML document:

<Book>
   
<Title>Parsing Techniques</Title>
   
<Author>Dick Grune</Author>
   
<Author>Ceriel Jacobs</Author>
   
<Publisher>Springer</Publisher>
</Book>

 

Here is the XPath expression:

 

                /Book/Author

 

The semantics of that XPath expression are the values returned when evaluating the XPath expression on the XML document. These are the values returned:


   
<Author>Dick Grune</Author>
   
<Author>Ceriel Jacobs</Author>

 

That’s the semantics of the XPath expression.

 

Here is an XPath expression with identical semantics, but different syntax:

 

                /Book/*[self::Author]

 

Why does the XPath language allow expressions with different syntax and identical semantics?

 

The rationale, in this example, is that it allows a syntactic distinction to be made between dereferencing a field in a composite object (with the slash operator) and performing an indexed lookup (with the predicate), even though there is no semantic distinction between the two.

 

Comments?

 

/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