Subject: Re: [xsl] A function that tokenizes a string, wrapping each token in start-tag , end-tag pairs? From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Thu, 21 Apr 2016 12:56:23 -0000 |
Okay, I changed the implementation as you suggested, see below. The new
implementation is much shorter and much clearer. Can it be improved even further?
codepoints-to-string($delimiter))">
<!-- Create an element for each non-empty token in $line. $line is tokenized using the sequence of symbols denoted by $line-delimiter. For the token at position i, name the element using the string in headers[$i] --> <xsl:function name="f:line" as="element()*"> <xsl:param name="line" as="xs:string" /> <xsl:param name="delimiter" as="xs:integer+" /> <xsl:param name="headers" as="xs:string+" />
<xsl:for-each select="tokenize($line,
<xsl:if test=". ne ''"> <xsl:variable name="pos" select="position()" /> <xsl:element name="{$headers[$pos]}"> <xsl:sequence select="."/> </xsl:element> </xsl:if> </xsl:for-each>
</xsl:function>
It would depend on the data and on the structure of the headers variable whether the separate
<xsl:for-each select="tokenize($line, codepoints-to-string($delimiter))[. ne '']">
--- Diese E-Mail wurde von Avast Antivirus-Software auf Viren gepr|ft. https://www.avast.com/antivirus
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] A function that tokenizes, Costello, Roger L. c | Thread | Re: [xsl] A function that tokenizes, Costello, Roger L. c |
Re: [xsl] A function that tokenizes, Costello, Roger L. c | Date | Re: [xsl] A function that tokenizes, Costello, Roger L. c |
Month |