the best way to check the xml reference?

advertisements

I have many references in my xml files like this:

<name id="key1"></name>
<ref to="key1"></ref>

so what's the best way to check the ref/@to is defined in a name/@id.

XSD? DTD? or programming using XPATH?


In XML Schema: ID, IDREF, IDREFS, xs:key -- see this for examples.

In XPath: the id() function.

In XSLT: the <xsl:key> declaration and the key() function.