
Hi there, Jamie Norrish wrote:
I have a document which, after parsing into an ElementTree, I validate against a RELAX NG schema. At this point I can use the XPath id function to find the element with a particular id. However, after adding a new element which has an attribute which the schema defines as holding an ID, that element is not found by the id function.
I'm confused about basic principles here: how do you define an id in a Relax NG schema? I thought that Relax NG does not contain information about this at all. DTDs can have this information, and I thought the new way to do this (as far as I know not supported by lxml..) is the xml:id specification: http://www.w3.org/TR/2005/PR-xml-id-20050712/ I thought Relax NG explicitly didn't do this kind of thing and kept itself to validation only.
If I validate the document against the schema again, nothing changes (not that I think it should be necessary to do this): the document is valid, and the id function doesn't find the element with the appropriate id.
If this is the correct behaviour, how do I get the new ids to be recognised?
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. Regards, Martijn