Handling of duplicate type definition from included XSD [message #604518] |
Mon, 01 March 2010 20:45 |
Nikita Missing name Messages: 32 Registered: October 2009 |
Member |
|
|
I have the following parent.xsd which I load to an XSDSchema object using an XSDResourceImpl (along with a custom XSDSchemaLocator):
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.sandbox.com/test"
targetNamespace="http://www.sandbox.com/test">
<xsd:include schemaLocation="child.xsd" />
<xsd:complexType name="person-type">
<xsd:sequence>
<xsd:element name="first-name" type="xsd:string"/>
<xsd:element name="home-address" type="address-type"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="address-type">
<xsd:sequence>
<xsd:element name="city" type="xsd:string"/>
<xsd:element name="zip-code" type="xsd:integer"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
If child.xsd also defines a type called "address-type", the duplicate type is detected, and this diagnostic error is added: The type may not have duplicate name and target namespace 'http://www.sandbox.com/test#address-type' (coss-schema.2).
I have a couple questions on how this situation is handled:
1. Is it safe to assume that even though there are 2 definitions of the same type, the definition from the parent XSD will be used by other types within that XSD? In this example, person-type would point to the address-type defined in parent.xsd, not the one in child.xsd.
2. Is the diagnostics list the best way to determine the list of all duplicate types? How can I get to the actual conflicted XSDTypeDefinition objects?
Thank you!
Nikita
|
|
|
Re: Handling of duplicate type definition from included XSD [message #604521 is a reply to message #604518] |
Mon, 01 March 2010 21:02 |
Ed Merks Messages: 33264 Registered: July 2009 |
Senior Member |
|
|
Nikita,
Comments below.
Nikita wrote:
> I have the following parent.xsd which I load to an XSDSchema object
> using an XSDResourceImpl (along with a custom XSDSchemaLocator):
>
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns="http://www.sandbox.com/test"
> targetNamespace="http://www.sandbox.com/test">
>
> <xsd:include schemaLocation="child.xsd" />
>
> <xsd:complexType name="person-type">
> <xsd:sequence>
> <xsd:element name="first-name" type="xsd:string"/>
> <xsd:element name="home-address" type="address-type"/>
> </xsd:sequence>
> </xsd:complexType>
>
> <xsd:complexType name="address-type">
> <xsd:sequence>
> <xsd:element name="city" type="xsd:string"/>
> <xsd:element name="zip-code" type="xsd:integer"/>
> </xsd:sequence>
> </xsd:complexType>
> </xsd:schema>
>
> If child.xsd also defines a type called "address-type", the duplicate
> type is detected, and this diagnostic error is added: The type may
> not have duplicate name and target namespace
> 'http://www.sandbox.com/test#address-type' (coss-schema.2).
>
> I have a couple questions on how this situation is handled:
> 1. Is it safe to assume that even though there are 2 definitions of
> the same type, the definition from the parent XSD will be used by
> other types within that XSD?
No, I wouldn't assume that.
> In this example, person-type would point to the address-type defined
> in parent.xsd, not the one in child.xsd.
That might be the case, but I wouldn't count on it.
> 2. Is the diagnostics list the best way to determine the list of all
> duplicate types? How can I get to the actual conflicted
> XSDTypeDefinition objects?
The diagnostic's primary component should be the local declaration
that's causing the problem, if there is a local declaration; they might
each come from included schemas and not be a problem until combined in
the including schema.
>
> Thank you!
> Nikita
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03089 seconds