If you're using a DOM as input, support for the id() function is dependent
upon the DOM's getElementByID() function. So the real question here is why
your DOM isn't providing that information.
Quoting the DOM spec:
Note: The DOM implementation must have information that says which
attributes are
of type ID. Attributes with the name "ID" are not of
type ID unless so defined.
Implementations that do not know whether attributes are
of type ID or not are
expected to return null.
The individual DOM implementation has to decide when this information is
available and how it's maintained. In most current DOMs, you don't "know
whether attributes are of type ID" unless the DOM was validated against a
DTD or schema that provides this information. In many DOMs, that
information is set only by a validating parser, and attributes added after
that may not be checked to see whether they should be added to the ID list.
DOM Level 3's "abstract schema" chapter, now under development, will
provide better support for DTDs/schemas generally and for IDs in specific,
in those DOMs which implement that feature. Until then, and in DOMs which
choose not to support those APIs, you're stuck with "it works when the DOM
implementation says it works."
If you think your DOM implementation _should_ be supplying this
information, and it doesn't, report that to its support team.