Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Attribute of an EAttribute?!
Attribute of an EAttribute?! [message #499043] Thu, 19 November 2009 15:59 Go to next message
Morten MacFly is currently offline Morten MacFlyFriend
Messages: 69
Registered: July 2009
Member
Hi all,

I am trying something not very common:
A client using the software I am developing with EMF would like to use
the XML file (of the resource) being produced by my application for it's
own purposes: a certified validation. I am generally interested in this
information and would like to apply the tag internally. He suggested to
"simply" add a tag to each attribute in the XML resource as he's not
using EMF, not even Java and this would be most convenient in fact.

So basically I would like to change my Resource XML file from:

<namespace:attr_name>attr_value</namespace:attr_name>

to:

<namespace:attr_name tag="checked">attr_value</namespace:attr_name>

....for certain attributes or (if that is simpler to do) for every attribute.

I though I could "model" this in a way directly with Ecore to
auto-generate the getter and setter for this tag (visibility I would
take care of). But surely this does not work as this would mean to do an
"attribute for an EAttribute".
In addition it does not really belong to my data model as it should just
trigger a flag in the *one* specific view on my data model.

Any idea / hint / advise how I can achive this efficiently?

With best regards, Morten.
Re: Attribute of an EAttribute?! [message #499122 is a reply to message #499043] Thu, 19 November 2009 23:19 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Morten,

The only way to achieve this via a schema would be to make attr_name a
complex type with an attribute and simple content; that would map to an
EClass with to features in Ecore. So there's really no way to make two
attributes of a class come out like this. I think you'd need to
specialize XMLSaveImpl and XMLHandler...


Morten MacFly wrote:
> Hi all,
>
> I am trying something not very common:
> A client using the software I am developing with EMF would like to use
> the XML file (of the resource) being produced by my application for it's
> own purposes: a certified validation. I am generally interested in this
> information and would like to apply the tag internally. He suggested to
> "simply" add a tag to each attribute in the XML resource as he's not
> using EMF, not even Java and this would be most convenient in fact.
>
> So basically I would like to change my Resource XML file from:
>
> <namespace:attr_name>attr_value</namespace:attr_name>
>
> to:
>
> <namespace:attr_name tag="checked">attr_value</namespace:attr_name>
>
> ...for certain attributes or (if that is simpler to do) for every attribute.
>
> I though I could "model" this in a way directly with Ecore to
> auto-generate the getter and setter for this tag (visibility I would
> take care of). But surely this does not work as this would mean to do an
> "attribute for an EAttribute".
> In addition it does not really belong to my data model as it should just
> trigger a flag in the *one* specific view on my data model.
>
> Any idea / hint / advise how I can achive this efficiently?
>
> With best regards, Morten.
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Attribute of an EAttribute?! [message #499145 is a reply to message #499122] Fri, 20 November 2009 06:04 Go to previous messageGo to next message
Morten MacFly is currently offline Morten MacFlyFriend
Messages: 69
Registered: July 2009
Member
Hi Ed,

> I think you'd need to
> specialize XMLSaveImpl and XMLHandler...
Ok, I thought about that way, too.

BTW: I figured out something strange while lookinh into this. As
mentioned my XML file looks like below:

>> <namespace:attr_name>attr_value</namespace:attr_name>

When I played with an example model I realised that it stores it's
attributes like:

<Object attr1="xxx" attr2="yyy" />

and so on. I created that sample from an XSD.

When I compared the Ecore models I realised 3 tags missing in my model:
1.) an ExtendedMetaData at the root node with a child "qualified" set to
false.
2.) an EStringToStringMapEntry at the "DocumentRoot" called
"xMLNSPrefixMap" with two ExtendedMetaData attributes "kind"="attribute"
and "name="xmlns:prefix".
3.) an EStringToStringMapEntry at the "DocumentRoot" called
"xSISchemaLocation" with two ExtendedMetaData attributes
"kind"="attribute" and "name="xsi:schemaLocation".

When I apply these to my model, too the persitence file (XML file) looks
now like the sample one. Thus, attributes are now XML node attributes
and not XML nodes. I wonder where this comes from and where I can read
about such advanced "control mechanisms"...?!

With best regards, Morten.

