[xml2rfc] Compacting an ID reference
petithug at acm.org (Marc Petit-Huguenin) Wed, 16 December 2009 01:43 UTC
From: "petithug at acm.org"
Date: Tue, 15 Dec 2009 17:43:07 -0800
Subject: [xml2rfc] Compacting an ID reference
In-Reply-To: <20091214231757.GQ1516@Sun.COM>
References: <4B26BAD4.9050502@htt-consult.com> <20091214231757.GQ1516@Sun.COM>
Message-ID: <4B283B2B.6090202@acm.org>
Nicolas Williams wrote: > On Mon, Dec 14, 2009 at 05:23:16PM -0500, Robert Moskowitz wrote: >> ID references tend to be long and make for long reference tags and high >> indents in the reference section: >> >> [...] >> >> Is there a simpler way? > > Not that I know of, but I'd really like one (maybe some can be done via > XSLT?). In particular I'd like a way to change the reference anchor -- > "I-D.<stuff>" is really, really ugly and user-unfriendly, while > "BTNS-C-API" is much more readable. > > The reason references work this way is simple: each reference needs a > unique anchor, but there's no way to assign that other than to use the > I-D's filename as the basis for the anchor name, plus, you include the > references via XML entities, without a way [that I know of] to modify > the object being included. Here's how to do this with XSLT. First you need to use Xinclude to include your references, then you can put the Xinclude statement inside a map element with the new anchor that you want: "[...] <section title="Acknowledgements"> <t>Look at the nice references <xref target="BTNS-C-API" /></t> </section> </middle> <back> <references title="Normative References" xmlns:xi="http://www.w3.org/2001/XInclude"> <map anchor="BTNS-C-API"> <xi:include xi:href="http://xml.resource.org/public/rfc/bibxml3/reference.I-D.ietf-btns-c-api.xml" /> </map> </references> </back> [...]" Then you need the following xslt document (dup.xslt): "<?xml version="1.0" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" /> <xsl:template match="map"> <xsl:apply-templates select="reference" /> </xsl:template> <xsl:template match="map/reference/@anchor"> <xsl:attribute name="anchor"> <xsl:value-of select="../../@anchor" /> </xsl:attribute> </xsl:template> <xsl:template match="* | text() | processing-instruction('rfc') | @*"> <xsl:copy> <xsl:apply-templates select="@* | * | text() | processing-instruction('rfc')" /> </xsl:copy> </xsl:template> <xsl:template match="@xml:base" /> </xsl:stylesheet>" You can use xsltproc for this: $ xsltproc --xinclude -o new.xml dup.xslt original.xml And then after running xml2rfc on it: "9. Acknowledgements Look at the nice references [BTNS-C-API] 10. References 10.1. Normative References [BTNS-C-API] Richardson, M., Williams, N., Komu, M., and S. Tarkoma, "C-Bindings for IPsec Application Programming Interfaces", draft-ietf-btns-c-api-04 (work in progress), March 2009. " -- Marc Petit-Huguenin Personal email: marc at petit-huguenin.org Professional email: petithug at acm.org Blog: http://blog.marc.petit-huguenin.org
- [xml2rfc] Compacting an ID reference Robert Moskowitz
- [xml2rfc] Compacting an ID reference Nicolas Williams
- [xml2rfc] Compacting an ID reference Julian Reschke
- [xml2rfc] Compacting an ID reference Robert Moskowitz
- [xml2rfc] Compacting an ID reference Julian Reschke
- [xml2rfc] Compacting an ID reference Scott Brim
- [xml2rfc] Compacting an ID reference Julian Reschke
- [xml2rfc] Compacting an ID reference Nicolas Williams
- [xml2rfc] Compacting an ID reference Nicolas Williams
- [xml2rfc] Compacting an ID reference Julian Reschke
- [xml2rfc] Compacting an ID reference Robert Moskowitz
- [xml2rfc] Compacting an ID reference Robert Moskowitz
- [xml2rfc] Compacting an ID reference Marc Petit-Huguenin