[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
At 2004-04-09 13:07 -0400, Angus McIntyre wrote:
Only if the parameter is of type "node set" since that is the only argument type for select= for <xsl:apply-templates/>
No, because the data type of the parameter is result tree fragment.
To initialize a node set to empty use select="/.." as the attribute.
Good hint!
Then address the nodes in the stylesheet using the document function. In outline form:
But XSL *is* XML so you can use the document() function to get at the nodes of your stylesheet.
I hope this helps.
....................... Ken
Re: [xsl] 'apply-templates' on parameter of 'call-template'
Subject: Re: [xsl] 'apply-templates' on parameter of 'call-template' From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Fri, 09 Apr 2004 14:03:34 -0400 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] 'apply-templates' on para, M. David Peterson | Thread | Re: [xsl] 'apply-templates' on para, Wendell Piez |
RE: [xsl] 'apply-templates' on para, M. David Peterson | Date | RE: RE: [xsl] Saxon servlet and xsl, Michael Kay |
Month |