Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XML Schema Definition (XSD) » Unable to load mixed content when loading an ecore model derived from an xml schema
Unable to load mixed content when loading an ecore model derived from an xml schema [message #604369] Tue, 22 September 2009 17:44
Dhiraj  is currently offline Dhiraj Friend
Messages: 18
Registered: July 2009
Junior Member
I have the following sample xsd:-

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<schema xmlns="" xmlns:tns=""
xmlns:xsd="" elementFormDefault="qualified"
<complexType mixed="true" name="PersonType">
<any processContents="lax" namespace="##any" minOccurs="0" maxOccurs="unbounded"/>
<attribute name="name" type="string" />

<element name="Person" type="tns:PersonType"></element>

And using the EMF Project I created an ecore out of this xsd and
added a derived feature 'classification' which would be assigned
the value from the text node of the Person element. The ecore for
this derived attribute is like this:-

<eStructuralFeatures xsi:type="ecore:EAttribute" name="classification" eType="ecore:EDataType"
volatile="true" transient="true" defaultValueLiteral="" derived="true">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="name" value=":3"/>
<details key="kind" value="simple"/>

I have attached the complete ecore file with this post (filename: schema.ecore)

Then I was trying to load the following model file (xml file):-

<?xml version="1.0" encoding="UTF-8"?>
<schema:Person xmlns:schema="" name="Dhiraj">Dhiraj KUmar<schema:Person name="Manoj"/></schema:Person>

using the following Junit test, but for some reason the 'mixed' attribute of
the PersonType EObject was not being loaded with the correct values and as
a result the 'classification' feature was having an empty value. Following is
the code to load the model file:-

public class ModelLoadingTest extends TestCase {
public void testLoading() {
URI composite2xURI = URI.createPlatformPluginURI(
"/PersonEcore/test/Person.schema", true);
ResourceSet rset = new ResourceSetImpl();

XMLResourceImpl c2xRes = new XMLResourceImpl(composite2xURI);
Map<Object, Object> defaultLoadOptions = c2xRes.getDefaultLoadOptions();
defaultLoadOptions.put(XMLResource.OPTION_RECORD_UNKNOWN_FEA TURE,
defaultLoadOptions.put(XMLResource.OPTION_EXTENDED_META_DATA ,
try {
System.out.println("loaded the resource correctly...");
EObject person = c2xRes.getContents().get(0);
} catch (IOException e) {

public EPackage getPersonEPackage() {
EPackage composite2xPkg = null;
ResourceSet rset = new ResourceSetImpl();
Resource res = rset
"/PersonEcore/model/schema.ecore", true)); //$NON-NLS-1$ //$NON-NLS-2$
try {
composite2xPkg = (EPackage) res.getContents().get(0);
} catch (IOException e) {
return composite2xPkg;

Do I need to pass some other options while loading such resources?
Previous Topic:key/keyref does not validate with recursion?
Next Topic:Unable to load mixed content when loading an ecore model derived from an xml schema
Goto Forum:

Current Time: Tue Jul 14 13:10:17 GMT 2020

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

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

Back to the top