?JoshTriplett has documented the XML-XCB protocol description format; this documentation is included in the xcb-proto package.


The XCB project is a replacement for the X Window System library Xlib. One major feature of XCB is the automatic generation of C bindings to the X protocol based on a description of that protocol. Previously, these descriptions were written in a protocol description language defined by a set of M4 macros. The XML-XCB project replaced the M4-based protocol description language and macros with an XML-based protocol description language and an XSLT-based binding generator.

This new approach has several advantages:

  • XML and XSLT are much more widely understood than M4.
  • There are many more tools that understand XML and XSLT. Only the M4 macro processor understands M4, and creating new operations based on the M4 protocol descriptions would require writing new sets of macros with the same API. XML protocol descriptions simply provide structured data for use either by XSLT or by any programming language with an XML library. This greatly reduces duplication of effort between different operations on the protocol descriptions. The structured format of XML also enables processing based on the structure of the data, rather than just executing macros as they are encountered.
  • Many more uses of the data become possible, through accessing the XML protocol descriptions from a program, rather than treating them as a program themselves. For some examples, see the Future Directions section.


XML-XCB consists of the following components:




Write the XML Schema.

Done: the XML-XCB schema is available.

Convert one of the smaller extensions to the XML description format, to provide some data to work with.

Done: converted dpms.xcb to dpms.xml.

Write the XSLT for the most needed protocol elements, including all those used by the converted extension.

Done: c-client.xsl

Convert xcb_types to the XML description format, and write the additional XSLT to support it.

Done: converted xcb_types.xcb to xcb_types.xml. (Update: now obsolete and merged into xproto.xml.)

Convert the remaining extensions to the XML description format.

Done: see bigreq.xml, render.xml, shape.xml, shm.xml, sync.xml, and xc_misc.xml.

Convert the core X protocol description to the XML description format.

Done; see xproto.xml.

Add the XSLT for the protocol elements needed by the remaining extensions.


Write XSLT to handle variable-length structures.


Complete all remaining XSLT, and ensure that the generated C code matches the code generated by the M4 macros.


Integrate into XCB.


Add support for one extension referencing the types of another.


Convert the XFIXES extension to the XML description format.

Done; see xfixes.xml.

Convert the DAMAGE extension to the XML description format.

Done; see damage.xml.

Convert the Composite extension to the XML description format.

Done; see composite.xml

Convert the XEvIE extension to the XML description format.

Done; see xevie.xml


You can download my project presentation for C410 "Open Source Software Development", or the LaTeX source for that presentation.

Future Directions

Some possible enhancements enabled by the XML data format include:

  • Using the XML protocol descriptions, a program could analyze dumped X protocol streams and generate a listing of the X requests and results in that stream.
  • Bindings for different languages (whether native or just wrappers around the C API) would simply be additional XSLTs. These XSLTs could generate the bindings directly, or output information for an existing language-binding generator.
  • An automatically-generated server-side protocol handler would also be just another XSLT.
  • Documentation for the X protocol could be embedded in the XML using an existing XML documentation format, or a subset or superset of such a format. Protocol documentation could then be generated through XSLT, including API listings generated from the protocol descriptions themselves.