Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inherit default qualification from schema when not specified #84

Merged
merged 2 commits into from
Jun 7, 2024

Conversation

veewee
Copy link
Contributor

@veewee veewee commented Jun 5, 2024

Both attributes and elements have a default qualification of false.
The reader does not take into account the schema configurations attributeFormDefault and elementFormDefault.

This PR introduces a fallback to the schema settings if the form attribute does not exist.

<xs:schema version="1.0" targetNamespace="http://www.example.com"
    xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
    <xs:complexType name="root">
        <xs:sequence>
            <xs:element name="item1" type="xs:string" form="qualified" />
            <xs:element name="item2" type="xs:string" form="unqualified" />
            <xs:element name="item3" type="xs:string" />
        </xs:sequence>
    </xs:complexType>
</xs:schema>
<xs:schema version="1.0" targetNamespace="http://www.example.com"
    xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified">
    <xs:complexType name="root">
        <xs:attribute name="item1" type="xs:int" form="qualified"/>
        <xs:attribute name="item2" type="xs:int" form="unqualified"/>
        <xs:attribute name="item3" type="xs:int"/>
    </xs:complexType>
</xs:schema>

@veewee veewee changed the title Inherit default qualification from schema when not set Inherit default qualification from schema when not specified Jun 5, 2024
@goetas
Copy link
Member

goetas commented Jun 6, 2024

Is this a standard thing? is it mentioned in any doc?

@veewee
Copy link
Contributor Author

veewee commented Jun 7, 2024

Yes it is.

The form on element / attribute can have 3 states:

  • qualified : display with namespace prefix
  • unqualified : display as local name
  • not set : This now falls back to false in this package, however it should fall back to the defaults configured at schema level. (elementFormDefault or attributeFormDefault - in case these are not set, it should default to false)

See the offical spec:

https://www.w3.org/TR/xmlschema11-1/

<schema
  attributeFormDefault = (qualified | unqualified) : unqualified
  elementFormDefault = (qualified | unqualified) : unqualified

https://www.w3.org/TR/xmlschema11-1/#dcl.elt.local

2 If targetNamespace is not present and one of the following is true
2.1 form = qualified
2.2 form is absent and the ancestor has elementFormDefault = qualified
then the ·actual value· of the targetNamespace [attribute] of the ancestor element information item, or ·absent· if there is none.

https://www.w3.org/TR/xmlschema11-1/#dcl.att.local

2 If targetNamespace is not present and one of the following is true
2.1 form = qualified
2.2 form is absent and the ancestor has attributeFormDefault = qualified

Here are some concrete implementation test-cases from how it's implemented inside php-src's ext-soap:

Attributes:

Elements:

@goetas goetas merged commit 51558f6 into goetas-webservices:master Jun 7, 2024
@goetas
Copy link
Member

goetas commented Jun 7, 2024

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants