getElementByID -> getElementByXPointer???

I was reading up on the current state of XPointer, XPath and etcetera.  It
occurs to me that, if XPointer ever becomes a Recommendation (1), then it can be
used to generalize getElementByID() into a function which can return any point
in a document.  Say we have a function called getElementByXPointer().  Since
XPointer supports ids (2), then:

] getElementByID('1701A')

...could be represented using XPointer as either:

] getElementByXPointer('1701A')
] getElementByXPointer('/1/1/2')
] getElementByXPointer('fed/2')

...in the following XML (3):

] <?xml version="1.0"?>
] <?xml-id names="id xcha je"?>
] <starships>
]   <alien id="fed" xml:lang="en-US">
]     <ship id="1701" />
]     <ship id="1701A" />
]     <ship id="2000" />
]   </alien>
]   <alien xcha="klingon" xml:lang="x-klingon">
]     <ship xcha="IKS7" />
]     <ship xcha="IKS38k" />
]   </alien>
] </starships>

This seems to be a natural generalization of the getElementByID function; it
provides more flexiblity and brings some additional functionality to the DOM (an
XPointer can return a single element or a set of elements/nodes).  Is this being
considered for the next version of the DOM?

---
Jimmy Cerra

---
1) I really hope XPointer becomes a recommendation, as I like some of the
features, such as Child Sequences.

2) AKA Bare Names.

3) Note that I used a processing instruction to tell you what an id is.

Received on Saturday, 27 April 2002 22:20:12 UTC