Forums » Saxon/C Help and Discussions »
I/O error reported by XML parser for the named output_file of apply_templates_returning_file
Added by Martin Honnen about 5 years ago
I have run into another problem using apply_templates_returning_file
, using set_cwd(os.getcwd())
I thought it would work but once I started using paths to subdirectories the new problem occurs: I get an "I/O error reported by XML parser processing" claiming it can't find the file named as the output_file.
Sample Python code is:
import os
import saxonc
def XSLT_Simple2(proc):
xslt30_processor = proc.new_xslt30_processor()
output_file_name = "output-from-XSLT_Simple2.xml"
xslt30_processor.set_cwd(os.getcwd())
xslt30_processor.apply_templates_returning_file(source_file="data/sample-input1.xml", stylesheet_file="styles/identity.xsl", output_file=output_file_name)
with saxonc.PySaxonProcessor() as proc:
print(proc.version)
XSLT_Simple2(proc)
On running (in C:\SomeDir\SomeFolder
), this outputs
Saxon/C 1.2.1 running with Saxon-HE 9.9.1.5C from Saxonica
Error
I/O error reported by XML parser processing C:\SomeDir\SomeFolder\output-from-XSLT_Simple2.xml: Das System kann die angegebene Datei nicht finden
so for some reason I don't understand Saxon attempts to feed the file output-from-XSLT_Simple2.xml
to the XML parser which obviously then fails as the code is supposed to create that file.
If I have the input and XSLT file in the working directory and change the line to call apply_templates_returning_file
to
xslt30_processor.apply_templates_returning_file(source_file="sample-input1.xml", stylesheet_file="identity.xsl", output_file=output_file_name)
the code works as intended.
Replies (9)
Please register to reply
RE: I/O error reported by XML parser for the named output_file of apply_templates_returning_file - Added by O'Neil Delpratt about 5 years ago
thanks for reporting this issue. Investigating it now.
RE: I/O error reported by XML parser for the named output_file of apply_templates_returning_file - Added by Martin Honnen about 5 years ago
If I first create a file of that name (outside of the Python code) the error then says
Static error at root on line 1 column 45 of output-from-XSLT_Simple2.xml:
XTSE0150: The supplied file does not appear to be a stylesheet
so it seems the file read attempt is done to read it as XSLT code.
RE: I/O error reported by XML parser for the named output_file of apply_templates_returning_file - Added by O'Neil Delpratt about 5 years ago
Update:
I ran a similar python script on a linux machine and it ran successfully. Therefore I think it is failing to resolve the files due to some difference on the linux/windows machine.
I will next investigate this python script on a windows machine.
RE: I/O error reported by XML parser for the named output_file of apply_templates_returning_file - Added by Martin Honnen about 5 years ago
Any update on this? I managed to install an Ubuntu version as a Windows 10 Linux Subsystem and then run saxonc with Python 3 there, using the same files, and indeed it works with LINUX. But I am lost what could be the reason for the strange behaviour on Windows and how to fix it.
RE: I/O error reported by XML parser for the named output_file of apply_templates_returning_file - Added by O'Neil Delpratt about 5 years ago
Sorry no progress as yet, I have let this one slip. I have created a bug issue to keep track of its progress: #4388
RE: I/O error reported by XML parser for the named output_file of apply_templates_returning_file - Added by O'Neil Delpratt almost 3 years ago
Has this problem gone away in SaxonC 11?
RE: I/O error reported by XML parser for the named output_file of apply_templates_returning_file - Added by Martin Honnen almost 3 years ago
I am not on a machine to test that, will try later during the weekend.
RE: I/O error reported by XML parser for the named output_file of apply_templates_returning_file - Added by Martin Honnen almost 3 years ago
The original code does not run with SaxonC 11 as the XSLT 3 processor no longer has the method apply_templates_returning_file
so I tried to rewrite it as
import os
import saxonc
def XSLT_Simple2(proc):
xslt30_processor = proc.new_xslt30_processor()
output_file_name = "output-from-XSLT_Simple2.xml"
xslt30_processor.set_cwd(os.getcwd())
xslt30_transformer = xslt30_processor.compile_stylesheet(stylesheet_file="styles/identity.xsl")
xslt30_transformer.apply_templates_returning_file(source_file="data/sample-input1.xml", output_file=output_file_name)
with saxonc.PySaxonProcessor() as proc:
print(proc.version)
XSLT_Simple2(proc)
I have tested that it runs fine on one Windows 11 machine with SaxonC-HE 11.2.
RE: I/O error reported by XML parser for the named output_file of apply_templates_returning_file - Added by O'Neil Delpratt almost 3 years ago
Great. Thanks for letting me know
Please register to reply