Project

Profile

Help

Bug #6381

closed

set_unprefixed_element_matching_policy(1) doesn't seem to work

Added by Martin Honnen 4 months ago. Updated 14 days ago.

Status:
Closed
Priority:
Normal
Category:
Internals
Sprint/Milestone:
-
Start date:
2024-03-31
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
12, trunk
Fix Committed on Branch:
12, trunk
Fixed in Maintenance Release:
Platforms:
.NET, Java

Description

I wrote the following Python code making use of set_unprefixed_element_matching_policy(1) on an PyXPathProcessor:

from saxonche import PySaxonProcessor

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

    xpath_processor = saxon_proc.new_xpath_processor()

    xpath_processor.set_unprefixed_element_matching_policy(1)

    xpath_processor.set_context(file_name='sample1.xml')

    print(xpath_processor.evaluate('/root/foo'))

    xpath_processor.set_context(file_name='sample2.xml')

    print(xpath_processor.evaluate('/root/foo'))

Output:

SaxonC-HE 12.4.2 from Saxonica
None
None

Sample XML files are attached.

A similar Java program (also attached) outputs:

12.4                                                                
<foo xmlns="http://example.com/ns-2023">bar</foo>

<foo xmlns="http://example.com/ns-2023">baz</foo>
<foo xmlns="http://example.com/ns-2024">bar</foo>

<foo xmlns="http://example.com/ns-2024">baz</foo>

I would have expected the Python program to select and output the same nodes as the Java program, instead, despite the policy set, no nodes seem to be selected.


Files

main.py (457 Bytes) main.py Martin Honnen, 2024-03-31 14:45
JavaDefaultNamespaceTest1.java (823 Bytes) JavaDefaultNamespaceTest1.java Martin Honnen, 2024-03-31 14:45
sample1.xml (90 Bytes) sample1.xml Martin Honnen, 2024-03-31 14:45
sample2.xml (90 Bytes) sample2.xml Martin Honnen, 2024-03-31 14:45

Please register to edit this issue

Also available in: Atom PDF