|
Re: Serialized models based on xsd ? [message #424339 is a reply to message #424336] |
Thu, 23 October 2008 15:06 |
Ed Merks 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/
|
|
|
Powered by
FUDForum. Page generated in 0.02652 seconds