XSD to Java code generation with multiple import of the same namespace [message #425606] |
Wed, 03 December 2008 07:01  |
Eclipse User |
|
|
|
I'd encountered a problem with generating Java code by EMF XSD generation
functionality within Eclipse 3.2.2. Within the *.xsd file a multiple
import of the same namespace was used, see egzample:
<!-- Imports -->
<xsd:import schemaLocation="Part1.xsd"
namespace="http://TestLibB"></xsd:import>
<xsd:import schemaLocation="Part2.xsd"
namespace="http://TestLibB"></xsd:import>
I'd like to ask if the XSD to Java code generation functionality in
Eclipse 3.4 respecting multiple import of the same namespace in a XSD file
and generates valid Java code?
The W3C Specification says it is up to a XML Schema application
(EMF XSD to Java transformation) to ignore multiple
imports of the same namespace or not.
-----
http://www.w3.org/TR/xmlschema-1
4.2.3 References to schema components across namespaces
.....
Note: ... Given that the schemaLocation attribute is only a hint,
it is open to applications to ignore all but the first <import> for
a given namespace, regardless of the actual value of schemaLocation,
but such a strategy risks missing useful information when new
schemaLocations are offered.
-----
Regards,
Blazej
|
|
|
|
|
|
|
|
|
Re: XSD to Java code generation with multiple import of the same namespace [message #425730 is a reply to message #425725] |
Fri, 05 December 2008 11:04  |
Eclipse User |
|
|
|
Błażej,
It's always worked.
Błażej Kroll wrote:
> Hello,
>
> Thank you for the answer Ed.
>
> Just to close the subject. Can I expect the multiple import to work in
> EMF 2.2 or 2.3? Or is it a new introduced thing?
>
> Regards,
> Blazej
>
>
> Ed Merks pisze:
>> Blazej,
>>
>> Comments below.
>>
>>
>> Blazej Kroll wrote:
>>> Hello, to clarify the issue I'm facing:
>>>
>>> I want to generate Java from XML Schema.
>>> I am facing a validation error from Xerces when using multiple
>>> imports in an xml schema file like:
>>> <xsd:import schemaLocation="Part1.xsd"
>>> namespace="http://TestLibB"></xsd:import>
>>> <xsd:import schemaLocation="Part2.xsd"
>>> namespace="http://TestLibB"></xsd:import>
>> It seems to me they ought to support that.
>>>
>>> After looking for a workaround I tried to make it another way (not
>>> to see the validator's error)
>>> and make a fsingle file which includes the necessary Part1.xsd and
>>> Part2.xsd files and then import that file in the main Schema from
>>> which I will generate the Java code.
>>>
>>> Some file which gatheres all the necessery ones called
>>> Intermediate.xsd which includes:
>>> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>>> targetNamespace="http://TestLib/B">
>>> <xsd:include schemaLocation="Part1.xsd"></xsd:include>
>>> <xsd:include schemaLocation="Part2.xsd"></xsd:include>
>>> </xsd:schema>
>>>
>>> and then in the main file to generate Java code I use single import
>>> operation:
>>> <xsd:import namespace="http://TestLib/B"
>>> schemaLocation="Intermediate.xsd"></xsd:import>
>>>
>>> So the validator is giving no errors.
>> Yes, that should work.
>>> Just to summer things up I want to make sure that from the EMF side
>>> both these scenarioes (multiple import usage) generate a valid Java
>>> code despite the validator's error in the first case.
>> Yes, EMF should treat them as entirely equivalent and should generate
>> the same code for each.
>>>
>>> Regards,
>>> Blazej
>>>
|
|
|
Powered by
FUDForum. Page generated in 0.08898 seconds