OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Re: help with xslt


Hi,

> * Dave Pawson <qnirc@qcnjfba.pb.hx> [2008-09-13 07:54:38 +0100]:
> Sam Steingold wrote:
>> I maintain clisp (http://clisp.cons.org), in particular, the clisp
>> manual ("implementation notes") in DocBook/xml format.
>> the manual has a lot of links to the CLHS (Common Lisp HyperSpec, the
>> HTML version of the ANSI standard).
>> I keep them in the form
>> <ulink role="clhs" url="sec_11-1-2-1-2"/>
>> which is converted by
>>
>> <xsl:param name="clhs.top" select="'http://www.lisp.org/HyperSpec/'"/>
>> <xsl:param name="clhs.body" select="concat($clhs.top, 'Body/')"/>
>> <xsl:template match="ulink[@role='clhs']">
>>  <xsl:choose><xsl:when test=".=''">
>>    <a class="{@role}" href="{$clhs.body}{@url}.html"><xsl:text>[</xsl:text>
>>     <xsl:value-of select="@url"/>
>>     <xsl:text>]</xsl:text></a></xsl:when>
>>   <xsl:otherwise>
>>    <a class="{@role}"
>> href="{$clhs.body}{@url}.html"><xsl:apply-templates/></a>
>> </xsl:otherwise></xsl:choose></xsl:template>
>>
>> alas, there are two versions of CLHS around, the older one (for which
>> the above is geared) and the newer one, with a different page naming
>> system.
>>
>> specifically, section 11.1.2.1.2 which is sec_11-1-2-1-2.html is the
>> older version is now 11_abab.html while chap-11.html is now 11_.html.
>>
>> I want to be able to generate clisp impnotes which link to either
>> version based on a variable setting at processing time.
>>
>> This would mean that I would have to write an xslt function mapping an
>> array of integers #(11 1 2 1 2) to either sec_11-1-2-1-2 or 11_abab.
>> How do I do that?
>> To begin with, I don't even know how to iterate (or recurse) in xslt.
>> I use xsltproc on linux.
>
>
> <xsl:variable name='ver' select="'1.0'"/>
>
>
> <xsl:template match="ulink[@role='clhs']">
>
> <xsl:variable name='target'>
> <xsl:choose>
> <xsl:when test="$ver = '1.0'>
>   <xsl:value-of select="$ver1URL">
> <xsl:otherwise>
>  <xsl:value-of select="$ver2URL">
> </xsl:otherwise>
> </xsl:choose>
> </xsl:variable>
>
>
>   <xsl:choose><xsl:when test=".=''">
>     <a class="{@role}" href="{$target}{@url}.html"><xsl:text>[</xsl:text>
>      <xsl:value-of select="@url"/>
>      <xsl:text>]</xsl:text></a></xsl:when>
>    <xsl:otherwise>
>     <a class="{@role}" href="{$target}{@url}.html">
>      <xsl:apply-templates/></a>
>  </xsl:otherwise></xsl:choose></xsl:template>
>
>
> Which assumes $ver1URL points to version 1 of CLHS
> and $ver2URL points to version 2 of CLHS

this takes care of the easy part.
the hard part is translating an array of integers #(11 1 2 1 2) to
either sec_11-1-2-1-2 or 11_abab.
how do I do that?

-- 
Sam Steingold (http://sds.podval.org/) on Fedora release 9 (Sulphur)
http://dhimmi.com http://jihadwatch.org http://pmw.org.il
http://camera.org http://openvotingconsortium.org http://iris.org.il
Your mouse pad is incompatible with MS Windows - your HD will be reformatted.



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]