Re: [xsl] Conditional XSL Variable

Subject: Re: [xsl] Conditional XSL Variable
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 20 Nov 2008 20:13:29 GMT
Others have pointed out that value-of will produce an epty text node
from a empty element, but most likely you don't want to this at all.

> 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
> Saxon-B

There are no result tree fragments in xslt 2 thankfully that has gone.

                <xsl:variable name="mappingsCodeA">

If you use value-of inside xsl:variable in thsi way you are not
assigning a string or attribute node to the variable but a document node
with child text node with string value the string value of the selection
which is relatively expensive to build and to use.

You were testing for count=1 but im guessing that you just mean to use 
map:entry[@codeA=$valueOfCodeA] if it exists or map:otherwise otherwise 

 <xsl:variable name="mappingsCodeA" select="$lookupTable/map:table/

Then you can use $mappingsCodeA/@codeB as because you have used a selct
attribute $mappings references the node in your lookup table, not a
document node containing a newly constructed tree.


The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 

Current Thread