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

Predicate Evaluation

Subject: Predicate Evaluation
From: "Fernando Ribeiro" <webmaster@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 26 Nov 2007 12:03:11 -0200
 Predicate Evaluation
Hello,

I am trying to find an explanation for the following behavior:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="
http://www.w3.org/1999/XSL/Transform" xmlns:ns1="urn:ns1"
xmlns:ns2="urn:ns2">
    <xsl:param name="param1"/>
    <xsl:param name="param2"/>
    <xsl:template match="/">
        <ns3:Element1 xmlns:ns3="urn:ns3">
            <xsl:for-each select="$param1/ns1:Element1">
                <ns3:Element2>
                    <xsl:value-of
select="$param2/ns2:Element1/ns2:Element2   = ns1:Element2"/> <!--
returns "true" -->
                </ns3:Element2>
                <ns3:Element3>
                    <xsl:value-of
select="$param2/ns2:Element1[ns2:Element2 =
ns1:Element2]/ns2:Element3"/> <!-- returns empty -->
                </ns3:Element3>
            </xsl:for-each>
        </ns3:Element1>
    </xsl:template>
</xsl:stylesheet>

 Using Saxon 8.4, the expression doesn't evaluate as expected when
used as a predicate, unless it is assigned to a variable first:

<?xml version=" 1.0 " encoding="UTF-8"?>
 <xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns1="urn:ns1"
xmlns:ns2="urn:ns2">
      <xsl:param name="param1"/>
     <xsl:param name="param2"/>
     <xsl:template match="/">
         <ns3:Element1 xmlns:ns3="urn:ns3">
             <xsl:for-each select="$param1/ns1:Element1">
                <xsl:variable name="variable1" select="ns1:Element2"/>
                <ns3:Element2>
                     <xsl:value-of
select="$param2/ns2:Element1/ns2:Element2 = $variable1"/> <!-- returns
"true" -->
                 </ns3:Element2>
                 <ns3:Element3>
                     <xsl:value-of
select="$param2/ns2:Element1[ns2:Element2 =
$variable1]/ns2:Element3"/> <!-- returns "value1" -->
                 </ns3:Element3>
             </xsl:for-each>
         </ns3:Element1>
     </xsl:template>
 </xsl:stylesheet>

These are the inputs:

<ns1:Element1 xmlns:ns1="urn:ns1">
   <ns1:Element2>Test</ns1:Element2>
 </ns1:Element1>

<ns2:Element1 xmlns:ns2="urn:ns2">
   <ns2:Element2 attribute1="value1">Test</ns2:Element2>
  <ns2:Element3>value1</ns3:Element3>
 </ns2:Element1>

Can someone tell me why is it so?

Thanks,

Fernando

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.