AB.
AB.

Reputation: 859

Comma split function in XSLT 1.0

I have a parameter in which I'm having information like:

"item1,item2,item3,item4"

So this could be 1 or 2 or 3 or 4.

I want to split it and process it individually. Any idea how to achieve this?

Upvotes: 1

Views: 1699

Answers (1)

Lachlan Roche
Lachlan Roche

Reputation: 25966

Use exslt, these extensions are available for most XSLT processors.

Here is an implementation of str:split as an XSLT template. It is called like so:

<xsl:variable name="values">
    <xsl:text>item1,item2,item3,item4</xsl:text>
</xsl:variable>

<xsl:call-template name="str:split">
   <xsl:with-param name="string" select="$values" />
   <xsl:with-param name="pattern" select="','" />
</xsl:call-template>

Upvotes: 1

Related Questions