[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: A function that tokenizes a string, wrapping each
On 21.04.2016 14:20, Costello, Roger L. costello@xxxxxxxxx wrote:
I've implemented the function, see below. It works fine, but I want to know if it can be improved. Is there a way to write the function more idiomatic? Shorter? Generalized to be more widely useful? /Roger codepoints-to-string($line-delimiter))" as="xs:string*" /> <xsl:variable name="len" select="count($tokens)" as="xs:integer"/> as="xs:integer" /><xsl:for-each select="1 to $len"> <xsl:variable name="index" select="xs:integer(.)" <xsl:variable name="value" select="$tokens[position() eq$index]" as="xs:string" /> <xsl:choose> <xsl:when test="$value eq ''"/> <xsl:otherwise> <xsl:element name="{$headers[position() eq $index]}"> <xsl:sequence select="$value"/> </xsl:element> </xsl:otherwise> </xsl:choose> </xsl:for-each> Can't you simply process the tokens directly e.g. <xsl:for-each select="tokenize($line, codepoints-to-string($line-delimiter))"> <xsl:if test=". ne ''"> <xsl:variable name="pos" select="position()"/> <xsl:element name="{$headers[$pos]}"> <xsl:value-of select="."/> ?
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|