[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
Re: Transform symbol to element
Subject: Re: Transform symbol to element
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Wed, 11 Nov 2009 12:36:20 +0100
|
Selvaganesh wrote:
This is possible to convert the quote symbol to xml elements?
If anybody know the way please share me, below placed my input file format
and required output format.
Input XML:
<p>This is the sample of double quote starting the double publication
ended</p>
<p>This is the sample of single quote starting the single publication
ended</p>
Output XML:
<para>This is the sample of double quote starting <quote open=""
close="">the double publication</quote> ended</para>
<para>This is the sample of single quote starting <quote open=""
close="">the single publication</quote> ended</para>
With XSLT 2.0 you can try it as follows:
<xsl:template match="p">
<para>
<xsl:analyze-string select="." regex="()([^]*)()|()([^]*)()">
<xsl:matching-substring>
<quote open="{regex-group(1)}" close="{regex-group(3)}">
<xsl:value-of select="regex-group(2)"/>
</quote>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:value-of select="."/>
</xsl:non-matching-substring>
</xsl:analyze-string>
</para>
</xsl:template>
--
Martin Honnen
http://msmvps.com/blogs/martin_honnen/
|
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format
RSS 2.0 |
|
Atom 0.3 |
|
|