Altova Mailing List Archives

Re: [xsl] Empty input in analyze-string

From: "Joe Fawcett" <joefawcett@----------->
Date: 7/4/2008 1:31:00 PM
Seems to me that the empty string doesn't match or mismatch:


<xsl:stylesheet version="2.0" 

 <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>


     <xsl:for-each select="data/para">

       <input><xsl:value-of select="."/></input>

       <xsl:analyze-string select="." regex="{$myregex}">



             <xsl:value-of select="."/>





             <xsl:value-of select="."/>








I get (with Saxon 9.1):


From: "Michael Kay" <mike@xxxxxxxxxxxx>
Sent: Friday, July 04, 2008 2:18 PM
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
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

-----Original Message-----
From: Mathieu Malaterre [mailto:mathieu.malaterre@xxxxxxxxx]
Sent: 04 July 2008 13:44
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] Empty input in analyze-string


  I cannot figure out how to tell xsl:analyze-string that
empty input should not match regex.


    <xsl:analyze-string select="$para2" regex="{$myregex}">
        <xsl:value-of select="regex-group(1)"/>

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 !


These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.