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

conditional xsl:analyze-string

Subject: conditional xsl:analyze-string
From: "J. S. Rawat" <jrawat@xxxxxxxxxxxxxx>
Date: Tue, 10 Feb 2009 11:06:42 +0530
 conditional xsl:analyze-string
We have following kinds of data, which have totally unexpected patterns. Can anyone suggest me the conditional way to write the regular expression. It should not delete any kind of data if it is not matching exactly. As we have seen below that some portion of third name is getting deleted.

Input
<span class="name">Axxx B.</span>
<span class="name">B. Axxx</span>
<span class="name">xxx C. Dxxx</span>
<span class="name">Exxx-Exxx</span>

XSL
<xsl:analyze-string select="." regex="([A-Z][A-Z|a-z|\-|#]+)(,)?\s+([A-Z|\.]+)+">
<au>
<xsl:matching-substring>
<s><xsl:value-of select="regex-group(1)"/></s>
<xsl:value-of select="regex-group(2)"/><xsl:text> </xsl:text>
<f><xsl:value-of select="regex-group(3)"/></f>
</xsl:matching-substring>
</au>
</xsl:analyze-string>
<xsl:analyze-string select="." regex="([A-Z|\.]+)(,)?\s+([A-Z][A-Z|a-z|\-|#]+)">
<au>
<xsl:matching-substring>
<f><xsl:value-of select="regex-group(1)"/></f>
<xsl:value-of select="regex-group(2)"/><xsl:text> </xsl:text>
<s><xsl:value-of select="regex-group(3)"/></s>
</xsl:matching-substring>
</au>
</xsl:analyze-string>


Output
<au><s>Axxx</s> <f>B.</f></au>
<au><f>B.</f> <s>Axxx</s></au>
<au><f>C.</f> <s>Dxxx</s></au> <!--xxx is deleted-->
<au/> <!-- text is deleted-->

Any clue in this regard will be highly appreciable!!!

...JSR

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-2011 All Rights Reserved.