This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Passing a parameter from one matched template to another


First off, thanks to Joerg and Stuart for responding to my post, it's appreciated!

    [Paul] <xsl:variable name="input"><ARE><YOU><NUTS></xsl:variable>

    [Joerg] Is it <ARE/><YOU/><NUTS/> (example 1) or ...

Oops, I meant: <xsl:variable name=input><ARE/><YOU/><NUTS/></xsl:variable>

    [Joerg] Example 1:

            <xsl:apply-templates select="vendor:node-set($input)/*[1]" />

            <xsl:template match="ARE">
               <xsl:param name="x" select="''"/>
               <xsl:apply-templates select="following-sibling::*[1]">
                 <xsl:with-param name="x" select="anything-passed-to-template-YOU"/>
               </xsl:apply-templates>
            </xsl:template>

            <xsl:template match="YOU">
               <xsl:param name="x" select="''"/>
               <xsl:apply-templates select="following-sibling::*[1]">
                 <xsl:with-param name="x" select="anything-passed-to-template-NUTS"/>
               </xsl:apply-templates>
            </xsl:template>

            <xsl:template match="NUTS">
               <xsl:param name="x" select="''"/>
            </xsl:template>

Thanks!  The above appears to be the pattern I was looking for.

    [Paul]  <xsl:apply-templates select="vendor:node-set($input)" />
    [Joerg] <xsl:apply-templates select="vendor:node-set($input)/*[1]" />

I hadn't thought (obviously) about processing a single node at a time, which is why I couldn't figure out a parameter might get passed from one matched template to the next.

    [Stuart] ... the string '--' must not appear in an XML comment. Ouch!

I appreciate your picking nits, it's a good way for me to learn

    [Stuart] Beware of the parameter in your example, <xsl:param name="x"
             select="''"/>. Have you figured out what the default value of
             $x is? Is that what you intended?

I have this tendency (for which I was previously chided) to try to condense my examples to what I consider to be the essentials.  Because I didn't consider what happens in the default case to be of any importance to my query, I left it out.  I should have mentioned that in the initial posting.

Once again, thanks,

Paul



________________________________________________________
Outgrown your current e-mail service?
Get a 25MB Inbox, POP3 Access, No Ads and No Taglines with LYCOS MAIL PLUS.
http://login.mail.lycos.com/brandPage.shtml?pageId=plus

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]