> Morten MacFly wrote:
>> Hi all,
>>
>> I am trying something not very common:
>> A client using the software I am developing with EMF would like to use
>> the XML file (of the resource) being produced by my application for it's
>> own purposes: a certified validation. I am generally interested in this
>> information and would like to apply the tag internally. He suggested to
>> "simply" add a tag to each attribute in the XML resource as he's not
>> using EMF, not even Java and this would be most convenient in fact.
>>
>> So basically I would like to change my Resource XML file from:
>>
>> <namespace:attr_name>attr_value</namespace:attr_name>
>>
>> to:
>>
>> <namespace:attr_name tag="checked">attr_value</namespace:attr_name>
>>
>> ...for certain attributes or (if that is simpler to do) for every
>> attribute.
>>
>> I though I could "model" this in a way directly with Ecore to
>> auto-generate the getter and setter for this tag (visibility I would
>> take care of). But surely this does not work as this would mean to do an
>> "attribute for an EAttribute".
>> In addition it does not really belong to my data model as it should just
>> trigger a flag in the *one* specific view on my data model.
>>
>> Any idea / hint / advise how I can achive this efficiently?
>>
>> With best regards, Morten.
>>
Re: Attribute of an EAttribute?! [message #499243 is a reply to message #499145] Fri, 20 November 2009 14:33 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------020807060609070608040602
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Morten,

Comments below.

Morten MacFly wrote:
> Hi Ed,
>
>
>> I think you'd need to
>> specialize XMLSaveImpl and XMLHandler...
>>
> Ok, I thought about that way, too.
>
> BTW: I figured out something strange while lookinh into this. As
> mentioned my XML file looks like below:
>
>
>>> <namespace:attr_name>attr_value</namespace:attr_name>
>>>
>
> When I played with an example model I realised that it stores it's
> attributes like:
>
> <Object attr1="xxx" attr2="yyy" />
>
> and so on. I created that sample from an XSD.
>
By default EAttributes will tend to be saved as XML attributes, but
extended meta data can be used to force out an element instead.
> When I compared the Ecore models I realised 3 tags missing in my model:
> 1.) an ExtendedMetaData at the root node with a child "qualified" set to
> false.
> 2.) an EStringToStringMapEntry at the "DocumentRoot" called
> "xMLNSPrefixMap" with two ExtendedMetaData attributes "kind"="attribute"
> and "name="xmlns:prefix".
> 3.) an EStringToStringMapEntry at the "DocumentRoot" called
> "xSISchemaLocation" with two ExtendedMetaData attributes
> "kind"="attribute" and "name="xsi:schemaLocation".
>
> When I apply these to my model, too the persitence file (XML file) looks
> now like the sample one. Thus, attributes are now XML node attributes
> and not XML nodes. I wonder where this comes from and where I can read
> about such advanced "control mechanisms"...?!
>
These are good things to read:

Binding XML to Java
< http://www.theserverside.com/tt/articles/article.tss?l=Bindi ngXMLJava>
XML Schema to Ecore Mapping
< http://www.eclipse.org/modeling/emf/docs/overviews/XMLSchema ToEcoreMapping.pdf>

> With best regards, Morten.
>
>
>> Morten MacFly wrote:
>>
>>> Hi all,
>>>
>>> I am trying something not very common:
>>> A client using the software I am developing with EMF would like to use
>>> the XML file (of the resource) being produced by my application for it's
>>> own purposes: a certified validation. I am generally interested in this
>>> information and would like to apply the tag internally. He suggested to
>>> "simply" add a tag to each attribute in the XML resource as he's not
>>> using EMF, not even Java and this would be most convenient in fact.
>>>
>>> So basically I would like to change my Resource XML file from:
>>>
>>> <namespace:attr_name>attr_value</namespace:attr_name>
>>>
>>> to:
>>>
>>> <namespace:attr_name tag="checked">attr_value</namespace:attr_name>
>>>
>>> ...for certain attributes or (if that is simpler to do) for every
>>> attribute.
>>>
>>> I though I could "model" this in a way directly with Ecore to
>>> auto-generate the getter and setter for this tag (visibility I would
>>> take care of). But surely this does not work as this would mean to do an
>>> "attribute for an EAttribute".
>>> In addition it does not really belong to my data model as it should just
>>> trigger a flag in the *one* specific view on my data model.
>>>
>>> Any idea / hint / advise how I can achive this efficiently?
>>>
>>> With best regards, Morten.
>>>
>>>

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

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Morten,<br>
<br>
Comments below.<br>
<br>
Morten MacFly wrote:
<blockquote cite="mid:he5bh2$a5k$1@build.eclipse.org" type="cite">
<pre wrap="">Hi Ed,

