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

Variable scope when using imported stylesheets

Subject: Variable scope when using imported stylesheets
From: Ralph Holz <ralph.holz@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 24 Aug 2004 15:47:40 +0200
xsl variable scope
Hi,

I'm a bit at a loss how I can use variables in the context of imported stylesheets. I have a stylesheet A that worked standalone up to now, but now needs to import templates from a stylesheet B.

I had defined global variables in A to save myself some typing: they selected some nodesets *deep* in the source tree that I needed very often in the processing, e.g. (simplified)

<xsl:variable
  name="VehData"
  select="/root/data/baseDboFileRef/FileRefEval/FileRefVehData"
/>

I used $VehData whenever I needed to access the "vehicle data". Fine as long as there is only one baseDboFileRef.

But my *new* source tree is going to have several ones, which are treated with the templates from the imported stylesheet:

<xsl:for-each select="/root/data/baseDboFileRef">
  <xsl:call-template name="[...]" />
  ... many more templates from B called ...
</xsl:for-each>

I would like to define variables again to save the typing, so I thought I would need relative paths in the variable to make the access independent of the changing context (baseDboFileRef).

First, I tried defining global variables in the imported stylesheet that were an abbreviated version, as a tribute to the changed context:

<xsl:variable
  name="ImpVehData"
  select="FileRefEval/FileRefVehData"
/>

I didn't have much hope that that would work and indeed it didn't...

Now I could define my variables within each of the templates that get imported and I guess that would work. But since there are so many templates I'm wondering if there is a more elegant way to do this?

Thanks,
Ralph

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.