Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: datatype

From: Martin Honnen <mahotrash@-----.-->
To: NULL
Date: 7/3/2009 3:43:00 PM
Larry Sulky wrote:
> On Jul 3, 8:20 am, Martin Honnen <mahotr...@yahoo.de> wrote:
>> I did already suggest
>>
>> <xsl:variable name="bboxWidth"
>>                   as="xs:decimal"
>>                   select="xs:decimal($bboxTokens[3]) -
>> xs:decimal($bboxTokens[1])"/>
>>
>> where xs:decimal($bboxTokens[3]) casts the third item in the $bboxTokens
>> sequence to a decimal.


> Your suggestion didn't work at first. It gave me this error:
> 
> "Type error, value does not match a required type as specified
> by the matching rules in 2.5.4 Sequence Type Matching.
> - 'xs:decimal' "
> 
> But then I removed the as= attribute:
> 
> <xsl:variable name="bboxWidth"
>   select="xs:decimal($bboxTokens[3]) - xs:decimal($bboxTokens[1])"/>
> 
> and then it worked perfectly. So I'm a little confused, but
> grateful! :-)

I am not sure why you get that error.
When I try this XML document

<foo bbox="1,2,3,4"/>

against this XSLT

<xsl:stylesheet
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="2.0"
   xmlns:xs="http://www.w3.org/2001/XMLSchema">

   <xsl:template match="foo">
     <xsl:variable name="bboxTokens" as="xs:string*" 
select="tokenize(@bbox, ',')"/>
     <xsl:variable name="bboxWidth"
                  as="xs:decimal"
                  select="xs:decimal($bboxTokens[3]) - 
xs:decimal($bboxTokens[1])"/>
     <xsl:value-of select="$bboxWidth"/>
   </xsl:template>

</xsl:stylesheet>

then it runs fine with Saxon 9 and AltovaXML tools 2009.






-- 

	Martin Honnen --- MVP XML
	http://msmvps.com/blogs/martin_honnen/


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent