Altova Mailing List Archives


Re: [xsl] Option mystery

From: "Oleg Konovalov" <olegkon@--------->
To:
Date: 12/14/2006 2:44:00 PM
Guys,



I understood a part of the problem,
that choose is in the for-each block:
<xsl:for-each select="$tier/option">
 <xsl:choose>
   <xsl:when test="$tier/option[condition1]">   <----- bug: I removed
that "$tier/option[]"
   ...
   </xsl:when>
   <xsl:when test="$alternate-tier/option[condition1]">
   ...
   </xsl:when>
 </xsl:choose>
</xsl:for-each>
As soon as I removed that "$tier/option[]", it started working.
The funny thing is that it was in production for 2 years - hidden bug...

But is it technically legitimate to have "$alternate-tier/option[]" in
the second xsl:when block ?
Looks like if similar node exists in parallel tree and matches same
conditions, it sets it's value to "N/A".
Hmm, I am not sure. What do you think ?

Thank you,
Oleg.

On 12/13/06, Michael Kay <mike@xxxxxxxxxxxx> wrote:
>
> <xsl:choose>
>   <xsl:when test="$tier/option[option-num=$cur-option-num and
> @rate-increase='true']">
>     <option rate-increase="{@rate-increase}">
>        <debug1>branch1</debug1>
>         ...other elements
>      </option>
>    </xsl:when>
> </xsl:choose>
>
> A few questions regarding snippet:
> 1) is that "option" a predefined XSLT1.0 construct / keyword
> / operation ?

If you mean the option written as "<option rate-increase..." then it is a
literal result element: an element to be copied to the result.

> I can't find any in the XSLT book.



Look in the index under "literal result element".
>
> 2) the bug I am trying to fix is that somehow on exit I am
> getting a node with <option rate-increase="false"> (that
> debug1=branch1 and
> option-num=1).  How is that possible ?   That "branch1" is unique and
> can't come from any other place. How can that expression
> inside [] fail ?

Perhaps you're confused because the predicate can only return true if
@rate-increase is "true", whereas the value that's output is "false". But
the two occurrences of @rate-option are evaluated with different context
nodes, so you're looking at two different attributes.


Michael Kay
http://www.saxonica.com/

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.