1

I am having problems running the next XSL stylesheet:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="Blokea">
    <xsl:param name="Handiena" select="Blokea/Bl2">
       <xsl:if test="Blokea/Bl1>Blokea/Bl2">
    <xsl:param name="Handiena" select="Blokea/Bl1">
         <xsl:value-of select="$Handiena"/>
      </xsl:if>
</xsl:template>
</xsl:stylesheet>

over the next XML:

<?xml version="1.0" encoding="ISO-8859-1"?>
<Erroa>
    <Blokea>
        <Bl1>20</Bl1>
        <Bl2>10</Bl2>
    </Blokea>
</Erroa>

How can I solve it?

Haritz
  • 1,702
  • 7
  • 31
  • 50

1 Answers1

1

I think what you're trying to do is this:

<xsl:template match="Blokea">
  <xsl:param name="Handiena">
     <xsl:choose>
       <xsl:when test="./Bl1 &gt; ./Bl2">
         <xsl:value-of select="./Bl1"/>
       </xsl:when>
       <xsl:otherwise>
         <xsl:value-of select="./Bl2"/> 
       </xsl:otherwise>
    </xsl:choose>
 </xsl:param>
 <xsl:value-of select="$Handiena"/>
</xsl:template>

Correct me if I'm wrong.

hroptatyr
  • 4,702
  • 1
  • 35
  • 38
  • Correct answer, though with no explanation of the error. As with many errors in XSLT coding, it's a failure to think about what the context node is when writing a relative path expression. – Michael Kay Apr 19 '12 at 10:36
  • well also, xsl:params cannot be redefined in the way the OP was trying to do. And also, xslt is xml, so tags must be closed. – hroptatyr Apr 19 '12 at 10:48
  • @hroptatyr can you please have a look at this question - http://stackoverflow.com/questions/10698287/xpath-transformation-not-working-in-java . I am also using xpath transformation in java for xml signatures but the transformation does not seem to take place. – Ashwin May 23 '12 at 08:02