goetas / xsd2php

Convert XSD into PHP classes and serialize into XML (deserialize too)
149 stars 62 forks source link

XML element namespace in YAML files for referenced elemend in imported schemas is wrong #111

Closed jormeijer closed 8 years ago

jormeijer commented 8 years ago

An element that is referenced to an element in another schema will always get the XML namespace that is defined in the targetNamespace of the 'parent' schema.

For example:

<xs:schema targetNamespace="http://www.example.com" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ex="http://www.example2.com">

    <xs:import namespace="http://www.example2.com" schemaLocation="data2.xsd"/>

    <xs:complexType name="complexType1">
        <xs:sequence>
            <xs:element ref="ex:element1"/>
        </xs:sequence>
    </xs:complexType>

</xs:schema>

Will get converted to:

properties:
        element1:
            ...
            xml_element:
                namespace: 'http://www.example.com'
            ...

Instead of namespace: 'http://www.example2.com' which is the namespace where the referenced element is in.

goetas commented 8 years ago

fixed in https://github.com/goetas/xsd2php/pull/112