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

xs:Choice of xs:Sequence not supported? #168

Open
rtek opened this issue Feb 20, 2024 · 2 comments · May be fixed by #176
Open

xs:Choice of xs:Sequence not supported? #168

rtek opened this issue Feb 20, 2024 · 2 comments · May be fixed by #176

Comments

@rtek
Copy link
Contributor

rtek commented Feb 20, 2024

Attempting to parse this xsd results in a fatal. Is this an unsupported situation or a bug? Thoughts on a workaround?

https://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd

<element name="PGPData" type="ds:PGPDataType"/> 
<complexType name="PGPDataType"> 
  <choice>
    <sequence>
      <element name="PGPKeyID" type="base64Binary"/> 
      <element name="PGPKeyPacket" type="base64Binary" minOccurs="0"/> 
      <any namespace="##other" processContents="lax" minOccurs="0"
       maxOccurs="unbounded"/>
    </sequence>
    <sequence>
      <element name="PGPKeyPacket" type="base64Binary"/> 
      <any namespace="##other" processContents="lax" minOccurs="0"
       maxOccurs="unbounded"/>
    </sequence>
  </choice>
</complexType>
PHP Fatal error:  Uncaught TypeError: GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter::visitElement(): Argument #3 ($element) must be of type GoetasWebservices\XML\XSDReader\Schema\Element\ElementSingle, GoetasWebservices\XML\XSDReader\Schema\Element\Sequence given, called in ...\vendor\goetas-webservices\xsd2php\src\Php\PhpConverter.php on line 133 and defined in ...\vendor\goetas-webservices\xsd2php\src\Php\PhpConverter.php:429
@rtek rtek changed the title xsd:Choice of xsd:Sequence not supported? xs:Choice of xs:Sequence not supported? Feb 21, 2024
@nikbobbie
Copy link

I ran into the same issue with the that file after upgrading my php runtime from 7.4 to 8.2.
Before php8 it was running flawless for over a year.

I spend some time debugging and made it work by patching some functions in Php/PhpConverter. Looks like the implementation of xs:sequence is just incomplete. Someone already created a pull request with a proper implementation which you could use a base for a patch until this fix is included in a release.
bba3d45

@rtek
Copy link
Contributor Author

rtek commented Mar 27, 2024

As a workaround i just altered the XSD to drop the second sequence and remove the choice, since i didnt need it anyways - e.g.

<element name="PGPData" type="ds:PGPDataType"/> 
<complexType name="PGPDataType"> 
    <sequence>
      <element name="PGPKeyID" type="base64Binary"/> 
      <element name="PGPKeyPacket" type="base64Binary" minOccurs="0"/> 
      <any namespace="##other" processContents="lax" minOccurs="0"
       maxOccurs="unbounded"/>
    </sequence>
</complexType>

related #170

@BigBadBassMan BigBadBassMan linked a pull request Nov 15, 2024 that will close this issue
BigBadBassMan pushed a commit to BigBadBassMan/xsd2php that referenced this issue Nov 15, 2024
BigBadBassMan added a commit to BigBadBassMan/xsd2php that referenced this issue Nov 15, 2024
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 a pull request may close this issue.

2 participants