Sam Steingold wrote:
Hi,
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="[EMAIL PROTECTED]'clhs']">
 <xsl:choose><xsl:when test=".=''">
   <a class="[EMAIL PROTECTED]" href="[EMAIL PROTECTED]"><xsl:text>[</xsl:text>
    <xsl:value-of select="@url"/>
    <xsl:text>]</xsl:text></a></xsl:when>
  <xsl:otherwise>
<a class="[EMAIL PROTECTED]" href="[EMAIL PROTECTED]"><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="[EMAIL PROTECTED]'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="[EMAIL PROTECTED]" href="[EMAIL PROTECTED]"><xsl:text>[</xsl:text>
     <xsl:value-of select="@url"/>
     <xsl:text>]</xsl:text></a></xsl:when>
   <xsl:otherwise>
    <a class="[EMAIL PROTECTED]" href="[EMAIL PROTECTED]">
     <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

HTH


regards

--
Dave Pawson
XSLT XSL-FO FAQ.
http://www.dpawson.co.uk

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to