I have received XSL from our government with the following content:
<xs:element minOccurs="0" maxOccurs="1"
name="VATTaxFiles">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded"
name="R" nillable="true">
<xs:complexType>
some stanza 1
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1"
name="SocialSecurityTaxFiles">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded"
name="R" nillable="true">
<xs:complexType>
some stanza 2
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1"
name="IncomeTaxFiles">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded"
name="R" nillable="true">
<xs:complexType>
some stanza 3
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
It seems to me that there are 2 bad issues with the design of this schema: 1) it uses anonymous complex types; 2) it has subelements with common name (R
) but different shape. Is this really a good or bad design for XSL?
This design create a problem when I am trying to use this schema from 3rd party tools, e.g. from Delphi XML Data binding with which I am trying to generate Delphi XML binding *.pas unit, but of course, the XML Binding wizard creates 3 interfaces IXMLR and 3 classes TXMLR, of course, such code is rejected by the compiler. I tried to provide specific 'Binding Options - Identifier Name, Data Type' for each R - e.g. R_VAT, R_Social, R_Income. And XML Binding tool generates interaces with those words inteed, but the class names are stil the same TR.
Is there way to configure XML Data binding wizard for different elements with the common name?
I don't think that anonymous complex types are intrinsically bad, but using them makes the types non-reusable, so it should only be done for a content model that definitely only applies to one element.
If the different R elements have different content models, then there's really no alternative to describing the structure in this way. It's a perfectly sound design as far as XML is concerned, but of course if your chosen data binding tool can't handle it, you'll need to find some workaround. Don't ignore the possibility of doing an XSLT transformation on the data into a different format that your data binding tool can cope with.