Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Serialized models based on xsd ?
Serialized models based on xsd ? [message #424336] Thu, 23 October 2008 13:46 Go to next message
Stephane  fournier is currently offline Stephane fournierFriend
Messages: 340
Registered: July 2009
Senior Member
Hi,
I have initialized an Ecore model from a XML schema.
I have generated model, edit, editor.

When I save the model, the serialized XML file conforms to the schema but
it does not mention that the xml file is valid against an xsd.
I was expecting something like that in the xml header :
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3schools.com note.xsd"

But nevertheless, I use the XMLResource.OPTION_SCHEMA_LOCATION in options
map at save time.

I made the test from the famous library.xsd schema and EMF 2.4.

Do I miss something to set up ?

Stephane.
Re: Serialized models based on xsd ? [message #424339 is a reply to message #424336] Thu, 23 October 2008 15:06 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Stéphane,

Comments below.

Stéphane Fournier wrote:
> Hi,
> I have initialized an Ecore model from a XML schema.
> I have generated model, edit, editor.
>
> When I save the model, the serialized XML file conforms to the schema
> but it does not mention that the xml file is valid against an xsd.
> I was expecting something like that in the xml header :
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://www.w3schools.com note.xsd"
You won't generally get that by default... Also, a schema location
specifies the namespace and the physical location.
>
> But nevertheless, I use the XMLResource.OPTION_SCHEMA_LOCATION in
> options map at save time.
The schema location is serialized only if ePackage.getNsURI() is
different from ePackage.eResource().getURI()
>
> I made the test from the famous library.xsd schema and EMF 2.4.
>
> Do I miss something to set up ?
Not really. Just a tiny detail. A good technique for controlling the
value of the xsi:schemaLocation is to add someting like this to the
XyzPackageImpl:

@Override
protected Resource createResource(String uri)
{
return super.createResource("http://www.w3schools.com note.xsd"");
}

Hey, I answered this in the FAQ!
http://wiki.eclipse.org/index.php/EMF/FAQ#How_can_I_ensure_t hat_an_xsi:schemaLocation_is_serialized_for_my_packages.3F
>
> Stephane.
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:simple type wrapper classes pattern?
Next Topic:Writing entities with a different model implementation
Goto Forum:
  


Current Time: Thu Apr 25 20:12:52 GMT 2024

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

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

Back to the top