xsd2php
xsd2php copied to clipboard
Multiple namespaced refs not included in yml file. Only last one
In the following example only one (the last one in the choice list) ref with property name 'Declaration' is included in BB.yml
input (data is modified/simplified to clearify problem) :
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="urn:tst"
xmlns:ABC_01="BB:ABC:01"
xmlns:DEF_01="BB:DEF:01"
xmlns:GHI_01="BB:GHI:01"
xmlns:AA_01="SW:AA:01"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:tst"
elementFormDefault="qualified">
<xs:import namespace="BB:ABC:01" schemaLocation="BB_ABC_01.xsd"/>
<xs:import namespace="BB:DEF:01" schemaLocation="BB_DEF_01.xsd"/>
<xs:import namespace="BB:GHI:01" schemaLocation="BB_GHI_01.xsd"/>
<xs:import namespace="SW:AA:01" schemaLocation="SW_AA_01.xsd"/>
<xs:element name="BB">
<xs:annotation>
<xs:documentation>
<SW_MessageVersionNumber>00001</SW_MessageVersionNumber>
<SW_MessageVersionDate>1 April 2017</SW_MessageVersionDate>
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element ref="AA_01:MetaData"/>
<xs:element ref="GHI_01:Declaration"/>
<xs:choice>
<xs:element ref="ABC_01:Declaration" minOccurs="0"/>
<xs:element ref="DEF_01:Declaration" minOccurs="0"/>
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
output:
properties:
metaData:
expose: true
access_type: public_method
serialized_name: MetaData
xml_element:
namespace: 'SW:AA:01'
accessor:
getter: getMetaData
setter: setMetaData
type: Test\Test\MetaData
declaration:
expose: true
access_type: public_method
serialized_name: Declaration
xml_element:
namespace: 'BB:DEF:01'
accessor:
getter: getDeclaration
setter: setDeclaration
type: Test\Test\Declaration
Any idea how to solve/fix this?
Thanks!
if the name of the element is always declaration
, there is no (easy) way to solve it because with PHP you can not have two properties having the same name
Yes, name is always Declaration
but in it's own namespace.
And the not so easy way would probably involve using the namespace when creating the properties for the PHP classes? (type hinting class properties would be nice here..)
For now i'll go for the poor man's solution and do a rename of the Declaration namespaces, make them unique and do a search/replace on the XML end result.
Thanks and keep up the good work!
And the not so easy way would probably involve using the namespace when creating the properties for the PHP classes? (type hinting class properties would be nice here..)
The not easy part is "de-serializing" an xml where the node just says Declaration
as name.
To understand which PHP class should be instantiated would be necessary to "guess it somehow" (most probably based on the content of the node... but that is not easy at all)