xsl-list
[Top] [All Lists]

[xsl] so how does sum() work?

2008-05-13 23:21:09
Hi All,

I'm experiencing a strange (for me) behavior in my XSLT:

This works:
        <xsl:for-each select="cdm:classification/cdm:app-domain">
          <xsl:call-template name="print-assertion">
            <xsl:with-param name="business-rule">APP-0010</xsl:with-param>
            <xsl:with-param name="message">A classification to a
Functional Application Domain must include a percentage of use greater
than
              zero. </xsl:with-param>
            <xsl:with-param name="result"
select="number(@cdm:percent-of-use) &gt; 0"/>
          </xsl:call-template>
        </xsl:for-each>


But this produces "required item type of first operand of '/' is node;
supplied value has item type xs:string"
        <xsl:call-template name="print-assertion">
          <xsl:with-param name="business-rule">APP-0011</xsl:with-param>
          <xsl:with-param name="message">An Application's percentage
of use across all non LOB domain classifications must be equal to
100%. </xsl:with-param>
          <xsl:with-param name="result"
select="sum(cdm:classification/cdm:app-domain/@cdm:percent-of-use) =
1.0"/>
        </xsl:call-template>

I'm using saxon 9B inside oxygen 9.2

Now if I execute
sum(cdm:classification/cdm:app-domain/@cdm:percent-of-use) = 1.0
within oxygen it correctly evaluates to either true or false, but
produces error when executing within my XSLT ... but only if the
result evaluates to false.  When the sum of those attributes does
equal 1.0 then no error is generated.


Any ideas?

Thanks in advance

Oh, BTW: I call my print-assertion template maybe 40 times in my
stylesheet and all works well.  Its only the sum() that is causing me
grief.

Jacek

----------- print-assetrion template --------------------
 <xsl:template name="print-assertion">
    <xsl:param name="result" select="false()"/>
    <xsl:param name="element"/>
    <xsl:param name="business-rule"/>
    <xsl:param name="message"/>
    <xsl:if test="not($result) or $print-passed-assertions">
      <assertion>
        <asset-id>
          <xsl:value-of
select="$element/ancestor-or-self::node()[ends-with(name(),
'-asset')]/@cdm:uuid"/>
        </asset-id>
        <asset-name>
          <xsl:value-of
select="$element/ancestor-or-self::node()[ends-with(name(),
'-asset')]/cdm:name"/>
        </asset-name>
        <business-rule>
          <xsl:value-of select="$business-rule"/>
        </business-rule>
        <result>
          <xsl:value-of select="$result"/>
        </result>
        <element>
          <xsl:copy-of select="$element"/>
        </element>
        <message>
          <xsl:copy-of select="$message"/>
        </message>
      </assertion>
    </xsl:if>
  </xsl:template>

-- 
Jacek Radajewski

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>