Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Load portion of xml file
Load portion of xml file [message #425199] Wed, 19 November 2008 10:20 Go to next message
Sun  is currently offline Sun Friend
Messages: 20
Registered: July 2009
Junior Member
Hi All,

Is there any way to load portion/partial xml file with EMF?

Say for example,
<person>
<name>XYZ</name>
<address>
<houseNo>1</houseNo>
<streetNo>4</streetNo>
<society>ABC</society>
<city>Bangalore</city>
<state>Karnataka</state>
</address>
</person>

How can I load just <address> portion of the xml? The reason is there is
no schema definition for the rest of the xml document. And entire document
is very large. The above is just example for simplicity.

Thanks in Advance.
Sun
Re: Load portion of xml file [message #425200 is a reply to message #425199] Wed, 19 November 2008 10:32 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30882
Registered: July 2009
Senior Member
Sun,

No, there's not, but if you load with the resource created by
GenericXMLResourceFactoryImpl you should be able to load the whole file
and extract the part you're interested in.


Sun wrote:
> Hi All,
>
> Is there any way to load portion/partial xml file with EMF?
>
> Say for example,
> <person>
> <name>XYZ</name>
> <address>
> <houseNo>1</houseNo>
> <streetNo>4</streetNo>
> <society>ABC</society>
> <city>Bangalore</city>
> <state>Karnataka</state>
> </address>
> </person>
>
> How can I load just <address> portion of the xml? The reason is there
> is no schema definition for the rest of the xml document. And entire
> document is very large. The above is just example for simplicity.
>
> Thanks in Advance.
> Sun
>
Re: Load portion of xml file [message #425227 is a reply to message #425200] Thu, 20 November 2008 07:30 Go to previous messageGo to next message
Sun  is currently offline Sun Friend
Messages: 20
Registered: July 2009
Junior Member
Ed,

Can you give some example code for using the GenericXMLResourceFactoryImpl?

For this example lets say there is a file called address.ecore which
define the schema. And person.xml is the xml file from which address needs
to be loaded. After modification when I save the resource, will it update
appropriate portion automatically?

Regards
Sun
Re: Load portion of xml file [message #425228 is a reply to message #425227] Thu, 20 November 2008 08:22 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30882
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------060105060302050303040509
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Sun,

You just register it and use it like any other resource factory, i.e.,
just like the one that's generated for your schema-based model. Have a
look at its createResource method and compare that to the one for your
generated model. And yes, it will serialize changes properly. Have a
loot at this article to understand how it works:

Binding XML to Java
< http://www.theserverside.com/tt/articles/article.tss?l=Bindi ngXMLJava>


Sun wrote:
> Ed,
>
> Can you give some example code for using the
> GenericXMLResourceFactoryImpl?
>
> For this example lets say there is a file called address.ecore which
> define the schema. And person.xml is the xml file from which address
> needs to be loaded. After modification when I save the resource, will
> it update appropriate portion automatically?
>
> Regards
> Sun
>

--------------060105060302050303040509
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Sun,<br>
<br>
You just register it and use it like any other resource factory, i.e.,
just like the one that's generated for your schema-based model.
Previous Topic:Existing genmodel not picked up
Next Topic:non-compact xml serialization
Goto Forum:
  


Current Time: Tue Feb 18 01:07:57 GMT 2020

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

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

Back to the top