[xml] How to dump a processed RelaxNG schema
- From: Jack Schwartz <Jack A Schwartz Sun COM>
- To: xml gnome org
- Subject: [xml] How to dump a processed RelaxNG schema
- Date: Tue, 17 Jun 2008 17:22:54 -0700
Hi everyone.
I would like to be able to look through a RelaxNG schema to see if a
given element type is surrounded by <oneOrMore> or <zeroOrMore>, to know
whether more than one of those elements is allowed. This would be easy
to do, except that the schema has several <ref>s and <define> groups.
I believe that internally the parser must replace each <ref> literal
with the data of its corresponding <define> group (i.e. inline the
group) in order to create a single cohesive schema that the validator
can use. However, I cannot find a way to dump this post-processed
inlined schema to a file so I can search through it.
I tried this in python:
outfile = open(sys.argv[2], "w")
outfile2 = open(sys.argv[3], "w")
ctxt = libxml2.relaxNGNewParserCtxt(sys.argv[1])
schema = ctxt.relaxNGParse()
schema.relaxNGDumpTree(outfile)
schema.relaxNGDump(outfile2)
where sys.argv[1] is the name of the schema file itself.
outfile basically contains the input file contents. The <ref>s are
still intact; the data of the referenced <define> is not substituted inline.
outfile2 contains only this:
RelaxNG: manifest.rng
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
<start>
</start>
</grammar>
The call to relaxNGDump() gives this message:
Unimplemented block at relaxng.c:7672
I've made sure to test with the latest library as well: I ran with the
library created from release 2.6.32.
xmllint --version shows this:
xmllint: using libxml version 20632
compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1
FTP HTTP DTDValid HTML Legacy C14N Catalog XPath XPointer XInclude Iconv
ISO8859X Unicode Regexps Automata Expr Schemas Schematron Modules Debug
I've searched the archives but there aren't really good keywords to
use. (I tried schema, inline and define)
What do I need to do to dump out a schema which has inlined the data of
each referenced <define>?
Thanks,
Jack
P.S. I am building an XML file layering mechanism and need this
information to know whether to add or overlay new elements at a
particular place in a DOM tree.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]