Subject: Re: [xsl] conditional xsl:analyze-string From: Syd Bauman <Syd_Bauman@xxxxxxxxx> Date: Tue, 10 Feb 2009 06:32:51 -0500 |
If I follow you, here (and I may not), you've provided the input, the XSLT you're trying, and the output of the XSLT you're trying. It would make answering questions a lot easier if you'd provide the desired output in addition to or instead of the actual output. Even better would be to also include a higher-level description of what you're trying to do. That said, maybe what you're looking for is <xsl:when>? (I say so in part because I'd like to find out if this is a reasonable approach, myself :-) <xsl:when test="matches(.,'[A-Z][a-z]+ [A-Z]\.')"> <xsl:analyze-string select="." regex="([A-Z][a-z]+) ([A-Z]\.)"> <xsl:matching-substring> <au> <s><xsl:value-of select="regex-group(1)"/></s> <f><xsl:value-of select="regex-group(2)"/></f> </au> </xsl:matching-substring> </xsl:analyze-string> </xsl:when> (Just an example, not really intended to handle your data; would have to be inside an <xsl:choose>, of course. > 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!!!
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] conditional xsl:analyze-strin, J. S. Rawat | Thread | Re: [xsl] conditional xsl:analyze-s, David Carlisle |
Re: [xsl] Restrictions on pattern f, Florent Georges | Date | Re: [xsl] conditional xsl:analyze-s, David Carlisle |
Month |