[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

local variables as entity reference in different style

Subject: local variables as entity reference in different stylesheets
From: Marko Draisma <mdraisma@xxxxxxxxxxx>
Date: Mon, 3 Dec 2001 19:48:50 +0000
xsl local variable
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.