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

Referring to imported variable's value in override

Subject: Referring to imported variable's value in override
From: "Christian Roth" <roth@xxxxxxxxxxxxxx>
Date: Mon, 29 Mar 2010 17:37:28 +0200
 Referring to imported variable's value in override
Hello,

can I use the value of an imported variable in its override definition?

My current use-case is defining the value of a variable in a stylesheet
customization layer as "all it already contains, plus those two items".

Naively trying, I first came up with this:

--main.xsl--
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs"
  version="2.0">

  <xsl:import href="sub.xsl" />

  <!-- MAIN -->
  <xsl:variable name="test" select="$test, ('c','d')" />

  <xsl:template match="/">
    <xsl:message select="$test"/>
  </xsl:template>

</xsl:stylesheet>
--end--

--sub.xsl--
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs"
  version="2.0">

  <!-- SUB -->
  <xsl:variable name="test" select="('a','b')"/>


</xsl:stylesheet>
--end--

, thinking that the declaration of test in main would use the imported
declaration from sub.xsl since the one in main.xsl does not yet exist at
that position. However, this gives me circular reference error in main.xsl:

SystemID: /Users/chris/Beruf/infinity-loop/testdata/feature-testing/
stylesheet-levels/main.xsl
Severity: fatal
Description: Circular definition of variable test
Start location: 9:0
URL: http://www.w3.org/TR/xslt20/#err-XTDE0640


The desired output in the console would be

--desired output--
a b c d
--end--

How does one best tackle this? Maybe define the base variable with a
different name, say, "test-base" in the imported stylesheet, so that
there is no name-clash resp. override happening? How to do this when
there are more customization layers to handle, each one wishing to refer
to "what's already there"?


Regards
Christian

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.