This script operates on a Relax NG schema in the XML format. It produces a file containing Python declarations corresponding to the element and attribute names from the schema.
If the schema is expressed in Relax NG Compact Syntax
(RNC), the trang utility can
translate it. Typically, RNC files have names ending in
.rnc, while Relax NG files in the
XML format have names ending in
.rng. To translate, use this command:
is the unqualified name of the file. For example, if
your RNC schema is named
translate it using:
trang roster.rnc roster.rng
Once you have the schema in
format, here is the general form of the command that
If you supply this optional argument, the given
appended to the front of every generated name.
For example, suppose you use this command:
pyrang -p RNC_ foo.rng
The manifest constant generated for an element named
player would be
RNC_PLAYER_N instead of the default
This option is helpful if your application works with multiple schemas that may have some overlap in their element or attribute names.
The name of the input schema file is required; it will
generally end in
If this argument is provided, output is written to that file. Any existing file is deleted (assuming you have write permission for that file).
If omitted, output is written to the standard output stream.
Here is an example. This command would read schema file
roster.rng and write the
corresponding Python definitions to file
pyrang -o rnc_roster.py roster.rng
You can then include the generated manifest constants in
your program using this Python
from rnc_roster import *