Mappings cannot be generated when using substitutionGroup
See original GitHub issueWhat I’m about to report may be
- a bug
- or a know limitation
- or I may just be using the tool incorrectly
Problem
With a schema such as this one which attempts to use substitutionGroup
:
<schema
targetNamespace="http://mws.amazonservices.com/schema/Products/2011-10-01/default.xsd"
elementFormDefault="qualified"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:product="http://mws.amazonservices.com/schema/Products/2011-10-01"
xmlns:tns="http://mws.amazonservices.com/schema/Products/2011-10-01/default.xsd">
<import schemaLocation="ProductsAPI_Response.xsd"
namespace="http://mws.amazonservices.com/schema/Products/2011-10-01" />
<element name="ItemAttributes"
type="tns:ItemAttributesType"
substitutionGroup="product:AttributeSet" /> <!-- PROBLEM AT THIS LINE -->
I run into an error stating:
[ERROR] src-resolve: Cannot resolve the name 'product:AttributeSet' to a(n) 'element declaration' component.
Would I be correct in stating that this is a limitation of jsonix-schema-compiler
?
Trial & Error
In the example earlier, Jsonix processing fails when the schema file for namespaceA fails to use substitutionGroup to refer to something in namespaceB. So I manipulated the schema to be one namespace and then the command to generate mappings started to work … perhaps that is a hint to help debug this?
<schema
targetNamespace="http://mws.amazonservices.com/schema/Products/2011-10-01"
elementFormDefault="qualified"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:product="http://mws.amazonservices.com/schema/Products/2011-10-01"
xmlns:tns="http://mws.amazonservices.com/schema/Products/2011-10-01">
<import schemaLocation="ProductsAPI_Response.xsd"
namespace="http://mws.amazonservices.com/schema/Products/2011-10-01" />
<element name="ItemAttributes"
type="tns:ItemAttributesType"
substitutionGroup="product:AttributeSet" />
The xml traffic I want to parse clearly marks its elements as namespaceA and napespaceB so I can’t parse real traffic with this workaround.
This was just an experiment to get some insight into: Does substitutionGroup work at all when used with jsonix-schema-compiler? And right now I think the answer is that substitutionGroup works within the same namespace but not across.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Since you’ve solved the issue, PR is not necessary anymore.
Substitution groups work fine. See this project, these are pretty complex schemas, use most of the XML Schema featureset including substitution groups.
The problem in your case is probably, well, that
AttributeSet
could not be found in the right namespace. I can’t say why is this without seeing the schemas. I’d normally do a full text search looking for the declaration of theAttributeSet
element, check the namespace, check theItemAttributesType
extends the type of theAttributeSet
.For more support PR your (simplified) test project under https://github.com/highsource/jsonix-support/tree/master/s/someproject (choose your own name for
s/someproject
).