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

RE: Can't pass parameters across differing contexts?

Subject: RE: Can't pass parameters across differing contexts?
From: "Michael Kay" <mhkay@xxxxxxxxxxxx>
Date: Fri, 26 Oct 2001 10:07:38 +0100
passing parameter across xsl
Your apply-templates select="document(....)" is invoking the implicit
built-in template rule for the root node, which in turn is invoking your
explicit template rule for the outermost element in the document. Built-in
templates don't pass on the parameters they were called with.

Use apply-templates select="document(...)/*"

Mike Kay

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Hunsberger,
> Peter
> Sent: 25 October 2001 23:12
> To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
> Subject:  Can't pass parameters across differing contexts?
>
>
> I've got an XSLT template producing HTML using a series of
> templates that
> look like the following:
>
> <xsl:template match="list/*">
>     <td valign="top">
>         <xsl:variable name="varname"><xsl:value-of
> select="local-name()"/></xsl:variable>
>         <select name="{$varname}" size="1">
>             <xsl:apply-templates
> select="document(concat('$varname,'.xml'))"
> mode="list">
>                 <xsl:with-param name="sel">
>                     <xsl:value-of select="'X'"/>
>                 </xsl:with-param>
>             </xsl:apply-templates>
>         </select>
> </xsl:template>
>
> <xsl:template match="options" mode="list">
>     <xsl:param name="sel"/>
> Sel=<xsl:value-of select="$sel"/>?
>     <xsl:apply-templates select="*" mode="list">
>         <xsl:with-param name="sel" select="$sel"/>
>     </xsl:apply-templates>
> </xsl:template>
>
> <xsl:template match="option" mode="list">
>     <xsl:param name="sel"/>
>     <xsl:element name="option">
>         <xsl:if test="@value = $sel">
>             <xsl:attribute name="selected">1</xsl:attribute>
>         </xsl:if>
>         <xsl:attribute name="value"><xsl:value-of
> select="@value"/></xsl:attribute>
>         <xsl:value-of select="."/>
>     </xsl:element>
> </xsl:template>
>
> The parameter "sel" is normally set with some other code, but
> the above
> replicates the problem.  The hard coded display of the
> parameter value in
> the "options" template shows no value being passed to the
> template  If I use
> the same coding to pass the value to the "option" template
> (and a similar
> display) I do see the value.  I tried getting  the contents of the new
> document into a variable and then running the templates against  the
> variable contents, but I get the same results.  I can only
> conclude that for
> some reason the parameter won't pass when I'm switching
> document contexts?
> If this is generally true is there a work around?
>
> If it makes a difference I'm using Xalan 2.0.1.
>
> Peter Hunsberger
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.