- markup (52)
- xml (7)
- xslt (21)
- atom (8)
- overlapping markup (2)
- schema (9)
- creole (4)
- xforms (1)
- pipelines (7)
- coding (2)
- dtll (1)
- genealogy (3)
- gtd (1)
- hardware (1)
- legislation (1)
- ontologies (2)
- unicode (1)
- web (24)
- google (3)
- rdf (6)
- rest (3)
- wikis (1)
- work (1)
- xpath (1)
- xquery (1)
- xtech2008 (3)
- life (26)
- children (5)
- equality (6)
- environment (4)
- gadgets (5)
- software (3)
- xlinq (2)
- conferences (7)
- xtech (6)
- blog (7)
- drupal (3)
Re: XML Paths in Programming Languages
The other big different between XPaths and path-based syntax in languages is what happens when a particular element doesn’t exist. For example, consider the XPath “/doc/house/floor/room”. The return value is a null if any of <doc>, <house>, <floor>, or <room> doesn’t exist in the document (or if the path in question doesn’t occur in the document). The programming language construct “doc.house.floor.room” throws a null pointer exception if “doc” or “doc.house” or “doc.house.floor” evaluates to null.
That makes a very big difference to your exception handling logic/code. You can just catch the exception each time (at some CPU cost which may or may not be significant), which means wrapping a try/catch construct around every path statement. That makes the code ugly and hard to read, unfortunately. So it turns out to be a big difference in practice.
Cheers, Tony.