[lxml-dev] etree.Element from RNG schema?
Frank Cusack
fcusack at redhat.com
Thu Jul 17 01:51:34 CEST 2008
Can lxml give me back an Element object from a parsed RNG schema?
That is, given
parser = etree.RelaxNG(etree.parse(file("foo.rng")))
I'd like to do something like parser.getroot() in order to get back
an Element/ElementTree which is like the original schema except with
grammar/define's expanded.
What I want is to go from
<grammar>
<start>
<element name="foo">
<ref name="bar" />
</element>
</start>
<define name="bar">
<text />
</define>
</grammar>
to
<element name="foo">
<text />
</element>
I realize this can't be done in all cases, e.g. there's no way to express
recursive references outside of a <grammar>. But in that case lxml could
return an error, or simply not recurse (so the expanded element tree would
contain the <ref> itself).
But even without handling recursion, wow it would be valuable for me not
to have to chase down includes and externalRef's, and more so not to have
to [re]implement combine rules.
-frank
More information about the lxml-dev
mailing list