Skip to main content



      Home
Home » Modeling » EMF » How to extract the XML data from the FeatureMap that represents the XML any type
How to extract the XML data from the FeatureMap that represents the XML any type [message #405292] Sun, 12 November 2006 17:39 Go to next message
Eclipse UserFriend
Originally posted by: darkker.gmail.com

Hi,

Is there a way to extract the XML data from the FeatureMap that represents
the XML any type?

As I see, all XML data from the any element is parsed into a number of
EFeatureMaps and enclosing EFeatures which represent the XML structure.

But what to do, if it is required to extract plain XML data?

I'm speaking about something like this:


EAttribute attribute = object.eClass().getEStructuralFeature("any");
FeatureMap map = (FeatureMap)object.eGet(attribute);

String xmlString = SomeMagicClass.getXMLData(map);
System.out.println("Read:" + xmlString);
// Read: <A x="123"><b> </b></A>


Is there any ideas?

Thanks in advance,

Vlad
Re: How to extract the XML data from the FeatureMap that represents the XML any type [message #405295 is a reply to message #405292] Mon, 13 November 2006 07:46 Go to previous messageGo to next message
Eclipse UserFriend
This is a multi-part message in MIME format.
--------------090405040800060908020102
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Vlad,

You'll find this article useful and then you'll likely have more
specific questions:

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


Vladimir P wrote:

> Hi,
>
> Is there a way to extract the XML data from the FeatureMap that
> represents the XML any type?
>
> As I see, all XML data from the any element is parsed into a number of
> EFeatureMaps and enclosing EFeatures which represent the XML structure.
>
> But what to do, if it is required to extract plain XML data?
>
> I'm speaking about something like this:
>
>
> EAttribute attribute = object.eClass().getEStructuralFeature("any");
> FeatureMap map = (FeatureMap)object.eGet(attribute);
>
> String xmlString = SomeMagicClass.getXMLData(map);
> System.out.println("Read:" + xmlString);
> // Read: <A x="123"><b> </b></A>
>
>
> Is there any ideas?
>
> Thanks in advance,
>
> Vlad
>


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

<!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">
Vlad,<br>
<br>
You'll find this article useful and then you'll likely have more
specific questions:<br>
<blockquote><a target="_out"
href=" http://www.theserverside.com/tt/articles/article.tss?l=Bindi ngXMLJava">Binding
XML to Java</a><br>
</blockquote>
<br>
Vladimir P wrote:
<blockquote cite="midc72f59e88204587cf1d7cf8fc6330e2d$1@www.eclipse.org"
type="cite">Hi,
<br>
<br>
Is there a way to extract the XML data from the FeatureMap that
represents the XML any type?
<br>
<br>
As I see, all XML data from the any element is parsed into a number of
EFeatureMaps and enclosing EFeatures which represent the XML structure.
<br>
<br>
But what to do, if it is required to extract plain XML data?
<br>
<br>
I'm speaking about something like this:
<br>
<br>
<br>
EAttribute attribute = object.eClass().getEStructuralFeature("any");
<br>
FeatureMap map = (FeatureMap)object.eGet(attribute);
<br>
<br>
String xmlString = SomeMagicClass.getXMLData(map);
<br>
System.out.println("Read:" + xmlString);
<br>
// Read: &lt;A x="123"&gt;&lt;b&gt; &lt;/b&gt;&lt;/A&gt;
<br>
<br>
<br>
Is there any ideas?
<br>
<br>
Thanks in advance,
<br>
<br>
Vlad
<br>
<br>
</blockquote>
<br>
</body>
</html>

--------------090405040800060908020102--
Re: How to extract the XML data from the FeatureMap that represents the XML any [message #405299 is a reply to message #405295] Tue, 14 November 2006 04:49 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: pyanov.mera.ru

Hi Ed,

Thanks for the usefull article, it clarifies a lot the usage of AnyTypes
in the EMF.

To be more specific:
I'm a writing a GUI application (sort of data-driven) that is intended for
editing a complex data structure, described by the EMF model. The model is
generated from the XML schema and loaded dynamicaly at application
start-up. Some parts of the model can store some arbitrary XML data. This
parts are described as anyType.

The problem is that the same piece of XML data should be represented in
two forms:
1. In the model it is described by a mixture of of EMF classes FeatureMap
and EStructuralFeature.
2. On the screen it is represented as a string, which user can edit,
copy/paste etc.

I'm looking for a simple way to convert EMF anyType FeatureMap <-> XML
string representation.

The only way I see now is to implement EMF serialization/deserialization
of the XML data on the fly.
But it seems to me a tricky and slow solution.

Do you know any other solution? Maybe there is some helper XYZUtil class
that simplifies this?

Thanks in advance,

Vlad
Re: How to extract the XML data from the FeatureMap that represents the XML any [message #405301 is a reply to message #405299] Tue, 14 November 2006 06:36 Go to previous messageGo to next message
Eclipse UserFriend
This is a multi-part message in MIME format.
--------------070102000809030902000009
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Vlad,

Ultimately walking the structure to produce a string will be necessary
and right now such code is tied to the save mechanism of the resource
implementation. XMLHelperImpl.saveString might do the trick, but
getting the root element name to be correct will be tricky, since that's
typically controlled by a containing document root. One brute force
approach would be to serialize to DOM using this XMLResource method

Document save(Document document, Map<?, ?> options, DOMHandler handler);

and use the mapping from EObjects to that DOM as a way of extracting the
branch of the DOM you need, but you'd have to save the whole tree and do
it again each time there is a change...


Vladimir P wrote:
> Hi Ed,
>
> Thanks for the usefull article, it clarifies a lot the usage of
> AnyTypes in the EMF.
>
> To be more specific:
> I'm a writing a GUI application (sort of data-driven) that is intended
> for editing a complex data structure, described by the EMF model. The
> model is generated from the XML schema and loaded dynamicaly at
> application start-up. Some parts of the model can store some arbitrary
> XML data. This parts are described as anyType.
>
> The problem is that the same piece of XML data should be represented
> in two forms:
> 1. In the model it is described by a mixture of of EMF classes
> FeatureMap and EStructuralFeature.
> 2. On the screen it is represented as a string, which user can edit,
> copy/paste etc.
>
> I'm looking for a simple way to convert EMF anyType FeatureMap <-> XML
> string representation.
>
> The only way I see now is to implement EMF
> serialization/deserialization of the XML data on the fly.
> But it seems to me a tricky and slow solution.
>
> Do you know any other solution? Maybe there is some helper XYZUtil
> class that simplifies this?
>
> Thanks in advance,
>
> Vlad
>


--------------070102000809030902000009
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">
Vlad,<br>
<br>
Ultimately walking the structure to produce a string will be necessary
and right now such code is tied to the save mechanism of the resource
implementation.
Re: How to extract the XML data from the FeatureMap that represents the XML any [message #405318 is a reply to message #405301] Wed, 15 November 2006 03:35 Go to previous message
Eclipse UserFriend
Originally posted by: darkker.gmail.com

Ed,

I have solved the problem by serializing the container object that holds
the any data to XML and then cutting the first and the last lines to
remove tags <container_object_name> and </container_object_name>. Before
deserialization I put these tags back. This approach works fine, even it
looks tricky :)).

One more thing to mention: I have noticed that the XML
formatting(indentation, whitespace characters, etc) is preserved in any
data during serialization /deserialization . Thats a really good feature
of EMF!

Thanks,

Vlad
Previous Topic:Purely reflective EMF editor
Next Topic:NsUri as reference
Goto Forum:
  


Current Time: Thu Nov 06 12:25:24 EST 2025

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

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

Back to the top