[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: so how does sum() work?
Hi Michael, Thank you for your reply. I have tried to declare all types but the same error persists. I'll do some further investigation and get back to you. Cheers Jacek On Wed, May 14, 2008 at 5:45 PM, Michael Kay <mike@xxxxxxxxxxxx> wrote: > I can't see what's wrong here and I suspect the problem might be elsewhere. > > One bit of advice, though: type errors are much easier to diagnose if you > declare the types of all your variables and parameters (using the "as" > attribute). This typically results in the error message being reported much > closer to the point where your code is actually wrong. > > Michael Kay > http://www.saxonica.com/ > > > > > -----Original Message----- > > From: Jacek Radajewski [mailto:jacekrad@xxxxxxxxx] > > Sent: 14 May 2008 07:20 > > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > > Subject: so how does sum() work? > > > > 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) > 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 > > -- Jacek Radajewski
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|