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

Conditional XSL Variable

Subject: Conditional XSL Variable
From: raulvk <raulvk.soa@xxxxxxxxx>
Date: Thu, 20 Nov 2008 19:45:34 +0000
 Conditional XSL Variable
Hi everyone,

I am using XSLT 2.0 to transform from one XML document to another.

I have defined a lookup table embedded in an XSL variable, which is
used within the template and is defined as a global variable similar
to the following:

    <xsl:variable name="lookupTable">
            <map:entry codeA="90434" codeB="9801" codeC="0121" />
            <map:entry codeA="90437" codeB="1800" codeC="1212" />
            <map:otherwise codeB="9800" codeC="9999" />

Functionally, this table will be looked up based on codeA, and the
corresponding values of codeB and codeC will be inserted in different
elements within the resulting XML document.
However, if the received value does not match any of the specified
codeA values, the "otherwise" node should be used instead.

I have created a variable that will store the node that will be used
to obtain the codeB and codeC variables.

                <xsl:variable name="mappingsCodeA">
test="count($lookupTable/map:table/map:entry[@codeA=$valueOfCodeA]) =
select="$lookupTable/map:table/map:entry[@codeA=$valueOfCodeA]" />

(where $valueOfCodeA is a variable that has the value that has to be looked up).

However, I am finding that the variable $mappingsCodeA never contains
anything. I think it has something to do with the type of the
variable, because it is not initialised as a result-tree fragment.

Has anyone come across this problem before? By the way, I am using


Current Thread


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.
First Name
Last Name
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.