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: using xsl:with-param in apply-templates problem


    Please see the code:
    <xsl:template match="//file">

                  you never need to start a match pattern with //
                  match="file"
                  will do here (and is the same, apart from default priority)

    	<xsl:variable select="@name" name="filename"/>
                 This variable doesn't seem to be doing ,uch, you could
                 just use @name instead of $filename below.

    	<xsl:apply-templates select="document($filename)" mode="file">
                 This is OK but beware that it applies templates to the
                 root node (/) of the new document so you need a
                 template in the mode "file" that matches /

    		<xsl:with-param name="filename"><xsl:value-of
    select="$filename"/></xsl:with-param>
                  Simpler and more efficient to make the parameter a
                  string (or actually in this case, attribute node)
                  rather than a result tree fragment:
         <xsl:with-param name="filename" select="$filename"/>
    	</xsl:apply-templates>
    </xsl:template>



   For some reason the parameter is not being picked up, has anybody got
   any ideas why?
   

almost certainly because you haven't a template for / in the mode file.
A simpler alternative is to apply templates to the top level element
rather than the document node, ie

<xsl:apply-templates select="document($filename)/*" mode="file">

David

_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit http://www.star.net.uk/stats.asp or alternatively call
Star Internet for details on the Virus Scanning Service.

 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]