[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: 'apply-templates' on parameter of 'call-template'

Subject: Re: 'apply-templates' on parameter of 'call-template'
From: Angus McIntyre <angus@xxxxxxxxx>
Date: Sat, 10 Apr 2004 11:17:10 -0400
xsl apply templates select parameter
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/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.