Subject: Re: [xsl] XSL - avoiding code duplication From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Mon, 26 May 2003 13:14:17 -0400 |
<xsl:template match="commonref" mode="quux"> <xsl:variable name="attribute"> <xsl:call-template name="setattribute"> <xsl:with-param name="node" select="."/> </xsl:call-template> </xsl:variable> ... </xsl:template>
Enjoy, Wendell
I'm trying to cut down on the duplication of XML and XSL in my project....
...I'm not very fond of this kind of cut-and-paste development so I tried to write a call-template function to manage these variables, however, if I do that the scope of the variables doesn't reach my mode function. For example: <xsl:template match="commonref" mode="quux"> <xsl:call-template name="set-vars"> <xsl:with-param name="node" select="."/> </xsl:call-template> <xsl:value-of select="$attribute"/> </xsl:template> <xsl:template name="set-vars"> <xsl:param name="node/> <xsl:variable name="attribute"> <xsl:choose> <xsl:when test="node/@attribute"> <xsl:value-of select="node/@attribute"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="id(node/@idref)/@attribute"/> </xsl:otherwise> </xsl:choose> </xsl:variable> </xsl:template> Does not work and gives an error that the variable is out of scope. Sensible. But my question is how to I compartmentalize this code so I don't have to cut-and-paste it all over the place (btw there are about 5 variables I need to do this with each time -- so the c-n-p is a lot more than it seems here). Suggestions? -j
__________________________________ Do you Yahoo!? The New Yahoo! Search - Faster. Easier. Bingo. http://search.yahoo.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
___&&__&_&___&_&__&&&__&_&__&__&&____&&_&___&__&_&&_____&__&__&&_____&_&&_ "Thus I make my own use of the telegraph, without consulting the directors, like the sparrows, which I perceive use it extensively for a perch." -- Thoreau
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] XSL - avoiding code duplicati, Jason Varsoke | Thread | [xsl] xsl:fo keeps, Tim Jones |
[xsl] Creating an array, Alan Gardner | Date | Re: [xsl] taking a literal or a att, Wendell Piez |
Month |