Please note, new blog at http://www.acheron.org/darryl/

XML semantics

There is something that has been bothering me for quite some time. It is bad XML semantics. Take this for example: <book> <chapter1> </chapter1> <chapter2> </chapter2> </book> To me, this is badly written XML for a number of reasons: 1. It semantically makes no sense. 2. It is hard to parse. The reason I think that this is not semantically correct is an XML document should describe the structure of the information, not the information itself. The node should really be a node, because it does represent something meaningful. Try parsing the above XML into something that is useful. What happens if you had another chapter to the XML document? Could you programatically tell me how many sections were in the document? In my view, this is a semantically correct XML document: <book> <chapter name="introduction" number="1"> <title /> <body /> </chapter> <chapter name="chapter2" number="2"> <title /> <body /> </chapter> </book>

» Post a Comment