1

I need to split a string "ab|bc|cd>xy|yz|zx>pq|rs|tu>

help me if any one can...

here is the code....

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">


<xsl:output method="html" version="1.0" indent="yes" />

<xsl:template match="/products/product">

<xsl:variable name="ImageString" select="properties/property[@name='Brand']"></xsl:variable>

<xsl:variable name="ImageFolderName" select="substring-before($ImageString,'#')" ></xsl:variable>
Folder Name:-<xsl:value-of select="$ImageFolderName" ></xsl:value-of>
<br/>
<xsl:variable name="ImageStringName" select="substring-after($ImageString,'#')" ></xsl:variable>
Final String:-<xsl:value-of select="$ImageStringName" ></xsl:value-of>

<xsl:variable name="values">     
    <xsl:text><xsl:value-of select="$ImageStringName" ></xsl:value-of></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> 
</xsl:template>

</xsl:stylesheet>
Mitch Wheat
  • 295,962
  • 43
  • 465
  • 541
tarun sharma
  • 11
  • 1
  • 3
  • Please post the code you have written so far. People generally do not like to just write your code for you. As it is, this is a work description, not a question. – Mitch Wheat Apr 11 '11 at 06:49
  • i have updated the post and write the code i m using... plz help me out... – tarun sharma Apr 11 '11 at 06:56
  • possible duplicate of [Does XSLT have a Split() function?](http://stackoverflow.com/questions/136500/does-xslt-have-a-split-function) –  Apr 11 '11 at 12:30

1 Answers1

4

To summarise the linked question below:

If you are using XSLT 2.0 then you can use tokenize(string, separator) method.

If you are using XSLT 1.0 then you'd need to write a recursive method to achieve this.

or

Use the tokenize() method if your template supports EXSLT.

See this question for full details of the options.

Community
  • 1
  • 1
Tim
  • 4,414
  • 4
  • 35
  • 49
  • "If you are using XSLT 1.0 then you'd need to write a recursive method" - or reuse one that has already been written: see the str:tokenize named template code on www.exslt.org – Michael Kay Apr 11 '11 at 09:33
  • Indeed - as it says in the linked question, I've updated the answer to make the options more explicit, although reading the linked question and answer has all the options. – Tim Apr 11 '11 at 09:55