[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Pattern Substring

Subject: RE: Pattern Substring
From: "Ramesh, Marimuthu" <M.Ramesh@xxxxxxxxxxx>
Date: Wed, 3 Mar 2010 11:47:24 +0530
RE:  Pattern Substring
Hi,

Your requirement is bit unclear. Your below code gives the output as
below:

<OPTION optionNumber="X055-0001">Text1 X055-0001 Text1 Textx2</OPTION>

<OPTION optionNumber="055-0002">Text1 055-0002 Text1 Text3</OPTION>

But your desired output below does not have any OPTION element, and also
the text inside the elements differ.

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

> Using the template I am able to get the second node correctly .

Do you mean the output by the above line.

Make the requirement clear.

Regards,
Rummy

-----Original Message-----
From: Senthilukvelaan [mailto:skumaravelan@xxxxxxxxxxxxxx]
Sent: Wednesday, March 03, 2010 11:02 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Pattern Substring

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>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.