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

Can't import single file into different namespaces #115

Open
tomasz-kusy opened this issue Jun 8, 2020 · 3 comments
Open

Can't import single file into different namespaces #115

tomasz-kusy opened this issue Jun 8, 2020 · 3 comments

Comments

@tomasz-kusy
Copy link

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.

@goetas
Copy link
Member

goetas commented Jun 10, 2020

Hi, thanks for starting this conversation.

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

@tomasz-kusy
Copy link
Author

tomasz-kusy commented Jun 10, 2020

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) ?

@goetas
Copy link
Member

goetas commented Jun 13, 2020

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.

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

No branches or pull requests

2 participants