Fwd: Some bugs in: date.add-duration.function.xsl
Андрей Бобров <[email protected]> Mon, 2 Aug 2010 19:49:43 +0300
| Newsgroups | gmane.text.xml.xslt.extensions |
|---|---|
| Message-ID | <[email protected]> |
I have sent this message to [email protected] previously, but get notification about that, that my message not delivered to members of the group because I'm not member of that group, so I send it now after that I have been come member of current list. Hello, I use your template that I found in: http://www.exslt.org/date/functions/add-duration/date.add-duration.template.xsl.html When I try to call the template in this peice of code: <xsl:variable name="dur1" select="xs:duration('P0000Y00M00DT00H00M01S')"/> <xsl:variable name="dur2" select="xs:duration('P0000Y00M00DT00H00M01S')"/> <xsl:variable name="duration"> <xsl:call-template name="date:add-duration"> <xsl:with-param name="duration1" select="xs:string($dur1)"/> <xsl:with-param name="duration2" select="xs:string($dur2)"/> </xsl:call-template> </xsl:variable> I get error: Arithmetic operator is not defined for arguments of types (xs:boolean, xs:integer) because here: <xsl:variable name="mult1" select="(($du1-neg) * -2) + 1"/> here: <xsl:variable name="mult2" select="(($du2-neg) * -2) + 1"/> here: <xsl:variable name="m" select="$months * ((($months >= 0) * 2) - 1)"/> and here: <xsl:variable name="s" select="$seconds * ((($seconds >= 0) * 2) - 1)"/> you don't use xs:integer constructor for cast booleans values (such as $du1-neg). So for solve it I added integer constructors: <xsl:variable name="mult1" select="(xs:integer($du1-neg) * -2) + 1"/> <xsl:variable name="mult2" select="(xs:integer($du2-neg) * -2) + 1"/> <xsl:variable name="m" select="$months * (xs:integer(($months >= 0) * 2) - 1)"/> <xsl:variable name="s" select="$seconds * (xs:integer(($seconds >= 0) * 2) - 1)"/> Also, here: <xsl:otherwise>P</xsl:otherwise> the template returns "P" if duration is 0, but "P" isn't valid form of xs:duration, so I changed it to: <xsl:otherwise>P0000Y00M00DT00H00M00S</xsl:otherwise> I believe that this code work of some XSLT processors, because different processors has different level of exaction of the XSLT code. I use: EditiX version 2010 Generally, you wrote very good and useful code. Thank you.