Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - datatype >Thread Next - Re: datatype Re: datatypeTo: NULL Date: 7/3/2009 12:48:00 PM Larry Sulky wrote: > Hi. I need to perform some subtraction on some variables. At first my > XSLT 2.0 code looked like this: > > <xsl:variable name="bboxTokens" select="tokenize(@bbox,',')"/ > <xsl:variable name="bboxWidth" select="$bboxTokens[3] - > $bboxTokens[1]"/> > <xsl:variable name="bboxHeight" select="$bboxTokens[4] - > $bboxTokens[2]"/> > > > And the error was that the datatype didn't support the operator - > (minus). So I added the as= attribute to declare the datatype: > > > <xsl:variable name="bboxTokens" as="decimal" select="tokenize > (@bbox,',')"/> tokenize gives you a sequence of strings, not a decimal. And the datatypes are in the W3C XML schema namespace so you need e.g. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"> ... <xsl:variable name="bboxTokens" as="xs:string*" select="tokenize(@bbox, ',')"/> > <xsl:variable name="bboxWidth" as="decimal" select="$bboxTokens > [3] - $bboxTokens[1]"/> <xsl:variable name="bboxWidth" as="xs:decimal" select="xs:decimal($bboxTokens[3]) - xs:decimal($bboxTokens[1])"/> -- Martin Honnen --- MVP XML http://msmvps.com/blogs/martin_honnen/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
