Project

Profile

Help

Bug #5850

closed

Error when compiling XSLT that uses "i" flag in regular expressions.

Added by Daniel Haley almost 2 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
High
Category:
-
Start date:
2023-01-23
Due date:
% Done:

100%

Estimated time:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Found in version:
12.0
Fixed in version:
12.1
SaxonC Languages:
SaxonC Platforms:
SaxonC Architecture:

Description

Using Saxon 12 (installed w/pypi) on Python 3.8.

I found that I get the error Unable to read casevariants.xml file when trying to compile a stylesheet that uses the "i" flag with regular expressions. (I'm using matches() in my example, but I was also able to reproduce when using xsl:analyze-string.)

It does compile if I add ";j" to the flags to force the Java flavor of regex.

Example:

Python

from saxonche import PySaxonProcessor


with PySaxonProcessor(license=False) as saxon_proc:

    xsltproc = saxon_proc.new_xslt30_processor()
    executable = xsltproc.compile_stylesheet(stylesheet_file="test_compile.xsl")

    if xsltproc.exception_occurred:
        print(f"error code: {xsltproc.error_code}\n"
              f"error msg: {xsltproc.error_message}")
        raise Exception(f"XSLT process exception(s) while compiling")

    print(executable)

XSLT

<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" expand-text="yes" 
    xmlns:p="urn:pentecom" xmlns:xs="http://www.w3.org/2001/XMLSchema"
    exclude-result-prefixes="p xs">
    <xsl:output indent="yes"/>
    <xsl:strip-space elements="*"/>
    
    <xsl:mode on-no-match="shallow-copy"/>
    
    <!--only compiles with ;j (java flavor) added to flag-->
    <xsl:template match="text()[matches(.,'f?ool','i')]"/>
    
</xsl:stylesheet>

Console Output (from PyCharm)

C:\apps\Python38\python.exe "C:\Users\Dan Haley\Desktop\try_saxon\test_saxonche_compile.py" 
Traceback (most recent call last):
  File "C:\Users\Dan Haley\Desktop\try_saxon\test_saxonche_compile.py", line 12, in <module>
    raise Exception(f"XSLT process exception(s) while compiling")
Exception: XSLT process exception(s) while compiling
error code: None
error msg: Unable to read casevariants.xml file

Process finished with exit code 1

Here's the console output after adding ";j":

C:\apps\Python38\python.exe "C:\Users\Dan Haley\Desktop\try_saxon\test_saxonche_compile.py" 
<saxonche.PyXsltExecutable object at 0x000001772B54D390>

Process finished with exit code 0

Files

test_compile.xsl (507 Bytes) test_compile.xsl Daniel Haley, 2023-01-23 19:09
test_saxonche_compile.py (474 Bytes) test_saxonche_compile.py Daniel Haley, 2023-01-23 19:09

Please register to edit this issue

Also available in: Atom PDF