Project

Profile

Help

Bug #6556

closed

http://saxon.sf.net/feature/standardErrorOutputFile file is created but remains empty, errors are written to the console not the file

Added by Martin Honnen 3 months ago. Updated 29 days ago.

Status:
Resolved
Priority:
Normal
Category:
Python API
Start date:
2024-10-02
Due date:
% Done:

0%

Estimated time:
Applies to branch:
12, trunk
Fix Committed on Branch:
12, trunk
Fixed in Maintenance Release:
Found in version:
Fixed in version:
SaxonC Languages:
All
SaxonC Platforms:
All
SaxonC Architecture:

Description

When I use the SaxonC HE 12.5 Python API to set a configuration property on the Saxon processor to redirect errors to a file it appears that the file is created but remains empty while errors occur in the console (not sure whether they are going to the error or output console).

Sample Python:

from saxonche import *


xslt1 = '''
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0">

<xsl:mode on-no-match="shallow-cpy"/>

<xsl:template match="/" name="xsl:initil-template">
  <xsl:next-match/>
</xsl:template>

</xsl:stylesheet>
'''

with PySaxonProcessor() as saxon_proc:
    print(saxon_proc.version)

    saxon_proc.set_configuration_property('http://saxon.sf.net/feature/standardErrorOutputFile', 'SaxonCHE12ErrorOutputFile-Test1.txt')

    xslt_processor = saxon_proc.new_xslt30_processor()

    try:
        xslt_executable = xslt_processor.compile_stylesheet(stylesheet_text=xslt1)
    except PySaxonApiError as e:
        print(f'Caught {e}')

Sample output:

SaxonC-HE 12.5 from Saxonica
Caught XTSE0080: Namespace prefix xsl refers to a reserved namespace
XTSE0020: Attribute xsl:mode/@on-no-match must be text-only-copy|shallow-copy|deep-copy|shallow-skip|deep-skip|fail

When I write similar Java code with Saxon HE 12.5 Java the error file is populated with the errors and only my own Javacode writes to the console e.g. the program

package org.example;

import net.sf.saxon.lib.Feature;
import net.sf.saxon.s9api.*;

import javax.xml.transform.stream.StreamSource;
import java.io.StringReader;

public class Main {
    public static void main(String[] args) {

        String xslt1 = "<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" version=\"3.0\">\n" +
                "\n" +
                "<xsl:mode on-no-match=\"shallow-cpy\"/>\n" +
                "\n" +
                "<xsl:template match=\"/\" name=\"xsl:initil-template\">\n" +
                "  <xsl:next-match/>\n" +
                "</xsl:template>\n" +
                "\n" +
                "</xsl:stylesheet>";


        Processor processor = new Processor();

        processor.setConfigurationProperty(Feature.STANDARD_ERROR_OUTPUT_FILE, "SaxonHE12JavaErrorOutputTest1.text");

        XsltCompiler xsltCompiler = processor.newXsltCompiler();

        try {
            XsltExecutable executable = xsltCompiler.compile(new StreamSource(new StringReader(xslt1)));
        } catch (SaxonApiException e) {
            System.out.println("Compilation failed: " + e.getMessage());
        }
    }
}

outputs

Compilation failed: Errors were reported during stylesheet compilation

with the file containing

Error at xsl:template on line 5 column 52 
  XTSE0080  Namespace prefix xsl refers to a reserved namespace
Error in xsl:mode/@on-no-match on line 3 column 38 
  XTSE0020  Attribute xsl:mode/@on-no-match must be
  text-only-copy|shallow-copy|deep-copy|shallow-skip|deep-skip|fail``

Related issues

Related to SaxonC - Feature #6520: Possible to capture messages and errors to a file?ResolvedO'Neil Delpratt2024-08-29

Actions
Actions #1

Updated by O'Neil Delpratt about 1 month ago

  • Related to Feature #6520: Possible to capture messages and errors to a file? added
Actions #2

Updated by O'Neil Delpratt about 1 month ago

  • Status changed from New to In Progress

In SaxonC Graalvm catches the exception and we throw it in C++ therefore overriding the Java mechanism. I am currently working on a solution.

Actions #3

Updated by O'Neil Delpratt 29 days ago

  • Status changed from In Progress to Resolved
  • Applies to branch trunk added
  • Fix Committed on Branch 12, trunk added
  • SaxonC Languages All added

Bug issue fixed on both saxon12 and the development branches for C++, PHP and Python.

Fix available in the next maintenance release. The following code is accepted:

saxon_proc.set_configuration_property('http://saxon.sf.net/feature/standardErrorOutputFile', 'SaxonCHE12ErrorOutputFile-Test1.txt')

Please register to edit this issue

Also available in: Atom PDF