Subject: RE: [xsl] Newbie - trying to extract specific values from XML file. From: "Andreas L. Delmelle" <a_l.delmelle@xxxxxxxxxx> Date: Fri, 19 Mar 2004 19:06:07 +0100 |
> -----Original Message----- > From: Julian Voelcker > <snip /> > I want to be able to create a variable (generally boolean), give it a > value at one point in the template and then further down in the > template check the value of the variable and modify the output. > > I see that there is an xsl:variable element, but haven't found any > examples of it's use. > Hi, Well, IIC it probably won't exactly be what you need anyway... if a variable's in scope for the entire stylesheet, it's value has to remain the same during the entire transformation. If you want it's value to depend on the context node, it needs to be in scope only for the template matching the nodes in question, and so will not be accessible to other templates. > Some pointers would be appreciated. I would advise to take a good look at using xsl:param and xsl:with-param when calling/applying templates. Some pseudo-code: <xsl:template match="a"> <xsl:variable name="vbool" select="{statement-about-a}" /> ... <xsl:apply-templates select="b"> <xsl:with-param name="pbool" select="$vbool" /> </xsl:apply-templates> </xsl:template> <xsl:template match="b"> <xsl:param name="pbool" select="true()" /> <xsl:if test="$pbool"> <!-- the {statement-about-a} is true, or it isn't supplied --> </xsl:if> ... </xsl:template> Ok, the above maybe has a more elegant solution using the XPath parent-axis, but just to give you an idea... (OTOH: it could save you a few theoretically unnecessary traversals of the ancestor-axis, and replace them by one reference to the parent-axis in the higher-level template) Hope this helps! Cheers, Andreas XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Newbie - trying to extrac, Wendell Piez | Thread | [xsl] multilple output documents, Andreas Beppler |
Re: [xsl] Newbie - trying to extrac, Wendell Piez | Date | Re: [xsl] getting rid of doctype de, Paul Tremblay |
Month |