Skip to content

Improve parsing of ComplexTypeSimpleContent according to XSD rules. #38

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

Merged

Conversation

veewee
Copy link
Member

@veewee veewee commented Jul 17, 2025

Q A
Type bug
BC Break no
Fixed issues

Summary

Given a schema that is similar to this one:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
           xmlns:tns="http://foo"
           targetNamespace="http://foo"
           elementFormDefault="qualified">
    <xsd:element name="sshOptions" type="tns:SshAuthenticationSettings" />
 
    <xsd:complexType name="SshAuthenticationSettings">
        <xsd:simpleContent>
            <xsd:extension base="xsd:string"
                <xsd:attribute name="method" type="xsd:string" />
                <xsd:attribute name="contentType" type="xsd:string" use="optional" />
            </xsd:extension>
        </xsd:simpleContent>
    </xsd:complexType>

</xsd:schema>

This:

<sshOptions xmlns="http://foo" contentType="filePath" method="password" />

Results in an empty string '' instead of null.

Only when the element is nillable and contains xsi:nil="true", it will result in null.
This makes it consistent in how it is described in the XSD spec.

It behaves correctly according to tests on an XSD validator:

  • When the simpleContent extends int and no value is provided:
    • => cvc-datatype-valid.1.2.1: '' is not a valid value for 'integer'.
  • When the simpleContent extends int and xsi:nil=true is provided without nillable in xsd:
    • => Attribute 'http://www.w3.org/2001/XMLSchema-instance,nil' must not appear on element 'sshOptions', because the {nillable} property of 'sshOptions' is false.
  • When the simpleContent extends int and xsi:nil=true is provided us nillable in xsd:
    • => OK

@veewee veewee force-pushed the ComplexTypeSimpleContent-nillable-decoding-logic branch from d93e938 to 94ad884 Compare July 17, 2025 12:30
@veewee veewee merged commit 5d8e020 into php-soap:main Jul 17, 2025
14 checks passed
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.

1 participant