Project

Profile

Help

Bug #2487

closed

Incorrect value returned by match-substring/regex-group()

Added by Tomos Hillman about 9 years ago. Updated almost 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
XPath conformance
Sprint/Milestone:
Start date:
2015-10-26
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.6
Fix Committed on Branch:
9.6
Fixed in Maintenance Release:
Platforms:

Description

I'm debugging someone else's code that previously worked correctly. The problem is illustrated in the following XSLT:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
  exclude-result-prefixes="xs xd"
  version="2.0">
  
  <xsl:output method="text"/>
  
  <xsl:template match="/">
    <xsl:analyze-string select="'1949'" regex="([0-9]{{1,2}})?\s?([A-Z]{{1}}[a-z]{{1,8}}\.?)?\s?([0-9]{{4}})">
      <xsl:matching-substring>
        <xsl:text>regex-group(1)=</xsl:text><xsl:value-of select="regex-group(1)"/><xsl:text>&#xd;</xsl:text>
        <xsl:text>regex-group(2)=</xsl:text><xsl:value-of select="regex-group(2)"/><xsl:text>&#xd;</xsl:text>
        <xsl:text>regex-group(3)=</xsl:text><xsl:value-of select="regex-group(3)"/><xsl:text>&#xd;</xsl:text>
      </xsl:matching-substring>
    </xsl:analyze-string>
  </xsl:template>
  
</xsl:stylesheet>

Where I would expect regex-group(1) to be empty, but instead it is getting the value '1'. This is in both saxon 9.6.0.5 and 9.6.0.7 (versions bundled with oXygen)

See also http://stackoverflow.com/questions/33342200/why-does-this-return-a-value-for-regex-group1

Please register to edit this issue

Also available in: Atom PDF