xsd2php icon indicating copy to clipboard operation
xsd2php copied to clipboard

Can't import single file into different namespaces

Open tomasz-kusy opened this issue 5 years ago • 3 comments

If same file is imported to different namespaces schema is imported only once. Example:

<xs:import namespace="urn:my:space"  schemaLocation="coreschemas/datatypes.xsd"/>
<xs:import namespace="urn:my:other"  schemaLocation="coreschemas/datatypes.xsd"/>

Possible solution (?): In SchemaReader.php add namespace, like:

if (isset($this->loadedFiles[$schema->getTargetNamespace() . $file])) {
            $schema->addSchema($this->loadedFiles[$schema->getTargetNamespace() . $file]);

Same in setter.

tomasz-kusy avatar Jun 08 '20 16:06 tomasz-kusy

Hi, thanks for starting this conversation.

Can you please create a pull request with the suggested solution?

goetas avatar Jun 10 '20 08:06 goetas

Sure. I figured it's an xsd-reader package thing (sorry for mess). I did changes, but unfortunately it doesn't pass your tests. Probably my knowledge of XML is not enough, but explain to me if you can this test: <xs:import schemaLocation="http://www.example.com/xsd.xsd" namespace="http://www.example.com"></xs:import> How reader in this test can read schema from given location (http://www.example.com/xsd.xsd) ?

tomasz-kusy avatar Jun 10 '20 17:06 tomasz-kusy

How reader in this test can read schema from given location (http://www.example.com/xsd.xsd) ?

https://github.com/goetas-webservices/xsd-reader/blob/e61848111e396e2d0e90664cdea179fdea4c1f45/tests/ImportTest.php#L15

this line is putting in cache a xsd for that url, thus later no http request is needed.

xsd-reader has a sort of aliasing that allows you to declare some schemas locally instead of reading them each time from the network.

goetas avatar Jun 13 '20 09:06 goetas