Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: merging two sequences in xslt

From: Martin Honnen <mahotrash@-----.-->
To: NULL
Date: 10/15/2008 6:48:00 PM
JMan wrote:
> can i change the datatypes of the lists, so that i can do something
> like
> <xsl:value-of select="for $p in 1 to count($l1) return ($l2[$p] div
> 10  , $l1[$p] div 10)" separator=" "/> ?

I don't understand how you expect the values a,b,c and so on to be 
treated as numbers.

However let's assume you have different input data

<parent>
<a>1,2,3,4,5,6,7,8</a>
<b>10,20,30,40,50,60,70,80</b>
</parent>

then you can of course convert the string sequence the tokenize function 
gives you to a number sequence:

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

   <xsl:template match="parent">
     <xsl:copy>
       <xsl:variable name="l1" as="xs:double*" select="for $item in 
tokenize(a, ',') return xs:double($item)"/>
       <xsl:variable name="l2" as="xs:double*" select="for $item in 
tokenize(b, ',') return xs:double($item)"/>
       <ab>
         <xsl:value-of select="for $p in 1 to count($l1) return ($l2[$p] 
div 10, $l1[$p] div 10)" separator=" "/>
       </ab>
     </xsl:copy>
   </xsl:template>

</xsl:stylesheet>
-- 

	Martin Honnen
	http://JavaScript.FAQTs.com/


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