Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » How to annotate genmodel with a relative import location?
How to annotate genmodel with a relative import location? [message #69428] Sat, 26 August 2006 19:21 Go to next message
Matthew Rawlings is currently offline Matthew RawlingsFriend
Messages: 39
Registered: July 2009
Member
How can I annotate the genmodel to generate the correct schemaLocation value
for an import?

I successfully generate an eCore model and genmodel from this schema.
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="http://www.acme.com/vehicles"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ns1="http://www.acme.com/parts"
targetNamespace="http://www.acme.com/vehicles"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:import namespace="http://www.acme.com/parts"
schemaLocation="Parts.xsd"/>
<xs:element name="car">
<xs:complexType>
<xs:sequence>
<xs:element ref="ns1:wheel"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

From the eCore model I want to export the model to an XSD. When I export I
get this schema.
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:parts="http://www.acme.com/parts"
xmlns:vehicles="http://www.acme.com/vehicles"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
ecore:documentRoot="DocumentRoot" ecore:nsPrefix="vehicles"
ecore:package="com.acme.vehicles"
targetNamespace="http://www.acme.com/vehicles">
<xsd:import namespace="http://www.acme.com/parts"
schemaLocation="file:/C:/working/eclipse/cars/parts.xsd"/>
<xsd:element name="car" type="vehicles:car_._type"/>
<xsd:complexType ecore:name="CarType" name="car_._type">
<xsd:sequence>
<xsd:element ref="parts:wheel"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>

How can I make the value of the schemaLocation in the import be the relative
location of "parts.xsd"? I do not want "platform" as the scheme for my URIs.
I want to do this using annotations/detail on the genmodel rather than
coding around it.

- Matthew
Re: How to annotate genmodel with a relative import location? [message #69449 is a reply to message #69428] Sat, 26 August 2006 21:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Matthew,

The schema location in the generated schema will try to create a
relative path between the absolute path of the schema you are
generating, typically platform:/resource/<project>/model/Xyz.xsd, and
the absolute URI of the schema being referenced, which appears to be
"file:/C:/working/eclipse/cars/parts.xsd". Since that's not possible, an
absolute URI would be used. But, if you export to the same folder, so
that a relative path correctly resolves, then that relative path should
be generated. (I wonder if when you import from a schema, the GenModel
should already be set up as if it exports to that same location?) What
I would typically expect is that each model exports a schema to its
model folder and hence references between model schemas will typically
be of the form ../../<other-project/model/Xyz.xsd.


Matthew Rawlings wrote:
> How can I annotate the genmodel to generate the correct schemaLocation value
> for an import?
>
> I successfully generate an eCore model and genmodel from this schema.
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns="http://www.acme.com/vehicles"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:ns1="http://www.acme.com/parts"
> targetNamespace="http://www.acme.com/vehicles"
> elementFormDefault="qualified" attributeFormDefault="unqualified">
> <xs:import namespace="http://www.acme.com/parts"
> schemaLocation="Parts.xsd"/>
> <xs:element name="car">
> <xs:complexType>
> <xs:sequence>
> <xs:element ref="ns1:wheel"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:schema>
>
> From the eCore model I want to export the model to an XSD. When I export I
> get this schema.
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
> xmlns:parts="http://www.acme.com/parts"
> xmlns:vehicles="http://www.acme.com/vehicles"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> ecore:documentRoot="DocumentRoot" ecore:nsPrefix="vehicles"
> ecore:package="com.acme.vehicles"
> targetNamespace="http://www.acme.com/vehicles">
> <xsd:import namespace="http://www.acme.com/parts"
> schemaLocation="file:/C:/working/eclipse/cars/parts.xsd"/>
> <xsd:element name="car" type="vehicles:car_._type"/>
> <xsd:complexType ecore:name="CarType" name="car_._type">
> <xsd:sequence>
> <xsd:element ref="parts:wheel"/>
> </xsd:sequence>
> </xsd:complexType>
> </xsd:schema>
>
> How can I make the value of the schemaLocation in the import be the relative
> location of "parts.xsd"? I do not want "platform" as the scheme for my URIs.
> I want to do this using annotations/detail on the genmodel rather than
> coding around it.
>
> - Matthew
>
>
>
Re: How to annotate genmodel with a relative import location? [message #69469 is a reply to message #69449] Sun, 27 August 2006 11:25 Go to previous messageGo to next message
Matthew Rawlings is currently offline Matthew RawlingsFriend
Messages: 39
Registered: July 2009
Member
Hi Ed,

Using the default settings and doing a straight import and export from one
genmodel to the same folder I do get the relative schemaLocation. An example
of the result is below.

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:parts="http://www.acme.com/parts"
xmlns:vehicles="http://www.acme.com/vehicles"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
ecore:documentRoot="DocumentRoot" ecore:nsPrefix="vehicles"
ecore:package="com.acme.vehicles"
targetNamespace="http://www.acme.com/vehicles">
<xsd:import namespace="http://www.acme.com/parts"
schemaLocation="platform:/resource/trans/model/parts.xsd"/ >
<xsd:element name="car" type="vehicles:car_._type"/>
<xsd:complexType ecore:name="CarType" name="car_._type">
<xsd:sequence>
<xsd:element ref="parts:wheel"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>

Q1. My problem is how to get schemaLocation="parts.xsd" instead of
schemaLocation="platform:/resource/trans/model/parts.xsd"/ >.

The URI scheme of "platform" is not suitable for producing a schema for
other tools to digest.

Q2. Can I do this using annotations on the genmodel?

Thanks for the quick response. - Matthew
Re: How to annotate genmodel with a relative import location? [message #69489 is a reply to message #69469] Sun, 27 August 2006 12:42 Go to previous message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Matthew,

It's not working as well as I expected. Please open a bugzilla.


Matthew Rawlings wrote:
> Hi Ed,
>
> Using the default settings and doing a straight import and export from one
> genmodel to the same folder I do get the relative schemaLocation. An example
> of the result is below.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
> xmlns:parts="http://www.acme.com/parts"
> xmlns:vehicles="http://www.acme.com/vehicles"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> ecore:documentRoot="DocumentRoot" ecore:nsPrefix="vehicles"
> ecore:package="com.acme.vehicles"
> targetNamespace="http://www.acme.com/vehicles">
> <xsd:import namespace="http://www.acme.com/parts"
> schemaLocation="platform:/resource/trans/model/parts.xsd"/ >
> <xsd:element name="car" type="vehicles:car_._type"/>
> <xsd:complexType ecore:name="CarType" name="car_._type">
> <xsd:sequence>
> <xsd:element ref="parts:wheel"/>
> </xsd:sequence>
> </xsd:complexType>
> </xsd:schema>
>
> Q1. My problem is how to get schemaLocation="parts.xsd" instead of
> schemaLocation="platform:/resource/trans/model/parts.xsd"/ >.
>
> The URI scheme of "platform" is not suitable for producing a schema for
> other tools to digest.
>
> Q2. Can I do this using annotations on the genmodel?
>
> Thanks for the quick response. - Matthew
>
>
>
Re: How to annotate genmodel with a relative import location? [message #598633 is a reply to message #69428] Sat, 26 August 2006 21:01 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Matthew,

The schema location in the generated schema will try to create a
relative path between the absolute path of the schema you are
generating, typically platform:/resource/<project>/model/Xyz.xsd, and
the absolute URI of the schema being referenced, which appears to be
"file:/C:/working/eclipse/cars/parts.xsd". Since that's not possible, an
absolute URI would be used. But, if you export to the same folder, so
that a relative path correctly resolves, then that relative path should
be generated. (I wonder if when you import from a schema, the GenModel
should already be set up as if it exports to that same location?) What
I would typically expect is that each model exports a schema to its
model folder and hence references between model schemas will typically
be of the form ../../<other-project/model/Xyz.xsd.


Matthew Rawlings wrote:
> How can I annotate the genmodel to generate the correct schemaLocation value
> for an import?
>
> I successfully generate an eCore model and genmodel from this schema.
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns="http://www.acme.com/vehicles"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:ns1="http://www.acme.com/parts"
> targetNamespace="http://www.acme.com/vehicles"
> elementFormDefault="qualified" attributeFormDefault="unqualified">
> <xs:import namespace="http://www.acme.com/parts"
> schemaLocation="Parts.xsd"/>
> <xs:element name="car">
> <xs:complexType>
> <xs:sequence>
> <xs:element ref="ns1:wheel"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:schema>
>
> From the eCore model I want to export the model to an XSD. When I export I
> get this schema.
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
> xmlns:parts="http://www.acme.com/parts"
> xmlns:vehicles="http://www.acme.com/vehicles"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> ecore:documentRoot="DocumentRoot" ecore:nsPrefix="vehicles"
> ecore:package="com.acme.vehicles"
> targetNamespace="http://www.acme.com/vehicles">
> <xsd:import namespace="http://www.acme.com/parts"
> schemaLocation="file:/C:/working/eclipse/cars/parts.xsd"/>
> <xsd:element name="car" type="vehicles:car_._type"/>
> <xsd:complexType ecore:name="CarType" name="car_._type">
> <xsd:sequence>
> <xsd:element ref="parts:wheel"/>
> </xsd:sequence>
> </xsd:complexType>
> </xsd:schema>
>
> How can I make the value of the schemaLocation in the import be the relative
> location of "parts.xsd"? I do not want "platform" as the scheme for my URIs.
> I want to do this using annotations/detail on the genmodel rather than
> coding around it.
>
> - Matthew
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to annotate genmodel with a relative import location? [message #598639 is a reply to message #69449] Sun, 27 August 2006 11:25 Go to previous message
Matthew Rawlings is currently offline Matthew RawlingsFriend
Messages: 39
Registered: July 2009
Member
Hi Ed,

Using the default settings and doing a straight import and export from one
genmodel to the same folder I do get the relative schemaLocation. An example
of the result is below.

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:parts="http://www.acme.com/parts"
xmlns:vehicles="http://www.acme.com/vehicles"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
ecore:documentRoot="DocumentRoot" ecore:nsPrefix="vehicles"
ecore:package="com.acme.vehicles"
targetNamespace="http://www.acme.com/vehicles">
<xsd:import namespace="http://www.acme.com/parts"
schemaLocation="platform:/resource/trans/model/parts.xsd"/ >
<xsd:element name="car" type="vehicles:car_._type"/>
<xsd:complexType ecore:name="CarType" name="car_._type">
<xsd:sequence>
<xsd:element ref="parts:wheel"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>

Q1. My problem is how to get schemaLocation="parts.xsd" instead of
schemaLocation="platform:/resource/trans/model/parts.xsd"/ >.

The URI scheme of "platform" is not suitable for producing a schema for
other tools to digest.

Q2. Can I do this using annotations on the genmodel?

Thanks for the quick response. - Matthew
Re: How to annotate genmodel with a relative import location? [message #598647 is a reply to message #69469] Sun, 27 August 2006 12:42 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Matthew,

It's not working as well as I expected. Please open a bugzilla.


Matthew Rawlings wrote:
> Hi Ed,
>
> Using the default settings and doing a straight import and export from one
> genmodel to the same folder I do get the relative schemaLocation. An example
> of the result is below.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
> xmlns:parts="http://www.acme.com/parts"
> xmlns:vehicles="http://www.acme.com/vehicles"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> ecore:documentRoot="DocumentRoot" ecore:nsPrefix="vehicles"
> ecore:package="com.acme.vehicles"
> targetNamespace="http://www.acme.com/vehicles">
> <xsd:import namespace="http://www.acme.com/parts"
> schemaLocation="platform:/resource/trans/model/parts.xsd"/ >
> <xsd:element name="car" type="vehicles:car_._type"/>
> <xsd:complexType ecore:name="CarType" name="car_._type">
> <xsd:sequence>
> <xsd:element ref="parts:wheel"/>
> </xsd:sequence>
> </xsd:complexType>
> </xsd:schema>
>
> Q1. My problem is how to get schemaLocation="parts.xsd" instead of
> schemaLocation="platform:/resource/trans/model/parts.xsd"/ >.
>
> The URI scheme of "platform" is not suitable for producing a schema for
> other tools to digest.
>
> Q2. Can I do this using annotations on the genmodel?
>
> Thanks for the quick response. - Matthew
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:How to annotate genmodel with a relative import location?
Next Topic:Complex Type Parsing
Goto Forum:
  


Current Time: Fri Mar 29 07:31:49 GMT 2024

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

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

Back to the top