Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Texo: how to load xml file?(Documentation or example needed)
Texo: how to load xml file? [message #858787] Fri, 27 April 2012 09:48 Go to next message
Olaf Burdziakowski is currently offline Olaf BurdziakowskiFriend
Messages: 46
Registered: April 2012
Member
I need to load data from xml file and store to database.
I used Texo to generate JAP anotated code + DAO based on my xsd file
Now I do not know how to load the data from xml file.
The example http: //wiki.eclipse.org/Texo/XML_and_XMI_Serialization is very poor.

Any full example please ...

[Updated on: Fri, 27 April 2012 11:18]

Report message to a moderator

Re: Texo: how to load xml file [message #858957 is a reply to message #858787] Fri, 27 April 2012 11:36 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Olaf,
Maybe I don't understand your question, but my first feel is that Texo is soooo simple in its usage that you just can't
believe it ;-)....
http://wiki.eclipse.org/Texo/XML_and_XMI_Serialization#De-Serializating.2FReading_from_XML.2FXMI

That wiki page shows this method:
private List<Object> readXML(final String xml) {
final ModelXMLLoader xmlLoader = new ModelXMLLoader();
xmlLoader.setLoadAsXMI(true);
xmlLoader.setReader(new StringReader(xml));
return xmlLoader.read();
}

The string is your xml string, which you can read from a file yourselve, what gets returned is the content of the xml
file as a list of JPA/Texo entities/objects.

If your file/string is plain xml (so not xmi) then don't do setLoadAsXMI(true).

Let me know if I did not understand your question...

gr. Martin


On 04/27/2012 11:48 AM, Olaf Burdziakowski wrote:
> I need to load data from xml file and store to database.
> I used Texo to generate JAP anotated code + DAO based on my xsd file
> Now I do not know how to load the data from xml file.
> The example http: //wiki.eclipse.org/Texo/XML_and_XMI_Serialization is very poor.
>
> Any full example please ...
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: Texo: how to load xml file [message #859036 is a reply to message #858957] Fri, 27 April 2012 12:25 Go to previous messageGo to next message
Olaf Burdziakowski is currently offline Olaf BurdziakowskiFriend
Messages: 46
Registered: April 2012
Member
Hi Martin,
maybe I do not understand something but it do not work.
What I did:
Here is my xml file:(exmaple)
<?xml version="1.0" encoding="UTF-8"?>
<list>
<file name="config_19700101000000.xml" valid_from="1970-01-01T00:00:00"/>
</list>
Here is my xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http: //www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:complexType name="listType">
<xs:sequence minOccurs="1" maxOccurs="unbounded">
<xs:element name="file">
<xs:complexType>
<xs:attribute name="valid_from" type="xs:dateTime" use="required"/>
<xs:attribute name="name" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:element name="list" type="listType"/>
</xs:schema>

I generated with texo from eclipe menu: JPA anotated model code + DAO.
I got some standard set of classes.

Now I would like to load above xml file with your easy function:

private static List<Object> readXML(final String xml) {
final ModelXMLLoader xmlLoader = new ModelXMLLoader();
xmlLoader.setLoadAsXMI(false);
xmlLoader.setReader(new StringReader(xml));
return xmlLoader.read();
}
As input there is string with loaded xml file. Now I got this error:

Exception in thread "main" java.lang.IllegalStateException: org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Package with uri 'null' not found. (, 1, 45)
at org.eclipse.emf.texo.xml.ModelXMLLoader.read(ModelXMLLoader.java:95)
at service.KCellPrices2.readXML(KCellPrices2.java:112)
at service.KCellPrices2.main(KCellPrices2.java:73)
Caused by: org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Package with uri 'null' not found. (, 1, 45)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.handleErrors(XMLLoadImpl.java:83)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:274)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:802)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.load(XMLResourceImpl.java:766)
at org.eclipse.emf.texo.xml.ModelXMLLoader.read(ModelXMLLoader.java:91)
... 2 more
Do you need more info?
Re: Texo: how to load xml file [message #859093 is a reply to message #859036] Fri, 27 April 2012 12:59 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Olaf,
Yes your xml is invalid, you need namespace declarations, otherwise Texo/EMF doesn't know which type you are actually
trying to read. You can easily try out what Texo expects by doing this:

final ModelXMLSaver xmlSaver = new ModelXMLSaver();
xmlSaver.setObjects(Collections.singletonList(new MyListType());
final StringWriter sw = new StringWriter();
xmlSaver.setWriter(sw);
xmlSaver.write();
System.err.println(sw.toString());

Replace the new MyListType() with your Texo generated class for the List type, or use the generated Factory to create it.

Does this help?

gr. Martin

On 04/27/2012 02:25 PM, Olaf Burdziakowski wrote:
> Hi Martin,
> maybe I do not understand something but it do not work.
> What I did:
> Here is my xml file:(exmaple)
> <?xml version="1.0" encoding="UTF-8"?>
> <list>
> <file name="config_19700101000000.xml" valid_from="1970-01-01T00:00:00"/>
> </list>
> Here is my xsd:
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http: //www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
> <xs:complexType name="listType">
> <xs:sequence minOccurs="1" maxOccurs="unbounded">
> <xs:element name="file">
> <xs:complexType>
> <xs:attribute name="valid_from" type="xs:dateTime" use="required"/>
> <xs:attribute name="name" type="xs:string" use="required"/>
> </xs:complexType>
> </xs:element>
> </xs:sequence>
> </xs:complexType>
> <xs:element name="list" type="listType"/>
> </xs:schema>
>
> I generated with texo from eclipe menu: JPA anotated model code + DAO.
> I got some standard set of classes.
>
> Now I would like to load above xml file with your easy function:
>
> private static List<Object> readXML(final String xml) {
> final ModelXMLLoader xmlLoader = new ModelXMLLoader();
> xmlLoader.setLoadAsXMI(false);
> xmlLoader.setReader(new StringReader(xml));
> return xmlLoader.read();
> }
> As input there is string with loaded xml file. Now I got this error:
>
> Exception in thread "main" java.lang.IllegalStateException: org.eclipse.emf.ecore.resource.Resource$IOWrappedException:
> Package with uri 'null' not found. (, 1, 45)
> at org.eclipse.emf.texo.xml.ModelXMLLoader.read(ModelXMLLoader.java:95)
> at service.KCellPrices2.readXML(KCellPrices2.java:112)
> at service.KCellPrices2.main(KCellPrices2.java:73)
> Caused by: org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Package with uri 'null' not found. (, 1, 45)
> at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.handleErrors(XMLLoadImpl.java:83)
> at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:274)
> at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:802)
> at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.load(XMLResourceImpl.java:766)
> at org.eclipse.emf.texo.xml.ModelXMLLoader.read(ModelXMLLoader.java:91)
> ... 2 more
> Do you need more info?


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: Texo: how to load xml file [message #859140 is a reply to message #859093] Fri, 27 April 2012 13:32 Go to previous messageGo to next message
Olaf Burdziakowski is currently offline Olaf BurdziakowskiFriend
Messages: 46
Registered: April 2012
Member
Hi Martin,

I tried before your approach but I also got an error:

Exception in thread "main" java.lang.IllegalStateException: The class class model.creconfigdir.ListType is not managed by this ModelResolver
at org.eclipse.emf.texo.utils.Check.isNotNull(Check.java:66)
at org.eclipse.emf.texo.model.ModelResolver.getModelDescriptor(ModelResolver.java:291)
at org.eclipse.emf.texo.model.ModelResolver.getModelObject(ModelResolver.java:234)
at org.eclipse.emf.texo.converter.ModelToConverter.traverseEReferencesForProxyDetermination(ModelToConverter.java:97)
at org.eclipse.emf.texo.converter.ModelToConverter.computeProxyObjects(ModelToConverter.java:77)
at org.eclipse.emf.texo.converter.ModelToConverter.doBaseActions(ModelToConverter.java:69)
at org.eclipse.emf.texo.xml.ModelEMFConverter.convert(ModelEMFConverter.java:81)
at org.eclipse.emf.texo.xml.ModelXMLSaver.write(ModelXMLSaver.java:84)
at service.KCellPrices2.writeXMI(KCellPrices2.java:117)
at service.KCellPrices2.main(KCellPrices2.java:64)

So can not write to xml also...
Re: Texo: how to load xml file [message #859298 is a reply to message #859140] Fri, 27 April 2012 15:03 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
One important thing is that you must have touched the generated Package class, so use it someway that it gets
initialized (it has an initialize method). If that's the problem/solution then I will add it to the wiki ofcourse.

gr. Martin


On 04/27/2012 03:32 PM, Olaf Burdziakowski wrote:
> Hi Martin,
>
> I tried before your approach but I also got an error:
>
> Exception in thread "main" java.lang.IllegalStateException: The class class model.creconfigdir.ListType is not managed
> by this ModelResolver
> at org.eclipse.emf.texo.utils.Check.isNotNull(Check.java:66)
> at org.eclipse.emf.texo.model.ModelResolver.getModelDescriptor(ModelResolver.java:291)
> at org.eclipse.emf.texo.model.ModelResolver.getModelObject(ModelResolver.java:234)
> at org.eclipse.emf.texo.converter.ModelToConverter.traverseEReferencesForProxyDetermination(ModelToConverter.java:97)
> at org.eclipse.emf.texo.converter.ModelToConverter.computeProxyObjects(ModelToConverter.java:77)
> at org.eclipse.emf.texo.converter.ModelToConverter.doBaseActions(ModelToConverter.java:69)
> at org.eclipse.emf.texo.xml.ModelEMFConverter.convert(ModelEMFConverter.java:81)
> at org.eclipse.emf.texo.xml.ModelXMLSaver.write(ModelXMLSaver.java:84)
> at service.KCellPrices2.writeXMI(KCellPrices2.java:117)
> at service.KCellPrices2.main(KCellPrices2.java:64)
>
> So can not write to xml also...


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: Texo: how to load xml file [message #859472 is a reply to message #859298] Fri, 27 April 2012 16:58 Go to previous messageGo to next message
Olaf Burdziakowski is currently offline Olaf BurdziakowskiFriend
Messages: 46
Registered: April 2012
Member
Hi Martin,

It helped me. Thank you. I did:
ModelPackage pModelPackage = CreConfigDirModelPackage.initialize();
Please add this to wiki.


Then writer has worked. But I got strange result:(xmlSaver.setSaveAsXMI(false))
<?xml version="1.0" encoding="UTF-8"?>
<list xmlns:xsi="http: //www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="null file:/C:/Users/Olaf/workspace/KCellPrices2/model/cre_config_dir.xsd">
<file xsi:type="file_._type" name="config_19700101000000.xml" valid_from="2011-12-31T23:00:00.0Z"/>
</list>

Can I get somehow something closer to xml accepted by EMF ResourceLoader? To get something like this:
<?xml version="1.0" encoding="UTF-8"?>
<list>
<file name="config_19700101000000.xml" valid_from="1970-01-01T00:00:00"/>
</list>

I mean I can add single reference to xml like file:/C:/Users/Olaf/workspace/KCellPrices2/model/cre_config_dir.xsd" but I would like to avoid xsi: in each xml element.

[Updated on: Fri, 27 April 2012 17:56]

Report message to a moderator

Re: Texo: how to load xml file [message #859597 is a reply to message #859472] Fri, 27 April 2012 18:07 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Olaf,
Except for the null schemalocation it is valid xml. What error does the EMF resource loader give?

Anyway you can prevent the xsi:type and schemalocation like this:
xmlSaver.getOptions().put(XMLResource.OPTION_SCHEMA_LOCATION, false);
xmlSaver.getOptions().put(XMLResource.OPTION_SAVE_TYPE_INFORMATION, false);

Let me know if the result works for you.

gr. Martin

On 04/27/2012 06:58 PM, Olaf Burdziakowski wrote:
> Hi Martin,
>
> It helps me. I did:
> ModelPackage pModelPackage = CreConfigDirModelPackage.initialize();
> Please add this to wiki.
>
>
> Then writer has worked. But I got strange result:(xmlSaver.setSaveAsXMI(false))
> <?xml version="1.0" encoding="UTF-8"?>
> <list xmlns:xsi="http: //www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="null
> file:/C:/Users/Olaf/workspace/KCellPrices2/model/cre_config_dir.xsd">
> <file xsi:type="file_._type" name="config_19700101000000.xml" valid_from="2011-12-31T23:00:00.0Z"/>
> </list>
>
> Can I get somehow something closer to xml accepted by EMF ResourceLoader? To get something like this:
> <?xml version="1.0" encoding="UTF-8"?>
> <list>
> <file name="config_19700101000000.xml" valid_from="1970-01-01T00:00:00"/>
> </list>



--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: Texo: how to load xml file [message #859694 is a reply to message #859597] Fri, 27 April 2012 19:14 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Olaf,
The strange thing is that you don't get a namespace. For example this a xml I get when converting the standard EMF
example to xml:
<?xml version="1.0" encoding="UTF-8"?>
<library:Library xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:library="http://www.eclipse.org/emf/texo/test/model/samples/library" name="library">
<writers xsi:type="library:Writer" name="writer" books="#//@books.0"/>
<books xsi:type="library:Book" title="title" pages="27" category="ScienceFiction" author="#//@writers.0"/>
</library:Library>

It has a namespace and a namespace attribute.

gr. Martin


On 04/27/2012 08:07 PM, Martin Taal wrote:
> Hi Olaf,
> Except for the null schemalocation it is valid xml. What error does the EMF resource loader give?
>
> Anyway you can prevent the xsi:type and schemalocation like this:
> xmlSaver.getOptions().put(XMLResource.OPTION_SCHEMA_LOCATION, false);
> xmlSaver.getOptions().put(XMLResource.OPTION_SAVE_TYPE_INFORMATION, false);
>
> Let me know if the result works for you.
>
> gr. Martin
>
> On 04/27/2012 06:58 PM, Olaf Burdziakowski wrote:
>> Hi Martin,
>>
>> It helps me. I did:
>> ModelPackage pModelPackage = CreConfigDirModelPackage.initialize();
>> Please add this to wiki.
>>
>>
>> Then writer has worked. But I got strange result:(xmlSaver.setSaveAsXMI(false))
>> <?xml version="1.0" encoding="UTF-8"?>
>> <list xmlns:xsi="http: //www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="null
>> file:/C:/Users/Olaf/workspace/KCellPrices2/model/cre_config_dir.xsd">
>> <file xsi:type="file_._type" name="config_19700101000000.xml" valid_from="2011-12-31T23:00:00.0Z"/>
>> </list>
>>
>> Can I get somehow something closer to xml accepted by EMF ResourceLoader? To get something like this:
>> <?xml version="1.0" encoding="UTF-8"?>
>> <list>
>> <file name="config_19700101000000.xml" valid_from="1970-01-01T00:00:00"/>
>> </list>
>
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: Texo: how to load xml file [message #859755 is a reply to message #859597] Fri, 27 April 2012 19:54 Go to previous messageGo to next message
Olaf Burdziakowski is currently offline Olaf BurdziakowskiFriend
Messages: 46
Registered: April 2012
Member
Hi Martin,

my intention of writing to xml file was to learn what is required to read the xml file with Texo engine. So I tested:

String sExtra = "<list xmlns:xsi=\"http: //www.w3.org/2001/XMLSchema-instance\" xmlns:CreConfigDir=\"file:/C:/Users/Olaf/workspace/KCellPrices2/model/cre_config_dir.xsd\">";

xmi = writeXMI(pAL);
System.out.println(xmi);
xmi = xmi.replace("<list>", sExtra);
System.out.println(xmi);
List<Object> pList = readXML(xmi);

This works only when I set both functions (read and write) setSaveAsXMI(true) without any funny replacement. But I have files that are not XMI and I would like to read simple xml file with simple update of header element.

What is then required in xml to read it with List<Object> pList = readXML(xmi); when xmlLoader.setLoadAsXMI(false);?
Currently I still got an error:

Exception in thread "main" java.lang.IllegalStateException: org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Package with uri 'null' not found. (, 2, 150)
at org.eclipse.emf.texo.xml.ModelXMLLoader.read(ModelXMLLoader.java:95)
at service.KCellPrices2.readXML(KCellPrices2.java:158)
at service.KCellPrices2.main(KCellPrices2.java:80)

for such file:
<?xml version="1.0" encoding="UTF-8"?>
<list xmlns:xsi="http: //www.w3.org/2001/XMLSchema-instance" xmlns:CreConfigDir="file:/C:/Users/Olaf/workspace/KCellPrices2/model/cre_config_dir.xsd">
<file name="config_19700101000000.xml" valid_from="2011-12-31T23:00:00.0Z"/>
</list>

[Updated on: Fri, 27 April 2012 20:09]

Report message to a moderator

Re: Texo: how to load xml file [message #859792 is a reply to message #859755] Fri, 27 April 2012 20:18 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Olaf,
Can you send me (mtaal@xxxxxxxx) the xsd file (or files) then I can try myself and debug, something is wrong with the
null uri. Not sure what/why.

gr. Maritn

On 04/27/2012 09:54 PM, Olaf Burdziakowski wrote:
> Hi Martin,
>
> my intention of writing to xml file was to learn what is required to read the xml file with Texo engine. So I tested:
>
> String sExtra = "<list xmlns:xsi=\"http: //www.w3.org/2001/XMLSchema-instance\"
> xmlns:CreConfigDir=\"file:/C:/Users/Olaf/workspace/KCellPrices2/model/cre_config_dir.xsd\">";
>
> xmi = writeXMI(pAL);
> System.out.println(xmi);
> xmi = xmi.replace("<list>", sExtra);
> System.out.println(xmi);
> List<Object> pList = readXML(xmi);
>
> This works only when I set both functions (read and write) have set setSaveAsXMI(true). But I have files that are not
> XMI and I would like to read simple xml file with simple update of header element.
>
> What is ten required in xml to read it with List<Object> pList = readXML(xmi); ?
> Currently I still got an error:
>
> Exception in thread "main" java.lang.IllegalStateException: org.eclipse.emf.ecore.resource.Resource$IOWrappedException:
> Package with uri 'null' not found. (, 2, 150)
> at org.eclipse.emf.texo.xml.ModelXMLLoader.read(ModelXMLLoader.java:95)
> at service.KCellPrices2.readXML(KCellPrices2.java:158)
> at service.KCellPrices2.main(KCellPrices2.java:80)
>
> for such file:
> <?xml version="1.0" encoding="UTF-8"?>
> <list xmlns:xsi="http: //www.w3.org/2001/XMLSchema-instance"
> xmlns:CreConfigDir="file:/C:/Users/Olaf/workspace/KCellPrices2/model/cre_config_dir.xsd">
> <file name="config_19700101000000.xml" valid_from="2011-12-31T23:00:00.0Z"/>
> </list>
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: Texo: how to load xml file [message #863154 is a reply to message #859792] Sun, 29 April 2012 09:46 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Olaf,
The solution is to set a namespace in your schema, so add these two attributes in xs:schema element:
xmlns="http://creconfigdir.model"
targetNamespace="http://creconfigdir.model"

The namespace also defines the package structure of your generated code, in this case the code will be generated in the
model.creconfigdir java package.

The testcase you passed works for me, the output/xml I get is this:
<?xml version="1.0" encoding="UTF-8"?>
<creconfigdir:list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:creconfigdir="http://creconfigdir.model">
<creconfigdir:file xsi:type="creconfigdir:file_._type" name="config_19700101000000.xml"
valid_from="2011-12-31T23:00:00.0Z"/>
</creconfigdir:list>

<?xml version="1.0" encoding="UTF-8"?>
<creconfigdir:list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:creconfigdir="http://creconfigdir.model">
<creconfigdir:file xsi:type="creconfigdir:file_._type" name="config_19700101000000.xml"
valid_from="2011-12-31T23:00:00.0Z"/>
</creconfigdir:list>

1

If you disable the type information:
<?xml version="1.0" encoding="UTF-8"?>
<creconfigdir:list xmlns:creconfigdir="http://creconfigdir.model">
<creconfigdir:file name="config_19700101000000.xml" valid_from="2011-12-31T23:00:00.0Z"/>
</creconfigdir:list>

<?xml version="1.0" encoding="UTF-8"?>
<creconfigdir:list xmlns:creconfigdir="http://creconfigdir.model">
<creconfigdir:file name="config_19700101000000.xml" valid_from="2011-12-31T23:00:00.0Z"/>
</creconfigdir:list>

1


gr. Martin

On 04/27/2012 10:18 PM, Martin Taal wrote:
> Hi Olaf,
> Can you send me (mtaal@xxxxxxxx) the xsd file (or files) then I can try myself and debug, something is wrong with the
> null uri. Not sure what/why.
>
> gr. Maritn
>
> On 04/27/2012 09:54 PM, Olaf Burdziakowski wrote:
>> Hi Martin,
>>
>> my intention of writing to xml file was to learn what is required to read the xml file with Texo engine. So I tested:
>>
>> String sExtra = "<list xmlns:xsi=\"http: //www.w3.org/2001/XMLSchema-instance\"
>> xmlns:CreConfigDir=\"file:/C:/Users/Olaf/workspace/KCellPrices2/model/cre_config_dir.xsd\">";
>>
>> xmi = writeXMI(pAL);
>> System.out.println(xmi);
>> xmi = xmi.replace("<list>", sExtra);
>> System.out.println(xmi);
>> List<Object> pList = readXML(xmi);
>>
>> This works only when I set both functions (read and write) have set setSaveAsXMI(true). But I have files that are not
>> XMI and I would like to read simple xml file with simple update of header element.
>>
>> What is ten required in xml to read it with List<Object> pList = readXML(xmi); ?
>> Currently I still got an error:
>>
>> Exception in thread "main" java.lang.IllegalStateException: org.eclipse.emf.ecore.resource.Resource$IOWrappedException:
>> Package with uri 'null' not found. (, 2, 150)
>> at org.eclipse.emf.texo.xml.ModelXMLLoader.read(ModelXMLLoader.java:95)
>> at service.KCellPrices2.readXML(KCellPrices2.java:158)
>> at service.KCellPrices2.main(KCellPrices2.java:80)
>>
>> for such file:
>> <?xml version="1.0" encoding="UTF-8"?>
>> <list xmlns:xsi="http: //www.w3.org/2001/XMLSchema-instance"
>> xmlns:CreConfigDir="file:/C:/Users/Olaf/workspace/KCellPrices2/model/cre_config_dir.xsd">
>> <file name="config_19700101000000.xml" valid_from="2011-12-31T23:00:00.0Z"/>
>> </list>
>>
>>
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: Texo: how to load xml file [message #865132 is a reply to message #863154] Mon, 30 April 2012 08:44 Go to previous messageGo to next message
Olaf Burdziakowski is currently offline Olaf BurdziakowskiFriend
Messages: 46
Registered: April 2012
Member
Hi Martin,
I spend some hours trying to guess how to understand your answer. Please update the project I send you, because whatever I do it do not work.

Regards

Olaf
Re: Texo: how to load xml file [message #865147 is a reply to message #865132] Mon, 30 April 2012 08:54 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Olaf,
I have sent you the updated project a few mins ago. I made the following changes:
- added the name space decl to the xsd
- made sure that texo generates code in the src directory (set the texo nature and the output directory)
- regenerated the texo code
- solved 2 import errors (small name change in the generated model package)
- run the testcase

Let me know if you still encounter problems.

gr. Martin

On 04/30/2012 10:44 AM, Olaf Burdziakowski wrote:
> Hi Martin,
> I spend some hours trying to guess how to understand your answer. Please update the project I send you, because whatever
> I do it do not work.
>
> Regards
>
> Olaf


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: Texo: how to load xml file [message #865195 is a reply to message #865147] Mon, 30 April 2012 09:25 Go to previous messageGo to next message
Olaf Burdziakowski is currently offline Olaf BurdziakowskiFriend
Messages: 46
Registered: April 2012
Member
Hi Martin,
this helped me a lot. Than you very much.
Additionally I set in ecore file nsPrefix="" ans then I got what I wanted:

<?xml version="1.0" encoding="UTF-8"?>
<list xmlns="http: //creconfigdir.model">
<file name="config_19700101000000.xml" valid_from="2011-12-31T23:00:00.0Z"/>
</list>

This work properly.

Thank you again!!!

Ps. I think such example should be available for all. You can use mine if you want.
Best regards

Olaf
Re: Texo: how to load xml file [message #865204 is a reply to message #865195] Mon, 30 April 2012 09:31 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Olaf,
Good that it works, I added a notes section to the wiki page, based on this forum thread:
http://wiki.eclipse.org/Texo/XML_and_XMI_Serialization#Notes

I will see how I can incorporate your example in there or create a separate small example project using a xsd.

gr. Martin

On 04/30/2012 11:25 AM, Olaf Burdziakowski wrote:
> Hi Martin,
> this helped me a lot. Than you very much.
> Additionally I set in ecore file nsPrefix="" ans then I got what I wanted:
> <?xml version="1.0" encoding="UTF-8"?>
> <list xmlns="http: //creconfigdir.model">
> <file name="config_19700101000000.xml" valid_from="2011-12-31T23:00:00.0Z"/>
> </list>
>
> This work properly.
>
> Thank you again!!!
>
> Ps. I think such example should be available for all. You can use mine if you want.
> Best regards
>
> Olaf


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Previous Topic:Using markers in nested TextEditor(s)
Next Topic:[CDO/Hibernate] java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number
Goto Forum:
  


Current Time: Wed Apr 24 16:24:19 GMT 2024

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

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

Back to the top