Xml2rfc generates RFCs and IETF drafts from document source in XML according to the dtd in RFC2629.
The IETF uses a specific format for the standards and other documents it publishes as RFCs, and for the draft documents which are produced when developing documents for publications. There exists a number of different tools to facilitate the formatting of drafts and RFCs according to the existing rules, and this tool, xml2rfc, is one of them. It takes as input an xml file which contains the text and meta-information about author names etc., and transforms it into suitably formatted output. The input xml file should follow the DTD given in RFC2629 (or it’s inofficial successor).
The current incarnation of xml2rfc provides output in the following formats: Paginated and unpaginated ascii text, html, nroff, and expanded xml. Only the paginated text format is currently (January 2013) accepable as draft submissions to the IETF.
To install a system-wide version of xml2rfc, download and unpack the xml2rfc distribution package, then cd into the resulting package directory and run:
$ python setup.py install
Alternatively, if you have the ‘pip’ command (‘Pip Installs Packages’) installed, you can run pip to download and install the package:
$ pip install xml2rfc
If you want to perform a local installation for a specific user, you have a couple of options. You may use python’s default location of user site-packages by specifying the flag --user. These locations are:
- UNIX: $HOME/.local/lib/python<ver>/site-packages
- OSX: $HOME/Library/Python/<ver>/lib/python/site-packages
- Windows: %APPDATA%/Python/Python<ver>/site-packages
You can additionally combine the flag --install-scripts with --user to specify a directory on your PATH to install the xml2rfc executable to. For example, the following command:
$ python setup.py install --user --install-scripts=$HOME/bin
will install the xml2rfc library and data to your local site-packages directory, and an executable python script xml2rfc to $HOME/bin.
The option --prefix allows you to specify the base path for all installation files. The setup.py script will exit with an error if your PYTHONPATH is not correctly configured to contain the library path the script tries to install to.
The command is used as follows:
$ python setup.py install --prefix=<path>
For further fine-tuning of the installation behavior, you can get a list of all available options by running:
$ python setup.py install --help
xml2rfc accepts a single XML document as input and outputs to one or more conversion formats.
Basic Usage: xml2rfc SOURCE [options] FORMATS...
The following parameters affect how xml2rfc behaves, however none are required.
Short Long Description -C --clear-cache purge the cache and exit -h --help show the help message and exit -n --no-dtd disable DTD validation step -N --no-network don’t use the network to resolve references -q --quiet dont print anything -v --verbose print extra information -V --version display the version number and exit -b BASENAME --basename=BASENAME specify the base name for output files -c CACHE --cache=CACHE specify an alternate cache directory to write to -D DATE --date=DATE run as if todays date is DATE (format: yyyy-mm-dd) -d DTD --dtd=DTD specify an alternate dtd file -o FILENAME --out=FILENAME specify an output filename
At least one but as many as all of the following output formats must be specified. The destination file will be created according to the argument given to –filename. If no argument was given, it will create the file(s) “output.format”. If no format is specified, xml2rfc will default to paginated text (--text).
Command Description --raw outputs to a text file, unpaginated --text outputs to a text file with proper page breaks --nroff outputs to an nroff file --html outputs to an html file --exp outputs to an XML file with all references expanded
- xml2rfc draft.xmlxml2rfc draft.xml --dtd=alt.dtd --basename=draft-1.0 --text --nroff --html
Version 2.12.2 (30 Oct 2018)
This bugfix release corrects a default setting for –v3 modes so they do not try to apply DTD validation. It refines the internationalised address layout, and does re-factoring in a number of places. Non-Latin author names and addresses in Right-To-Left scripts are now properly aligned in the Authors’ Addresses section. It also fixes an issue where needLines PI settings were ineffectual under python2.7, and caused exceptions under python3.5 and higher.
Excerpted from the commit log:
- Changed the HTML renderer to properly place organisation in i18n address layout, and added back the role indication that was lost in previous i18n address layout work.
- Updated run.py to apply the –no-dtd option to all –v3 formats, fixing an issue in 2.12.1 with running –html –v3 on a converted –v2v3 file.
- Fixed an issue with needLines when set to a string value.
- Added simple bidi-support to author addresses, in order to have addresses in right-to-left scripts align properly. Fixed a bug in the handling of non-Latin address information.
- Tweaked the vcard width to avoid having author names and addresses in right-to-left script end up far to the right, away from the ASCII information.
Version 2.12.1 (29 Oct 2018)
This release provides some additional polish over release 2.12.0, and also a few bugfixes. The primary focus for this release has been HTML compliance based on the W3C validator at https://validator.w3.org/. Valid HTML 5 is now generated for all documents used during testing. From the commit log:
- Fixed a number of issues with the v3 html renderer, to improve the generated html. Many of these were caught by the W3C validator at validator.w3.org:
- removed the <meta http-equiv=”Content-Type” …> element, as it should not appear when there is a <meta charset=…> element
- removed a number of extraneous wrapping divs with identical id attributes
- corrected the generation of <dt><dd> items for xml <ol> entries with percentage list types
- removed some attributes on html entries for xml <ol> lists that had incorrectly been transferred from the xml
- corrected the block element generated for <references> to <section>
- fixed an issue where <xref> in <name> would generate nested html <a> elements
- Also fixed some other issue:
- added a newline tail for block elements, to improve readability
- added missing space between author name and (editor)
- fixed the renderer for <note> to generate html <section> elements with the right class attribute
- refactored the generation of enclosing divs to hold id=”$anchor” to be more consistent, with less code
- modified the rendering of <xref> with text content to more closely match the historic rendering
- Updated python-version specific test masters. Tox runs for py27, py34, py35, and py36 aren now all clean.
- Changed some invalid <link> rel= values to valid ones in the preptool
- Tweaked the list of html block-level elements we use to control <div> wrapping
- Disallowed <iref> as a direct child of <table> in the schema, as it results in invalid html with the rendering specified in RFC 7992.
Version 2.12.0 (28 Oct 2018)
This release introduces the vocabulary v3 html formatter. In order to invoke this formatter, use the regular –html switch for html output, and add the –v3 switch to specify the v3 html formatter.
In v3 html formatter mode, xml2rfc accepts any valid xml2rfc input file, but since the actual formatter only understands the XML elements and attributes which have not been deprecated by RFC7991, it first applies the xml2rfc v2v3 converter in order to transform any deprecated markup to the elements and attributes it understands, and then applies the preptool in order to normalize the input before it starts rendering.
This is the first release of the v3 html formatter. It is quite feature complete, but has been tested only on a limited number of documents, so expect that there could be some rough edges.
In building the html v3 formatter, a number of rough edges were also discovered in the schema, RFC 7991; html format output, RFC 7992; and preptool specification, RFC 7998. The modifications applied in the code are described in draft-levkowetz-xml2rfc-v3-implementation-notes-05.