Subject: RE: replace() and efficiency: troff-to-unicode conversion
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 13 Sep 2006 00:13:37 +0100
|
> <xsl:template match="text()">
> <xsl:analyze-string select="." regex="\\\\\\(\\\?([a-z])"
> <xsl:matching-substring>
> <xsl:choose>
> <xsl:when test="regex-group(1)='s'">...
> <xsl:when test="regex-group(1)='c'">...
>
> What I don't understand is what an XSLT 2 processor does when
> I pass it a text node like:
>
> abab\(?sabab\(?cabab
>
> There are two matches here: \(?s and \(?c . When my
> <xsl:choose> finds the first match (it's the first <xsl:when>
> within the <xsl:choose>), doesn't it just replace all
> instances of \(?s and then not read the rest of the
> <xsl:when> lines? That is, won't it fail to find the subsequent \(?c ?
The xsl:matching-substring instruction is executed once for each match. So
it's executed once to process \(?s, and once to process \(?c. In the first
case, the first xsl:when fires. In the second case, the second xsl:when
fires.
Michael Kay
http://www.saxonica.com/
|