Subject: Re: [xsl] How to make this XSLT works for more than two section From: Andrew Welch <andrew.j.welch@xxxxxxxxx> Date: Fri, 15 Jun 2012 16:55:41 +0100 |
> <xsl:function name="custom:equalPredecingItemCount" as="xs:integer"> > <xsl:param name="preceding_items"/> > <xsl:param name="this_item"/> > <xsl:value-of select="sum(for $item in $preceding_items return custom:getEqualityValue($item, $this_item))"/> > </xsl:function> > > <xsl:function name="custom:getEqualityValue" as="xs:integer"> > <xsl:param name="item1"/> > <xsl:param name="item2"/> > <xsl:value-of select="if (deep-equal($item1, $item2)) then 1 else 0"/> > </xsl:function> A tip here - when the sequence type (as attribute) of the function is an atomic, always use xsl:sequence instead of xsl:value-of. When you use value-of you create a text node, which then gets atomized to the sequence type, so you can avoid that unnecessary step by using xsl:sequence which will return an atomic. The general rule is 'always use xsl:sequence in xsl:functions', as you pretty much always return atomics from functions. (that's also a good interview question "what's the difference between xsl:sequence and xsl:value-of) -- Andrew Welch http://andrewjwelch.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] How to make this XSLT wor, Robby Pelssers | Thread | [xsl] XSL-FO in the client?, Wendell Piez |
RE: [xsl] How to make this XSLT wor, Robby Pelssers | Date | [xsl] Re: date format using xslt 1., Jacob L |
Month |