Skip to content
This repository was archived by the owner on Apr 29, 2023. It is now read-only.

Multiple accepting paths for xs:any ##other element #128

@CausticYarn

Description

@CausticYarn

I am using bindings generated by PyXB 1.2.6.

I have a schema which is (essentially):

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns1="foo_namespace" targetNamespace="foo_namespace" elementFormDefault="qualified" attributeFormDefault="unqualified">
  <xs:element name="FooList">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="Foo" type="xs:string" minOccurs="0"/>
        <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

Paired with another schema:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="bar_namespace" elementFormDefault="qualified" attributeFormDefault="unqualified">
  <xs:element name="Bar" type="xs:string" minOccurs="0"/>
</xs:schema>

Parsing this XML sample:

<?xml version="1.0"?>
<foo:FooList xmlns:foo="foo_namespace" xmlns:bar="bar_namespace" xmlns:qux="qux_namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="foo_namespace file:///C:/code/temp/schema_tests/wildcard/wildcard_schema.xsd">
  <foo:Foo>Foo A</foo:Foo>
  <bar:Bar>Bar A</bar:Bar>	
  <qux:Qux>Qux A</qux:Qux>
</foo:FooList>

I can parse the sample with the bindings for the foo_namespace schema whether or not element Foo is present, and all non-Foo elements are placed into the wildcard elements (as expected).

When I include a binding for the bar_namespace schema, the XML sample is parsed correctly when the Foo element is present. However, if the Foo element is missing, I get the warning:

Multiple accepting paths for <class 'foo.CTD_ANON'>

It seems that the "Bar A" text gets parsed into the Foo element, and writing the XML back out results in:

<?xml version="1.0" ?>
<ns1:FooList xmlns:ns2="qux_namespace" xmlns:ns1="foo_namespace">
	<ns1:Foo>Bar A</ns1:Foo>
	<ns2:Qux>Qux A</ns2:Qux>
</ns1:FooList>

Is this schema truly ambiguous or is this a PyXB issue? I would think that the ##other attribute of the any element means that the {bar_namespace}Bar element is unambiguous, but it's possible I'm missing something. It's also not clear to me how the Bar element gets parsed into the Foo element.

Attached is code and samples reproducing the issue.
wildcard_tests.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions