Project

Profile

Help

Bug #6475

closed

saxoncee.PySaxonApiError: Source document not found. Line number: -1

Added by O'Neil Delpratt 7 days ago. Updated 7 days ago.

Status:
Resolved
Priority:
Normal
Category:
C++ API
Start date:
2024-07-09
Due date:
% Done:

0%

Estimated time:
Applies to branch:
Fix Committed on Branch:
12
Fixed in Maintenance Release:
Found in version:
12.5
Fixed in version:
SaxonC Languages:
C++, PHP, Python
SaxonC Platforms:
All
SaxonC Architecture:

Description

The Python PySchemaValidator is failing to validate an XML document if supplied as an XdmNode.

For example the following script:

    invalid_xml = "<?xml version='1.0'?><request><a/><!--comment--></request>"
    sch1 = "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' elementFormDefault='qualified' attributeFormDefault='unqualified'><xs:element name='request'><xs:complexType><xs:sequence><xs:element name='a' type='xs:string'/><xs:element name='b' type='xs:string'/></xs:sequence><xs:assert test='count(child::node()) = 3'/></xs:complexType></xs:element></xs:schema>"
    input_ = saxonproc2.parse_xml(xml_text=invalid_xml)
    print(type(input_))
    val.set_source_node(input_)
    val.register_schema(xsd_text=sch1)
    val.validate()

Throws the exception:

saxoncee.PySaxonApiError: Source document not found. Line number: -1

The workaround is supply the XML document as a file using the file_name keyword argument.

This worked in SaxonC 12.4.2.


Related issues

Copied from SaxonC - Bug #6469: SXXP0003 when parsing XHTML file with saxoncee 12.5.0ResolvedMatt Patterson2024-07-04

Actions
Actions #1

Updated by O'Neil Delpratt 7 days ago

  • Copied from Bug #6469: SXXP0003 when parsing XHTML file with saxoncee 12.5.0 added
Actions #2

Updated by O'Neil Delpratt 7 days ago

  • Category set to C++ API
  • Status changed from New to Resolved
  • Assignee set to O'Neil Delpratt
  • Priority changed from Low to Normal
  • SaxonC Languages C++, PHP added

This is a bug in the C++ code. Bug fix applied in the setSourceNode method of SchemaValidator.cpp.

Fix available in the next maintenance release.

Please register to edit this issue

Also available in: Atom PDF