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]
Imbue XML instances with semantics

Hi Folks,

Problem: There are N nodes. Create an XML instance so that the nodes form a ring (cyclic) topology.

Rick Jelliffe solved this problem very elegantly [1].

Here’s Rick’s solution: Arrange the nodes in document order:

<Node id="N1">...</Node>
<Node id="N2">...</Node>
<Node id="Nn">...</Node>


“How does that form a ring topology?” you ask. It doesn’t. Not yet. You need to define an operator on the nodes and give the operator the desired behavior (semantics). Allow me to explain.


To traverse from one <Node> element to the next, you must perform an operation. If you are moving from <Node> to <Node> using your eyes, then the operator is “physically move your eyes downward (or upward).” If you are moving from <Node> to <Node> using XPath, then the operator is following-sibling (or preceding-sibling). Regardless of the technology, some operator must be used to move from one <Node> element to the next. Let’s generically denote that operator by succ. To achieve our ring topology goal, then, we need to imbue the succ operator with this semantic:


The succ of a <Node> is the next node in document order
               except when <Node> is the last node, then the succ is the
               first node.


Now the nodes take on a ring topology, by way of the succ operator.


Awesome! Thanks Rick!


Lesson Learned: XML has no semantics. When we define operators on the XML and imbue specific behaviors on the operators, only then we may informally treat the XML as having semantics.






[1] http://xml-dev.markmail.org/message/b3n774tmzqfe5k4d?q=Notable+declarative+expressions%3F+date:201612


[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