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

Inconsistent values from <xsl:variable/>

Subject: Inconsistent values from <xsl:variable/>
From: Adam Worrall <adam-xsllist@xxxxxxxxxx>
Date: 15 Jun 2005 16:30:44 -0400
adam worrall
The use of an <xsl:if/> seem to result in different values being assigned:

  <xsl:variable name="RTF_GOOD">
      <xsl:value-of select="//out-form:Subform[@idType = 'RuleContent']"/>

  <xsl:variable name="RTF_BAD">
    <xsl:if test="2 > 1">
      <xsl:value-of select="//out-form:Subform[@idType = 'RuleContent']"/>

Both have the same select="" expression; it's only the presence of the
<xsl:if/> that changes things.

 $RTF_GOOD appears to contain the RTF that I expect;

 $RTF_BAD appears to be a string containing the flattened text() from
    within the RTF I expect.

Any ideas why they differ ? Is this a bug in Xalan ? A bug in my
understanding of XSL is far more likely :>

--- Details ---

The above is a trivial example; I know about <xsl:variable select="..."/>,
but I need to do some conditional logic to determine exactly which
nodeset to place into my variable.)

(It may also be worth pointing out that I'm repeatedly using XPath on
 node-sets, along the lines of:

  <xsl:variable "foo"  select="//elem1"/>
  <xsl:variable "bar"  select="$foo//elem2"/>
  <xsl:variable "quux" select="$bar/[@attr = 'thing']"/>

 in case that explains anything ...)

I'm examining the contents using this:

    <xsl:call-template name="dumpContext">
      <xsl:with-param name="myNodeSet" select="xalan:nodeset($RTF_GOOD)"/>

    <xsl:call-template name="dumpContext">
      <xsl:with-param name="myNodeSet" select="xalan:nodeset($RTF_BAD)"/>

  <xsl:template name="dumpContext">
    <xsl:param name="myNodeSet"/>
    <xsl:for-each select="$myNodeSet">
      <xsl:value-of select="local-name()"/>
      <xsl:for-each select="ancestor-or-self::*">
        <xsl:text>/</xsl:text><xsl:value-of select="local-name()"/>
      <xsl:value-of select="text()"/>

And seeing output like this:

 Validation ERROR: GOOD Subform[/QueryResult/FormSet/Form/Thing/Subform]""]
 Validation ERROR: BAD  []"aaaaacoy3y0co110yy2005-01-012005-01-012005-01-03"]

Many (many !) thanks,

 - Adam

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.