Fallbacks

It is possible to add extra XPointer expressions to act as fallbacks in the event that previous ones fail. The first expression that succeeds is used, and the remainder are ignored:

xpointer(...)xpointer(...)xpointer(...)

This technique can be used to cater for the possibility that an XML document will not reference a DTD. The following example contains three expressions. The first will be applied if the document references a DTD that includes attributes declared to be of type ID. The second will be applied only if this is not the case, but makes the assumption that the name of the attribute is 'id'. Finally, it may be known that some elements have an attribute called 'name', and it may not be known which of these two attributes contains ...

Get XML Companion, The, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.