Subject: Re: [xsl] problem with xsl:copy-of and counting lines From: David Carlisle <davidc@xxxxxxxxx> Date: Wed, 20 Jun 2007 12:43:40 +0100 |
> But if I want to use the value of the string for other operations I > have to declare a global variable, right? it depends what you want to do with it, I'd say 999 times out of a 1000 when users ask about variable usage the answer to the real underlying problem doesn't involve the use of variables at all. If it is a global variable it has a global value, but i thought you wanted different values calculated on different blocks. > Is it possible to match the node of an external document like > <xsl:template match="document('variables.xsl')/block"> or something like this? You are mixing up the concepts of matching and selecting. a maych pattern says, more or less 2if you happen to come across a node that looks like this, do the following". It's Xpath expressions in select attributes that actually steer the processor to look in different places. so you'd want <xsl:template match="block"> ... then at some point if you want to process the other doc, do <xsl:apply-templates select="document('variables.xsl')"/> or <xsl:apply-templates select="document('variables.xsl')/block"/> or whataver's needed in your case. > The variables.xsl file looks like this: oops that's xslt not an input file (although of course you can input xslt as data, it doesn't execute in that case) To spread your stylesheet code across multiple docu,emts you don't use document() you use xsl:import or xsl:include but these are compile time constructs the whole stylesheet is constructed by importing teh necessary .xsl files _before_ any transformation actually runs. Take 10 steps back. What problem are you trying to solve, just state it in english, without assuming that the solution requires the use of xsl:variable. > I am just waiting for Michael > Kays two books about XPath 2.0 and XSLT 2.0 for helping me with the > theme. are you using XSLT2 (all answers given so far assume the use of XSLt1) there are easier ways of counting lines in xslt2 as it has regular expression support. Also, _why_ do you want to count all the lines in an xml file, ignoring the XML structure, if that's what you really need it would seem to be easier to use a non xml tool, wc -l for example. David ________________________________________________________________________ The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom. This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] problem with xsl:copy-of , Andreas Peter | Thread | Re: [xsl] problem with xsl:copy-of , Andreas Peter |
Re: [xsl] problem with xsl:copy-of , Andreas Peter | Date | Re: [xsl] problem with xsl:copy-of , Andreas Peter |
Month |