Subject: [xsl] local variables as entity reference in different stylesheets From: Marko Draisma <mdraisma@xxxxxxxxxxx> Date: Mon, 3 Dec 2001 19:48:50 +0000 |
Hi there (3rd try), In stylesheets a.xsl, b.xsl and c.xsl I use the same local variables (not top-level, but inside templates). I think the easiest way to do this, is to make use of 'variables.xsl' as an entity-reference (&variables;). In fact, this is the way I do it. The only ugly thing about it, is that I have to put "xmlns:xsl='http://www.w3.org/1999/XSL/Transform'" into each variable, because I can't think of a suitable root element. It looks like this: <xsl:variable xmlns:xsl="http://www.w3.org/1999/XSL/Transform" name="attributes"> <xsl:call-template name="list"> <xsl:with-param name="elements" select="normalize-space(attributes)"/> <xsl:with-param name="mode" select="'alias'"/> </xsl:call-template> </xsl:variable> <xsl:variable xmlns:xsl="http://www.w3.org/1999/XSL/Transform" name="attributevals"> <xsl:call-template name="list"> <xsl:with-param name="elements" select="normalize-space(attributes)"/> <xsl:with-param name="mode" select="'value'"/> </xsl:call-template> </xsl:variable> Another way to do this, is to make use of a "dummy" root element, like this: <root xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:variable name="attributes"> <xsl:call-template name="list"> <xsl:with-param name="elements" select="normalize-space(attributes)"/> <xsl:with-param name="mode" select="'alias'"/> </xsl:call-template> </xsl:variable> <xsl:variable name="attributevals"> <xsl:call-template name="list"> <xsl:with-param name="elements" select="normalize-space(attributes)"/> <xsl:with-param name="mode" select="'value'"/> </xsl:call-template> </xsl:variable> </root> It works, but I would like to know what is considered to be "best practice". Thanx, Marko Draisma. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] select all nodes WITHOUT , Nisheet Verma | Thread | Re: [xsl] local variables as entity, Jeni Tennison |
Re: [xsl] local variables as entity, Jeni Tennison | Date | RE: [xsl] select all nodes WITHOUT , Nisheet Verma |
Month |