----- Original Message -----
From: "Sam Steingold" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, March 19, 2008 1:33 PM
Subject: [docbook-apps] applying imports to additional text
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I want
<literal role="unreadable">foo</literal>
to be processed as if it were written
<literal role="data"><ulink url="...">#<FOO></literal>
I wrote this:
<xsl:param name="clhs.top" select="'http://www.lisp.org/HyperSpec/'"/>
<xsl:param name="clhs.body" select="'{$clhs.top}Body/'"/>
<xsl:template match="[EMAIL PROTECTED] = 'unreadable']">
~ <span class="data"><a href="{$clhs.body}sec_2-4-8-20.html">#<</a>
~ <xsl:apply-imports/>></span>
</xsl:template>
it has 2 bugs:
1. "{$clhs.body}" is expanded to "{$clhs.top}Body/", not to
"http://www.lisp.org/HyperSpec/Body/" as I want. why?
The {$...} syntax in XSLT is called an attribute value template (AVT), and
it only works in literal output attribute values. In a param, it is treated
as an ordinary string. You want:
<xsl:param name="clhs.body" select="concat($clhs.top, 'Body/')"/>
2. the "#<" and ">" are not included in the <code></code> together with
FOO. How do I make <xsl:apply-imports/> operate on #<FOO> instead of
just FOO?
You can't. The apply-imports only applies to the current node, not to any
nodeset you might construct in the stylesheet.
However, in this case an alternative is easy. If you look in
html/inline.xsl for literal, you find:
<xsl:template match="literal">
<xsl:call-template name="inline.monoseq"/>
</xsl:template>
And if you look for the template named "inline.monoseq", you find it starts
as follows:
<xsl:template name="inline.monoseq">
<xsl:param name="content">
<xsl:call-template name="anchor"/>
<xsl:call-template name="simple.xlink">
<xsl:with-param name="content">
<xsl:apply-templates/>
</xsl:with-param>
</xsl:call-template>
</xsl:param>
<code>
...
Notice that it has a parameter named "content". You can construct your
content when you pass that parameter and it will then be included inside the
<code> element:
So your custom template can make a direct call to "inline.monoseq" and pass
the assembled content in the param, something like this:
<xsl:template match="[EMAIL PROTECTED] = 'unreadable']">
<span class="data">
<a href="{$clhs.body}sec_2-4-8-20.html">
<xsl:call-template name="inline.monoseq">
<xsl:with-param name="content">
<xsl:text>#<</xsl:text>
<xsl:apply-templates/>
<xsl:text>></xsl:text>
</xsl:with-param>
</xsl:call-template>
</a>
</span>
</xsl:template>
I use <xsl:text> for the literal text so whitespace is not accidentally
introduced into the output.
Bob Stayton
Sagehill Enterprises
[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]