Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » XSD -> ECORE conversion : problem with XSD inclusion
XSD -> ECORE conversion : problem with XSD inclusion [message #66406] Thu, 04 January 2007 10:49 Go to next message
Eclipse UserFriend
Originally posted by: turmeau.laurent.fmtls.siemensvdo.com

Hello,

I'm creating an EMF project, and the ECORE model is imported from a XML
schema.
This XML schema includes another one like this:

test.xsd

<xs:schema xmlnss="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:include schemaLocation="template_declaration.xsd"/>
<xs:element name="TOTO">
<xs:complexType>
<xs:sequence>
<xs:element ref="TITI_1" minOccurs="0"/>
<xs:element ref="TITI_2" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="Name" use="required">
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>

The ECORE model is generated successfully, but the Root package is
templateDeclaration whereas TOTO is expected.

I tried to avoid this, using ecore directives in the XSD to force the
generated package name. it gives something like this:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
ecore:package="TOTO"
ecore:nsPrefix="TOTO">
<xs:include schemaLocation="template_declaration.xsd"/>
...

Now, a TOTOPackage interface is generated, that defines:

String eNAME = "TOTO";
String eNS_URI =
" file:/C:/DATA/WICO_TLS/CongaConfig/xsd/template_declaration. xsd ";
String eNS_PREFIX = "TOTO";

The URI is not correct: test.xsd is expected. Indeed, when I try to load a
XML resource, EMF tries to map the XML against the
template_declaration.xsd. And it fails.

Has anybody encountered this problem?
regards

Laurent
Re: XSD -> ECORE conversion : problem with XSD inclusion [message #68159 is a reply to message #66406] Tue, 16 January 2007 12:29 Go to previous message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Laurent,

I think you asked this same question on the EMF newsgroup... The
XSDEcoreBuilder processes all the elements and types of a schema in
arbitrary order and hence the first element or type processed for the
null namespace will determine which physical schema location is used as
the nsURI. It's probably best to define your schemas to have a
targetNamespace...


Laurent TURMEAU wrote:
> Hello,
>
> I'm creating an EMF project, and the ECORE model is imported from a
> XML schema.
> This XML schema includes another one like this:
>
> test.xsd
>
> <xs:schema xmlnss="http://www.w3.org/2001/XMLSchema"
> elementFormDefault="qualified" attributeFormDefault="unqualified">
> <xs:include schemaLocation="template_declaration.xsd"/>
> <xs:element name="TOTO">
> <xs:complexType>
> <xs:sequence>
> <xs:element ref="TITI_1" minOccurs="0"/>
> <xs:element ref="TITI_2" minOccurs="0"/>
> </xs:sequence>
> <xs:attribute name="Name" use="required">
> </xs:attribute>
> </xs:complexType>
> </xs:element>
> </xs:schema>
>
> The ECORE model is generated successfully, but the Root package is
> templateDeclaration whereas TOTO is expected.
>
> I tried to avoid this, using ecore directives in the XSD to force the
> generated package name. it gives something like this:
>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> elementFormDefault="qualified" attributeFormDefault="unqualified"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
> ecore:package="TOTO"
> ecore:nsPrefix="TOTO">
> <xs:include schemaLocation="template_declaration.xsd"/>
> ..
>
> Now, a TOTOPackage interface is generated, that defines:
>
> String eNAME = "TOTO";
> String eNS_URI =
> " file:/C:/DATA/WICO_TLS/CongaConfig/xsd/template_declaration. xsd ";
> String eNS_PREFIX = "TOTO";
>
> The URI is not correct: test.xsd is expected. Indeed, when I try to
> load a XML resource, EMF tries to map the XML against the
> template_declaration.xsd. And it fails.
>
> Has anybody encountered this problem?
> regards
>
> Laurent
>
>
>
Re: XSD -> ECORE conversion : problem with XSD inclusion [message #601262 is a reply to message #66406] Tue, 16 January 2007 12:29 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 31770
Registered: July 2009
Senior Member
Laurent,

I think you asked this same question on the EMF newsgroup... The
XSDEcoreBuilder processes all the elements and types of a schema in
arbitrary order and hence the first element or type processed for the
null namespace will determine which physical schema location is used as
the nsURI. It's probably best to define your schemas to have a
targetNamespace...


Laurent TURMEAU wrote:
> Hello,
>
> I'm creating an EMF project, and the ECORE model is imported from a
> XML schema.
> This XML schema includes another one like this:
>
> test.xsd
>
> <xs:schema xmlnss="http://www.w3.org/2001/XMLSchema"
> elementFormDefault="qualified" attributeFormDefault="unqualified">
> <xs:include schemaLocation="template_declaration.xsd"/>
> <xs:element name="TOTO">
> <xs:complexType>
> <xs:sequence>
> <xs:element ref="TITI_1" minOccurs="0"/>
> <xs:element ref="TITI_2" minOccurs="0"/>
> </xs:sequence>
> <xs:attribute name="Name" use="required">
> </xs:attribute>
> </xs:complexType>
> </xs:element>
> </xs:schema>
>
> The ECORE model is generated successfully, but the Root package is
> templateDeclaration whereas TOTO is expected.
>
> I tried to avoid this, using ecore directives in the XSD to force the
> generated package name. it gives something like this:
>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> elementFormDefault="qualified" attributeFormDefault="unqualified"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
> ecore:package="TOTO"
> ecore:nsPrefix="TOTO">
> <xs:include schemaLocation="template_declaration.xsd"/>
> ..
>
> Now, a TOTOPackage interface is generated, that defines:
>
> String eNAME = "TOTO";
> String eNS_URI =
> " file:/C:/DATA/WICO_TLS/CongaConfig/xsd/template_declaration. xsd ";
> String eNS_PREFIX = "TOTO";
>
> The URI is not correct: test.xsd is expected. Indeed, when I try to
> load a XML resource, EMF tries to map the XML against the
> template_declaration.xsd. And it fails.
>
> Has anybody encountered this problem?
> regards
>
> Laurent
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Re: Can EMF Technology "Transaction" Execute Stand-Alone?
Next Topic:How can i set xmi:id in emf?
Goto Forum:
  


Current Time: Thu Feb 25 22:58:14 GMT 2021

Powered by FUDForum. Page generated in 0.02332 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top