Using XSLT for C code generation and testing
Abstract
xmlroff is a fast, free, high-quality, multi-platform XSL formatter that aims to excel at DocBook formatting and that integrates easily with other programs and with scripting languages.
xmlroff is written in C, but much of the C code is generated from the XML source for the XSL recommendation. What started out as a simple stylesheet to extract FO and property names from the XSL spec to avoid transcription errors has grown (and shrunk) over time to generate:
- C code for GObjects representing FOs and properties
- C code to verify allowed property values
- A single enumeration of all the 'enumerated token' values defined by XSL
- Structured comments in the C code that are used by gtk-doc to generate documentation
- XML entity declarations and references for assembling the generated documentation into one DocBook document
The code generation has been toned down in places over time. The initial object hierarchy was very flat because it was very easy to generate a unique class for each FO and each property, but just because you can doesn't mean you should, and there is now more use of common superclasses and that single, common enumuration of all of XSL's 'enumeration token' values.
Other uses of XSLT and XPath in the xmlroff project include:
- Pruning unsupported FOs and properties from the input FO document
- Generating test scripts for any XSL formatter from a W3C-format XSL testsuite's XML description
- Generating HTML reports from test results XML
- Generating a W3C-format XSL testsuite from FOP "layoutengine"
Download
Poster (A0 size): xmlroff-xslt.pdf
Attachments
-
xmlroff-xslt.pdf
(357.3 KB) - added by tkg
10 months ago.
'Using XSLT for C code generation and testing' poster.
