[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: Re: [docbook-apps] Multiple xrefs rendering
In XSL, almost anything is possible is you are willing to apply sufficient effort. 8^) In this case, you would need to customize the template starting with this line in biblio.xsl: <xsl:template match="biblioentry|bibliomixed" mode="xref-to"> That is the template that generates the text for an xref to a biblioentry. It is passed a 'xrefstyle' parameter, which is set when the template is called. Its value is either the value of the xrefstyle attribute on the xref element (if you are using DocBook 4.3), or it is the value of the role attribute on the xref element if you have set the stylesheet parameter 'use.role.as.xrefstyle'. You will have to create a system of xrefstyle names to modify the behavior of the rendered text for each one. I've included a sample customization below that does what you want, but you may want to modify it as you see fit. Then your example would look like: DocBook <xref linkend="db_homepage" xrefstyle="first-in-sequence"/> <xref linkend="db_tdg" xrefstyle="last-in-sequence"/> is an <acronym>XML</acronym> application... The alternative to using xrefstyle (or role) is trying to make the templates look for sibling elements in the document, which can get pretty complicated. Bob Stayton Sagehill Enterprises DocBook Consulting bobs@sagehill.net <xsl:template match="biblioentry|bibliomixed" mode="xref-to"> <xsl:param name="referrer"/> <xsl:param name="xrefstyle"/> <xsl:message>xrefstyle is <xsl:value-of select="$xrefstyle"/></xsl:message> <!-- handles both biblioentry and bibliomixed --> <xsl:if test="($xrefstyle != '' and $xrefstyle != 'last-in-sequence' and $xrefstyle != 'middle-in-sequence') or $xrefstyle = ''"> <xsl:text>[</xsl:text> </xsl:if> <xsl:choose> <xsl:when test="string(.) = ''"> <xsl:variable name="bib" select="document($bibliography.collection,.)"/> <xsl:variable name="id" select="@id"/> <xsl:variable name="entry" select="$bib/bibliography/*[@id=$id][1]"/> <xsl:choose> <xsl:when test="$entry"> <xsl:choose> <xsl:when test="$bibliography.numbered != 0"> <xsl:number from="bibliography" count="biblioentry|bibliomixed" level="any" format="1"/> </xsl:when> <xsl:when test="local-name($entry/*[1]) = 'abbrev'"> <xsl:apply-templates select="$entry/*[1]"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="@id"/> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:otherwise> <xsl:message> <xsl:text>No bibliography entry: </xsl:text> <xsl:value-of select="$id"/> <xsl:text> found in </xsl:text> <xsl:value-of select="$bibliography.collection"/> </xsl:message> <xsl:value-of select="@id"/> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:otherwise> <xsl:choose> <xsl:when test="$bibliography.numbered != 0"> <xsl:number from="bibliography" count="biblioentry|bibliomixed" level="any" format="1"/> </xsl:when> <xsl:when test="local-name(*[1]) = 'abbrev'"> <xsl:apply-templates select="*[1]"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="@id"/> </xsl:otherwise> </xsl:choose> </xsl:otherwise> </xsl:choose> <xsl:if test="$xrefstyle = 'first-in-sequence' or $xrefstyle = 'middle-in-sequence'"> <xsl:text> </xsl:text> </xsl:if> <xsl:if test="($xrefstyle != '' and $xrefstyle != 'first-in-sequence' and $xrefstyle != 'middle-in-sequence') or $xrefstyle = ''"> <xsl:text>]</xsl:text> </xsl:if> </xsl:template> ----- Original Message ----- From: "Giulio Piancastelli" <gpian@softhome.net> To: <docbook-apps@lists.oasis-open.org> Sent: Tuesday, May 18, 2004 3:35 AM Subject: [docbook-apps] Multiple xrefs rendering > Hi all, > > I'd like to be able to customize the rendering of multiple xrefs in the > following way. Say I have some DocBook text like: > > DocBook <xref linkend="db_homepage"/> <xref linkend="db_tdg"/> is an > <acronym>XML</acronym> application... > > where the linkends are entries in my bibliography. I'd like that to be > rendered as: > > DocBook [5 12] is an XML application... > > rather than: > > DocBook [5] [12] is an XML application... > > (The bibliography is already numbered.) I had a look at the Customizing > Cross References chapter in DocBook XSL: The Complete Guide, but as I > undestand it the solution I'm searching for is not to be found there. Is > that xref formatting entirely possible? > > Best Regards, > Giulio Piancastelli. > > > To unsubscribe from this list, send a post to docbook-apps-unsubscribe@lists.oasis-open.org, or visit http://www.oasis-open.org/mlmanage/. > > >
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]