
Martijn Faassen writes:
I'm confused about basic principles here: how do you define an id in a Relax NG schema?
<grammar [...] datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> [...] <define name="attlist.mads" combine="interleave"> <attribute name="id"> <data type="ID"/> </attribute> </define> [...] </grammar> seems to be how. (Note, I didn't write the schema, and I'm consequently not particularly in a position to change to using xml:id. However, I will if there's no other way, using lxml, to achieve what I need with new ids being recognised as such - and I can use an XML Schema or a DTD rather than RELAX NG if that makes a difference.) This is certainly what's allowing the XPath id function to work - before validating against the schema it doesn't work, and subsequently it does.
I'm still at a loss how you got your original ids recognized in the first place. Perhaps you can provide a small sample XML document, a small sample XPath statement, and, if this is possible, a sample small Relax NG that declares an id.
Sample XML: <?xml version="1.0" encoding="utf-8"?> <madsCollection xmlns="http://www.loc.gov/mads/"> <mads id="name-000001"> <authority>Some text</authority> </mads> </madsCollection> Sample XPath: id('name-000001') Sample RELAX NG schema (this should work, but I have just now manually cut out stuff that isn't used in the document above): <?xml version="1.0" encoding="UTF-8"?> <grammar ns="http://www.loc.gov/mads/" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> <define name="madsCollection"> <element name="madsCollection"> <ref name="attlist.madsCollection"/> <oneOrMore> <ref name="mads"/> </oneOrMore> </element> </define> <define name="attlist.madsCollection" combine="interleave"> <empty/> </define> <define name="mads"> <element name="mads"> <ref name="attlist.mads"/> <ref name="authority"/> </element> </define> <define name="attlist.mads" combine="interleave"> <attribute name="id"> <data type="ID"/> </attribute> </define> <define name="authority"> <element name="authority"> <ref name="attlist.authority"/> <text/> </element> </define> <define name="attlist.authority" combine="interleave"> <empty/> </define> <start> <ref name="madsCollection"/> </start> </grammar> Jamie -- Artefact Publishing: http://www.artefact.org.nz/ GnuPG Public Key: http://www.artefact.org.nz/people/jamie.html