Inasmuch as the customised version of the “xmlspec” schema being used for the next version of the XSL spec is maintained in RELAX NG XML syntax (RNG) and Emacs’s nXML-mode only uses RELAX NG compact syntax (RNC), I yet again wanted to convert a schema from RNG to RNC. As you would expect, there’s more than one way to do it.
The classic way is using James Clark’s utility. This involves: (a) working out if you need “Jing” or “Trang” (you need Trang); (b) getting the .jar or the executable; and (c) running it. Fairly simple, though it’s a pain that although it’s bundled with Ubuntu, etc., it’s not installed by default. I backup my data between OS re-installs (who doesn’t?) but not the OS-installed programs, so when I need it on a new machine or after a re-install, I, at least, have to go through the Jing/Trang confusion and then fire up the package manager to install it.
I wanted an alternative, but writing a RNG schema loader function for nxml-mode isn’t the work of an afternoon (interesting as it would be to bootstrap it using nxml-mode’s tokenizing of the RNG XML), so I found David Rosenborg’s “RNG to RNC Converter” (http://www.pantor.com/download.html). The current version works with XSLT 1.0 but not XSLT 2.0 (because it expects the XSLT processor to have a
node-set() furnction), but you can add the following to
RngToRncProcessorConfig.xsl so the XSLT works with both XSLT 1.0 and XSLT 2.0:
<!-- XSLT 2.0 or later. --> <xsl:when test="system-property('xsl:version') >= 2"> <xsl:variable name="body"> <xsl:for-each select="$schema"> <xsl:call-template name="make-body"/> </xsl:for-each> </xsl:variable> <xsl:sequence select="$body"/> </xsl:when>
My only other quibble with the stylesheet is that it doesn’t preserve comments that are in the RNG (more straightforward to do in XSLT 2.0 than XSLT 1.0, I admit).
I don’t yet know if I’ll stick to using RNG to RNC Converter in preference to Trang. The XSLT is easier to keep with the other stuff that I backup between installs or keep in the Subversion repository for machine configurations, but Trang is easier to use once it is installed and on your path. The best thing is that now I have the choice of more than one way to do it.
For a more complete list of ways to do it that is maintained by MURATA Makoto, see http://relaxng.org/#conversion.