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.






purge the cache and exit



show the help message and exit



disable DTD validation step



don’t use the network to resolve references



dont print anything



print extra information



display the version number and exit



specify the base name for output files



specify an alternate cache directory to write to



run as if todays date is DATE (format: yyyy-mm-dd)

-d DTD


specify an alternate dtd file



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




outputs to a text file, unpaginated


outputs to a text file with proper page breaks


outputs to an nroff file


outputs to an html file


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.10.3 (22 Sep 2018)

This bugfix release works around a problem with lxml versions before 3.8.0, and brings some other fixes and tweaks:

  • Tweaked validation output to not break if validation error log elements lack xpath information. Fixes issue #376. (lxml<3.8.0 does not provide the xpath of the offending element in error.path).

  • Fixed a couple of issues with v2v3 conversion warnings, and added element sourceline information for all elements created during conversion.

  • Fixed a buglet in sourcode rendering.

  • Added a warning about lxml versions that lack validation error xpath information, and tweaked the warn() method.

  • Tweaked the rendering of <eref>.

  • Added <blockquote> to the list of block level elements in isblock().

  • Added some values to xml2rfc.base.default_options, necessary when using xml2rfc as a library module (i.e., not getting options from through command-line invocation).

  • Added attribute markers=”true”|”false” to <sourcecode> and changed the v3 text formatter to only output code markers if <sourcecode> has attribute markers set to true.

Version 2.10.2 (19 Sep 2018)

  • Added a full listing of validation errors found, rather than just the first, when running v3 validation on an (possibly v2v3 converted) input file in preptool. Also improved the error messages by providing the xpath to the offending element.

  • Added normalization of RFC 2119 phrases before checking for validity, and updated tests files to include a <bcp14> test.

  • Fixed several places where unexpected input could cause exceptions. Also turned the invalid input document warning into an error. Fixes issue #375.

  • Preserved the element tail when rendering <bcp14>. Fixes issue #374.

  • Fixed an issue where an empty <references/> section could cause an exception in the v2 text formatter.

Version 2.10.1 (18 Sep 2018)

This is primarily a bugfix release, to handle issues people have reported with the new vocabulary v3 text formatter:

  • Fixed an issue where the v2 text formatter could blow up for some v3 documents, rather than exit with a message.

  • Fixed a problem in the v2v3 converter that could cause an Internet-Draft <seriesInfo> element to be inserted even if one was alredy present.

  • Tweaked the <seriesInfo> insertion code slightly, and expanded an error message slightly.

  • Fixed a couple of places where bad input could cause exceptions. Fixes issue #366.

  • Fixed a case where max() could be given an empty sequence.

  • Tweaked the handling of <ul> with structured <li> content. Fixes issue #365.

  • Improved the handling of <br>.

  • Added render_blockquote(). This fixes issue #359.

  • Fixed a problem in the plaintext formatter where table cells were not filled in if the table was wider than the available width. Also added support for formatted table cell content.

  • Added a check in preptool for <keyword> elements containing multiple keywords. Fixes issue #353.

  • Moved the reading of input files to avoid multiple reads. Fixes issue #352.

  • Added a renderer for <bcp14> elements.

  • Added error messages for empty artwork files. Tweaked the error message for missing artwork text. Addresses issue #370

  • Forced no_dtd when running v2v3 to avoid complaints when converting an alredy converted file, and also with the v3 text formatter.

  • Added a try/except around xinclude in order to provide error message without traceback on missing include files.

  • Removed an assert that prevented rendering of document top when some elements are so long that the line width will be more than 72 characters. Added support for <note> with <name>. Added <xref> format default for included references. Added a warning for <xref>s without ‘pn’ attribute (which can happen if the <xref> is pointing at an element for which pn is not generated (this is probably an error in RFC 7998). Fixes issue #346

  • Tweaked the preptool to handle removeInRFC=’true’ elements that lacks <t> children.

  • Added to the release notification addresses.

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.

Source Distribution

xml2rfc-2.10.3.tar.gz (2.0 MB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page