xsl-list
[Top] [All Lists]

[xsl] Pattern Substring

2010-03-02 23:32:12
Hi ,
I have xml like below and I want to do pattern match and get option
numbers which is always space delimited. Using the template I am able
to get the second node correctly .
But in the First element, am somehow missing the "X".

Input:

<OPTIONS >Text1 X055-0001 Text1 Textx2</OPTIONS>
<OPTIONS >Text1 055-0002 Text1 Text3</OPTIONS>

my xslt

 <xsl:template match="OPTIONS">
  <xsl:variable name="index" select="string-length(substring-before(.,'055'))"/>
    <xsl:element name="OPTION">
 <xsl:attribute name="optionNumber"><xsl:value-of
select="normalize-space(substring(.,$index,9))"/></xsl:attribute>
        <xsl:apply-templates/>
    </xsl:element>
 </xsl:template>

desired output:
<OPTIONS optionNumber=' X055-0001'>Text1 X055-0001 Text1</OPTIONS>
<OPTIONS  optionNumber='055-0001'>Text1 055-0001 Text1</OPTIONS>

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>