Project

Profile

Help

using id function in xpath expressions

Added by Anonymous about 17 years ago

Legacy ID: #4406334 Legacy Poster: Ole Lensmar (omatzura)

Hi, I want to use the id( .. ) function in an ad-hoc xpath expression, but it won't work since (I'm guessing..) the parser has no type information to know which attribute that is declared as an ID.. is there any way to get this working anyway? regards, /Ole eviware.com


Replies (1)

RE: using id function in xpath expressions - Added by Anonymous about 17 years ago

Legacy ID: #4406416 Legacy Poster: Michael Kay (mhkay)

This is sensitive to your choice of XML parser and the way you invoke it. Normally if you parse using Xerces on Java the IDs declared in the DTD are properly notified and everything works well. However if your input comes say from a DOM this isn't always the case. On the .NET platform the Microsoft XML parser doesn't notify attribute types, so id() simply doesn't work. If you want something that works more robustly, use a filter expression //x[id='abcd']. Under Saxon-SA this will be indexed so it should be just as fast as id().

    (1-1/1)

    Please register to reply