</pre>
<blockquote type="cite">
<pre wrap="">I think you'd need to
specialize XMLSaveImpl and XMLHandler...
</pre>
</blockquote>
<pre wrap=""><!---->Ok, I thought about that way, too.

BTW: I figured out something strange while lookinh into this. As
mentioned my XML file looks like below:

</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap=""> &lt;namespace:attr_name&gt;attr_value&lt;/namesp ace:attr_name&gt;
</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->
When I played with an example model I realised that it stores it's
attributes like:

&lt;Object attr1="xxx" attr2="yyy" /&gt;

and so on. I created that sample from an XSD.
</pre>
</blockquote>
By default EAttributes will tend to be saved as XML attributes, but
extended meta data can be used to force out an element instead.<br>
<blockquote cite="mid:he5bh2$a5k$1@build.eclipse.org" type="cite">
<pre wrap="">
When I compared the Ecore models I realised 3 tags missing in my model:
1.) an ExtendedMetaData at the root node with a child "qualified" set to
false.
2.) an EStringToStringMapEntry at the "DocumentRoot" called
"xMLNSPrefixMap" with two ExtendedMetaData attributes "kind"="attribute"
and "name="xmlns:prefix".
3.) an EStringToStringMapEntry at the "DocumentRoot" called
"xSISchemaLocation" with two ExtendedMetaData attributes
"kind"="attribute" and "name="xsi:schemaLocation".

When I apply these to my model, too the persitence file (XML file) looks
now like the sample one. Thus, attributes are now XML node attributes
and not XML nodes. I wonder where this comes from and where I can read
about such advanced "control mechanisms"...?!
</pre>
</blockquote>
These are good things to read:<br>
<blockquote><a target="_out"
href=" http://www.theserverside.com/tt/articles/article.tss?l=Bindi ngXMLJava">Binding
XML to Java</a><br>
<a
href=" http://www.eclipse.org/modeling/emf/docs/overviews/XMLSchema ToEcoreMapping.pdf">XML
Schema to Ecore Mapping</a><br>
</blockquote>
<blockquote cite="mid:he5bh2$a5k$1@build.eclipse.org" type="cite">
<pre wrap="">
With best regards, Morten.

</pre>
<blockquote type="cite">
<pre wrap="">Morten MacFly wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi all,

I am trying something not very common:
A client using the software I am developing with EMF would like to use
the XML file (of the resource) being produced by my application for it's
own purposes: a certified validation. I am generally interested in this
information and would like to apply the tag internally. He suggested to
"simply" add a tag to each attribute in the XML resource as he's not
using EMF, not even Java and this would be most convenient in fact.

So basically I would like to change my Resource XML file from:

&lt;namespace:attr_name&gt;attr_value&lt;/namesp ace:attr_name&gt;

to:

&lt;namespace:attr_name tag="checked"&gt;attr_value&lt;/namespace:attr_name&gt;

....for certain attributes or (if that is simpler to do) for every
attribute.

I though I could "model" this in a way directly with Ecore to
auto-generate the getter and setter for this tag (visibility I would
take care of). But surely this does not work as this would mean to do an
"attribute for an EAttribute".
In addition it does not really belong to my data model as it should just
trigger a flag in the *one* specific view on my data model.

Any idea / hint / advise how I can achive this efficiently?

With best regards, Morten.

</pre>
</blockquote>
</blockquote>
</blockquote>
</body>
</html>

--------------020807060609070608040602--


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:EMF 2.2 missing OPTION_ELEMENT_HANDLER
Next Topic:Advanced Drag & Drop
Goto Forum:
  


Current Time: Fri Apr 19 19:52:22 GMT 2024

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

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

Back to the top