At 14:03 -0400 09.04.2004, G. Ken Holman wrote:
[ ... how to use 'call-template' to 'surround' stylesheet XML ... ]
... address the nodes in the stylesheet using the document function.
In outline form:
<xsl:stylesheet
xmlns:myns="my-namespace"
exclude-result-prefixes="myns"
<myns:data1>
<p>This is my body</p>
<matchable id="123"/>
</myns:data1>
...
<xsl:with-param name="body" select="document('')/*/myns:data1/node()"/>
Of all the good suggestions and comments I've received, this one
seems to be closest to what I'd like to do, as I'm trying to make
some particularly skanky stylesheets written by someone else as
nearly 'self-documenting' as I can, and being able to 'separate out'
a chunk of data in its own namespace has considerable appeal in terms
of cleanliness and clarity.
I'm still missing something though, as the processors don't seem to
love your suggestion, at least the way I tried implementing it.
Sablotron crashes (presumably having tried to recurse infinitely),
while LibXSLT, Saxon and Xalan all just output the text nodes in the
content, as if they'd failed to find any matching templates. With the
stylesheet:
====
<?xml version='1.0' encoding='iso-8859-1'?>
<xsl:stylesheet version='1.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns:myns="my-namespace"
exclude-result-prefixes="myns">
<xsl:output method='html' version='1.0' encoding='iso-8859-1' indent='no'/>
<myns:data1>
<p>This is some text</p>
<matchable id="123"/>
</myns:data1>
<xsl:template match="/">
<xsl:call-template name="test">
<xsl:with-param name="body" select="document('')/*/myns:data1/node()"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="test">
<xsl:param name="body">no body</xsl:param>
<xsl:apply-templates select="$body"/>
</xsl:template>
<xsl:template name="matchable">
<p>The value is <xsl:value-of select="@id"/></p>
</xsl:template>
<xsl:template name="p">
<p><xsl:apply-templates/></p>
</xsl:template>
</xsl:stylesheet>
====
I get as output just the string
This is some text
rather than the
<p>This is some text</p>
<p>The value is 123</p>
that I was hoping for.
Have I overlooked something obvious, or is this the expected behavior?
Thanks again,
Angus
--
Business: http://www.nomadcode.com/
Personal: http://www.raingod.com/angus/
Political: http://www.gollum2004.com/