[lxml-dev] Resolve RelaxNG document

Stefan Behnel stefan_ml at behnel.de
Thu Sep 6 17:01:21 CEST 2007


Lawrence Oluyede wrote:
>> I think the easiest way is to do it by hand, something like:
>>
>>     resolve = etree.XPath("//rng:define[@name = $name]", namespaces=...)
>>     for ref in tree.iter("ref"):
>>         define = resolve(tree, name = ref.get("name"))
>>         if define:
>>              ref.getparent().replace(ref, define[0]) # or define[0][0] ?
>>
> 
> Ok thanks anyway, I was doing it by hand. I hoped there was something
> in the schema validator. How does the relaxng validator knows if a
> document is valid if it doesn't expand references?

What makes you think it doesn't?

It should be part of the evaluation step. However, you can't see that from the
outside as the tree you pass in is not modified.

Stefan



More information about the lxml-dev mailing list