[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: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Fri, 09 Apr 2004 14:03:34 -0400
call template apply templates
At 2004-04-09 13:07 -0400, Angus McIntyre wrote:
Is it legitimate to invoke 'xsl:apply-templates' on a parameter passed to 'xsl:call-template'?

Only if the parameter is of type "node set" since that is the only argument type for select= for <xsl:apply-templates/>


In other words, should the following fragment be expected to work:

        <xsl:template match="/">
           <xsl:call-template name="test">
              <xsl:with-param name="body">
                 <p>This is my body</p>
                 <matchable id="123"/>
              </xsl:with-param>

No, because the data type of the parameter is result tree fragment.


           </xsl:call-template>
        </xsl:template>

        <xsl:template name="test">
           <xsl:param name="body">no body</xsl:param>

To initialize a node set to empty use select="/.." as the attribute.


The Xalan error ("can not convert #RTREEFRAG to a nodelist") hints that I'm trying to do something basically contrary to the spirit of XSL, or at least XSL 1.0.

Good hint!


What I'd like to do can be described as follows: use 'call-template' to 'surround' an arbitrary block of XML, _contained in the XSL stylesheet_, by additional XML content - and have templates applied to the contained block in the usual way.

Then 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()"/>

As to why I want to do this particularly horrible thing, put it down to someone else's questionable design decisions. If the nodes that I want to 'surround' were in the XML rather than the XSL, this would be trivial.

But XSL *is* XML so you can use the document() function to get at the nodes of your stylesheet.


I hope this helps.

....................... Ken

--
Public courses: Spring 2004 world tour of hands-on XSL instruction
Each week:   Monday-Wednesday: XSLT/XPath; Thursday-Friday: XSL-FO
Hong Kong May 17-21; Bremen Germany May 24-28; Helsinki June 14-18

World-wide on-site corporate, govt. & user group XML/XSL training.
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Breast Cancer Awareness  http://www.CraneSoftwrights.com/s/bc

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.