Seems to me that the empty string doesn't match or mismatch:
<data>
<para>C.1</para>
<para>F.1</para>
<para></para>
<para>H.1</para>
<para>F.2</para>
</data>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xsl:variable name="myregex">^([CF]\.[0-9\.]+)\s*(.*)$</xsl:variable>
<output>
<xsl:for-each select="data/para">
<input><xsl:value-of select="."/></input>
<xsl:analyze-string select="." regex="{$myregex}">
<xsl:matching-substring>
<match>
<xsl:value-of select="."/>
</match>
</xsl:matching-substring>
<xsl:non-matching-substring>
<nonmatch>
<xsl:value-of select="."/>
</nonmatch>
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:for-each>
</output>
</xsl:template>
</xsl:stylesheet>
I get (with Saxon 9.1):
<output>
<input>C.1</input>
<match>C.1</match>
<input>F.1</input>
<match>F.1</match>
<input/>
<input>H.1</input>
<nonmatch>H.1</nonmatch>
<input>F.2</input>
<match>F.2</match>
</output>
Joe
http://joe.fawcett.name
--------------------------------------------------
From: "Michael Kay" <mike(_at_)saxonica(_dot_)com>
Sent: Friday, July 04, 2008 2:18 PM
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Subject: RE: [xsl] Empty input in analyze-string
It doesn't look to me as if it matches an empty string. Perhaps you are
misinterpreting the evidence?
Michael Kay
http://www.saxonica.com/
-----Original Message-----
From: Mathieu Malaterre [mailto:mathieu(_dot_)malaterre(_at_)gmail(_dot_)com]
Sent: 04 July 2008 13:44
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Empty input in analyze-string
Hello,
I cannot figure out how to tell xsl:analyze-string that
empty input should not match regex.
eg.
<xsl:variable
name="myregex">^([CF]\.[0-9\.]+)\s*(.*)$</xsl:variable>
<xsl:analyze-string select="$para2" regex="{$myregex}">
<xsl:matching-substring>
<xsl:value-of select="regex-group(1)"/>
</xsl:matching-substring>
...
if para2 is an empty element, then the regex success and
return an empty string. How do I express in my regex that
empty is a non-matching regex ?
Thanks !
--
Mathieu
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--