Subject: RE: [xsl] using xsl:with-param in apply-templates problem From: "Niki Dinsey" <niki.dinsey@xxxxxxxxx> Date: Tue, 27 Aug 2002 12:14:23 +0100 |
David, thanks for your advice, I have change the SS accordingly, it all seems to work apart from the param being passed: Latest code: <xsl:template match="file"> <xsl:apply-templates select="document(attribute::name)/*" mode="file"> <xsl:with-param name="filename" select="attribute::name"/> </xsl:apply-templates> </xsl:template> <xsl:template match="text()" mode="file"/> <!-- Matches for OTN --> <xsl:template match="//ATITLE|//BTITLE|//CTITLE|//DTITLE|//ETITLE|//FTITLE" mode="file"> <xsl:param name="filename"/> <title> <xsl:attribute name="filename"> <xsl:value-of select="$filename"/> </xsl:attribute> <xsl:attribute name="chapID"> <xsl:value-of select="ancestor::*[last()]/attribute::ID"/> </xsl:attribute> ...etc.. > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx [mailto:owner-xsl- > list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of David Carlisle > Sent: 27 August 2002 11:33 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: Re: [xsl] 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 XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] using xsl:with-param in a, David Carlisle | Thread | Re: [xsl] using xsl:with-param in a, David Carlisle |
RE: [xsl] using xsl:with-param in a, Niki Dinsey | Date | Re: [xsl] using xsl:with-param in a, David Carlisle |
Month |