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>
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. Commented Apr 11, 2011 at 6:49
  • i have updated the post and write the code i m using... plz help me out... Commented Apr 11, 2011 at 6:56
  • possible duplicate of Does XSLT have a Split() function? Commented Apr 11, 2011 at 12:30

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

"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
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.