My sincere apologies.  I had been stepping through the stylesheet and saw both the <xsl:matching-substring> and <xsl:non-matching-substring> instructions get called for what I thought was the same string, but it's not.  Sorry for wasting your and the list's time.

Chris 




On Feb 7, 2007, at 2:35 PM, Michael Kay wrote:

I'd like to see what's in "processing logic 1|2". Simplify it if necessary to convince me that that's not where the bug lies!
 
regex="^[·][\s]*
 
seems strange, it's the same as
 
regex="^·\s*
 
but I can't see anything wrong with it. Also, the xsl:when test could be written
 
<xsl:when test="(starts-with(., '·')">
 
since the match happens whether or not the middle dot is followed by spaces.
 
Actually, I notice that in your second example the <em> tag from the input has been copied to the output. That can't be happening inside the analyze-string, because the <em> element will have been atomized. So I think your code is copying the node to the output once more after the processing you've shown us. (Usual principle: if you can't find a bug, then assume it's in the code you're not looking at).
 
Michael Kay


From: saxon-help-bounces@lists.sourceforge.net [mailto:saxon-help-bounces@lists.sourceforge.net] On Behalf Of Chris von See
Sent: 07 February 2007 22:20
To: Mailing list for SAXON XSLT queries
Subject: [saxon] Question regarding XPath matches() and <xsl:analyze-string>

I have a stylesheet that is attempting to strip bullets and front-end whitespace off a list of <p> nodes and convert them into <li> nodes.  I'm using Saxon B with patch 8804.  In the stylesheet, there's an <xsl:choose> with the following <xsl:when>:

     <xsl:when test="matches(.,'^[·][\s]*')">
<xsl:element name="li">
<xsl:for-each select="node()">
<xsl:analyze-string select="." regex="^[·][\s]*">
<xsl:matching-substring>
... processing logic 1 ...
</xsl:matching-substring>
<xsl:non-matching-substring>
... processing logic 2 ...
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:for-each>
</xsl:element>
    </xsl:when>

What I *expect* to have happen is:
a)  the <xsl:when> test will return true when the string value of the input element starts with a bullet followed by some number of spaces... 
b) the <li> element is created
c) the content of the input element is iterated through, and:
- any node whose string value starts with a bullet followed by some number of spaces will get handled by "processing logic 1"
- any node whose string value does NOT with a bullet followed by some number of spaces will get handled by "processing logic 2"

What's actually happening, however, is that any string that matches the test on <xsl:when> and goes through the <xsl:analyze-string> is sent to *both* the <xsl:matching-substring> and <xsl:non-matching-substring> instructions, so that when I input this:

      <p>·         Acuarios con carpas</p>
      <p>·         Hojas de <em>Perfil de pez</em></p>

I get this:

      <li>£         Acuarios con carpas£         Acuarios con carpas</li>
      <li>£         Hojas de £         Hojas de <em>Perfil de pez</em></li>

instead of what I want, which is:

      <p>Acuarios con carpas</p>
      <p>Hojas de <em>Perfil de pez</em></p>

Why is Saxon passing these strings to both <xsl:matching-substring> and <xsl:non-matching-substring>?

Thanks
Chris 




-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642_______________________________________________
saxon-help mailing list
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help