Skip to main content

Xml2rfc generates RFCs and IETF drafts from document source in XML according to the dtd in RFC2629.

Project description


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.


System Install

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 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

User Install

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 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.

Custom Install

The option --prefix allows you to specify the base path for all installation files. The 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 install --prefix=<path>

For further fine-tuning of the installation behavior, you can get a list of all available options by running:

$ python 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.xml
xml2rfc draft.xml --dtd=alt.dtd --basename=draft-1.0 --text --nroff --html


xml2rfc depends on the following packages:


Version 2.13.0 (17 Nov 2018)

This release provides an number of improvements. Rendering of all v3 elements should now be in place for the v3 text and html formatters, and the renderers have been updated to follow the issue resolutions so far. A bug in the generation of boilerplate for BCPs has been fixed. Feedback on unexpected postal address data has been improved, as has feedback on unexpected combinations of stream, category, and consensus settings.

Details from the commit log:

  • In the html formatter:
    • Added indentation support for <dl> to the v3 html renderer.
    • Fixed a bug in the display of author names in the author addresses section when no postal information is given.
    • Improved <eref> rendering for the case when no eref text is provided.
    • Corrected the anchor placement for slugified names of figures and tables.
    • Added support for <referencegroup>.
    • Added a missing CSS class for <seriesInfo> rendering.
    • Added support for right and center alignment of tables.
  • In the text formatter:
    • Added v3 text formatter support for rendering of blockquote and cref.
    • Minor other tweaks.
  • In the preptool:
    • Added support for <referencegroup> elements.
    • Added support for the <rfc> version attribute.
    • Fixed a string formatting bug.
    • Added attribute valididty checking for integer-valued attributes.
    • Removed the forced inclusion of day for RFC publication dates, reverting to permitting publication with only year and month.
    • Added more sophisticated checking and setting of consensus, based on what is valid for the given stream and category.
    • Refined the handling when given input that already contains boilerplate, authors addresses and index.
  • In the v2v3 converter:
    • Added setting of the <rfc> version attribute.
    • Removed dubious elimination of <format> elements pointing to alternative reference URLs.
    • Fixed a couple of instances of buggy error reporting.
  • Changed util.postal.get_normalized_address() to return a filled-in adr structure even if no country could be identified, for more consistent code in other places.
  • In the Relax NG schema files:
    • Changed the v3 schema default value for <dl> newline so that the effect is the same as for the old ‘hanging’ default value.
    • Added a ‘derivedAnchor’ attribute for <referencegroup>, matching that of <reference>.
  • In the CSS style sheet:
    • Changed the CSS class for Reference Section definition lists from ‘reference’ to ‘references’.
    • Added styling for table alignment and applied the same styling for table labels as for figure labels.
  • Added bcp14, em, iref, strong, sub, and sup to the permitted elements in <name>.
  • Fixed some issues with the error messages for combinations of stream, category, and consensus.
  • Added code to honour the “display” attribute of <cref>.
  • Added a preptool action to check the <rfc> attributes submissionType (i.e., stream), category, and consensus for validity. Invalid combinations are called out, and warnings are issued about setting missing settings to default values.
  • With v2 formatters, treat consensus for BCPs the same way as STD documents,
  • Refactored some logging and address functionality, improved address warnings and other address-related tweaks.

Version 2.12.3 (30 Oct 2018)

This release fixes a schema issue.

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 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.

Project details

Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for xml2rfc, version 2.13.0
Filename, size File type Python version Upload date Hashes
Filename, size xml2rfc-2.13.0.tar.gz (2.7 MB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page