xsd2php
xsd2php copied to clipboard
Better Handling of xsd:choice
having this small piece of BMECat 2005.1
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://www.bmecat.org/bmecat/2005.1" xmlns="http://www.bmecat.org/bmecat/2005.1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xsd:element name="CUSTOMS_TARIFF_NUMBER">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="CUSTOMS_NUMBER"/>
<xsd:choice minOccurs="0">
<xsd:element ref="TERRITORY" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element minOccurs="0" ref="AREA_REFS"/>
</xsd:choice>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="TERRITORY" type="dtCOUNTRIES"/>
<xsd:element name="AREA_REFS">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="AREA_IDREF" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="AREA_IDREF" type="typeAREA_ID"/>
<xsd:element name="CUSTOMS_NUMBER">
<xsd:simpleType>
<xsd:restriction base="dtSTRING">
<xsd:maxLength value="60"/>
<xsd:minLength value="1"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:simpleType name="dtCOUNTRIES">
<xsd:restriction base="xsd:string">
<xsd:pattern value="(AD|AE|AF|AG|AI|AL|AM|AN|AO|AQ|AR|AS|AT|AU|AW|AZ|BA|BB|BD|BE|BF|BG|BH|BI|BJ|BM|BN|BO|BR|BS|BT|BV|BW|BY|BZ|CA|CC|CD|CF|CG|CH|CI|CK|CL|CM|CN|CO|CR|CU|CV|CX|CY|CZ|DE|DJ|DK|DM|DO|DZ|EC|EE|EG|EH|ER|ES|ET|FI|FJ|FK|FM|FO|FR|GA|GB|GD|GE|GF|GH|GI|GL|GM|GN|GP|GQ|GR|GS|GT|GU|GW|GY|HK|HM|HN|HR|HT|HU|ID|IE|IL|IN|IO|IQ|IR|IS|IT|JM|JO|JP|KE|KG|KH|KI|KM|KN|KP|KR|KW|KY|KZ|LA|LB|LC|LI|LK|LR|LS|LT|LU|LV|LY|MA|MC|MD|MG|MK|ML|MM|MN|MO|MP|MQ|MR|MS|MT|MU|MV|MW|MX|MY|MZ|NA|NC|NE|NF|NG|NI|NL|NO|NP|NR|NU|NZ|OM|PA|PE|PF|PG|PH|PK|PL|PM|PN|PR|PS|PT|PW|PY|QA|RE|RO|RU|RW|SA|SB|SC|SD|SE|SG|SH|SI|SJ|SK|SL|SM|SN|SO|SR|ST|SV|SY|SZ|TC|TD|TF|TG|TH|TJ|TK|TM|TN|TO|TP|TR|TT|TV|TW|TZ|UA|UG|US|UY|UZ|VA|VC|VE|VG|VI|VN|VU|WF|WS|YE|YT|YU|ZA|ZM|ZW){1,1}(-[A-Z|0-9]{1,3}){0,1}"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="typeAREA_ID">
<xsd:restriction base="dtSTRING">
<xsd:minLength value="1"/>
<xsd:maxLength value="60"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="dtSTRING">
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
</xsd:schema>
my request is about this part:
<xsd:choice minOccurs="0">
<xsd:element ref="TERRITORY" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element minOccurs="0" ref="AREA_REFS"/>
</xsd:choice>
the xsd says that these two element parts should be choices, but neither the generated PHP nor the yml Serializer Metadata does seem to respect that. shouldn't there be a pre serializer Hook or something that does handle such choices?
Also the Full BMECat causes a infinite Loop error in Doctine Inflector:
PHP Fatal error: Uncaught Error: Xdebug has detected a possible infinite loop, and aborted your script with a stack depth of '15024' frames in /var/www/xsd2php/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Pattern.php:17
Stack trace:
#0 /var/www/xsd2php/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/English/Inflectible.php(19): Doctrine\Inflector\Rules\Pattern->__construct('(s)tatuses$')
#1 /var/www/xsd2php/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/English/Rules.php(17): Doctrine\Inflector\Rules\English\Inflectible::getSingular()
#2 /var/www/xsd2php/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/English/InflectorFactory.php(14): Doctrine\Inflector\Rules\English\Rules::getSingularRuleset()
#3 /var/www/xsd2php/vendor/doctrine/inflector/lib/Doctrine/Inflector/GenericLanguageInflectorFactory.php(21): Doctrine\Inflector\Rules\English\InflectorFactory->getSingularRuleset()
#4 /var/www/xsd2php/vendor/doctrine/inflector/lib/Doctrine/Inflector/InflectorFactory.php(28): Doctrine\Inflector\GenericLa in /var/www/xsd2php/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Pattern.php on line 17