|

June 30th, 2009, 08:04 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
|
|
Regex in xsl:analyze-string
Hi All,
I need your help in matching a string, which looks like
<TYPE>,,<TYPE2> in the input xml. The separator here is comma. There may or may not be values in between some of the commas, i.e., the input string may be like no text,,<TYPE2> or <TYPE>,,no text. I need to match the no text area also.
INPUT:
$blockValue = "no text,no text,<TYPE2>,no text"
Code:
<KEYWDBLOCK BLOCK="3">
<VALUE>
<xsl:value-of select="$blockValue"/></VALUE>
<xsl:analyze-string select="$blockValue" regex="([A-Z0-9\-\s]+)">
<xsl:matching-substring>
<KEYWD BLOCK="3">
<xsl:value-of select="."/>
</KEYWD>
</xsl:matching-substring>
</xsl:analyze-string>
</KEYWDBLOCK>
PRESENT OUTPUT:
Code:
<KEYWDBLOCK BLOCK="3">
<VALUE>,,<TYPE2>,</VALUE>
<KEYWD BLOCK="3">TYPE2</KEYWD>
</KEYWDBLOCK>
REQD. OUTPUT:
Code:
<KEYWDBLOCK BLOCK="3">
<VALUE>,,<TYPE2>,</VALUE>
<KEYWD BLOCK="3"></KEYWD>
<KEYWD BLOCK="3"></KEYWD>
<KEYWD BLOCK="3">TYPE2</KEYWD>
<KEYWD BLOCK="3"></KEYWD>
</KEYWDBLOCK>
Any help is appreciated.
Thanks in advance
__________________
Rummy
Last edited by mrame; June 30th, 2009 at 08:07 AM..
|