You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Michael Glavassevich <mr...@ca.ibm.com> on 2010/08/06 14:43:03 UTC

Re: When is an ID an ID?

Benson,

It is the *type* of the attribute not its name which determines whether
it's an ID. This is usually determined by a type definition in an XML
Schema or DTD, but can also be assigned programmatically by the user (see
the Element.setIdAttribute*() methods). More info here [1].

Thanks.

[1] http://www.w3.org/TR/DOM-Level-3-Core/core.html#Attr-isId

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Benson Margulies <bi...@gmail.com> wrote on 08/06/2010 08:08:41 AM:

> The javadoc for the Document class has the following note under
> getElementById.
>
>         Note: Attributes with the name "ID" or "id" are not of type ID
> unless so defined
>
> So, I read an XHTML doc into the DOM (using Xerces 2.9.1).
>
> The doc has a plain old <p id='fribble'> in it.
>
> I call getElementById("fribble"), and it returns null.
>
> I use XPath to get "//*[id='fribble']", and all is well.
>
> So, the question is, what causes the DocumentBuilder to actually mark
> ID attributes as 'so defined?'
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-dev-help@xerces.apache.org