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:
trangF.rncF.rng
where is the unqualified name of the file. For example, if
your RNC schema is named Froster.rnc,
translate it using:
trang roster.rnc roster.rng
Once you have the schema in .rng
format, here is the general form of the command that
executes pyrang:
pyrang [-pprefix] [-ooutFile]F.rng
where:
-p prefix
If you supply this optional argument, the given will be
appended to the front of every generated name.
prefix
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 PLAYER_N.
This option is helpful if your application works with multiple schemas that may have some overlap in their element or attribute names.
F.rng
The name of the input schema file is required; it will
generally end in .rng.
-o outFile
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 rnc_roster.py.
pyrang -o rnc_roster.py roster.rng
You can then include the generated manifest constants in
your program using this Python import:
from rnc_roster import *