Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Modeling (top-level project) » How to get Element Content rather than Attribute
How to get Element Content rather than Attribute [message #383195] Mon, 01 September 2008 20:20 Go to next message
Joel Rosi-Schwartz is currently offline Joel Rosi-SchwartzFriend
Messages: 624
Registered: July 2009
Location: London. England
Senior Member
Hi,

I am trying to find a way to coerce EMF to model some text as Element
content rather than as an Attribute. To make this explicit, how EMF
normally serialises at String field is as such:

<?xml version="1.0" encoding="UTF-8"?>
<epo:PurchaseOrder xmlns:epo="http://www.example.com/ExtendedPO">
<details description="This could potentially be a very long string."/>
</epo:PurchaseOrder>

The value of "description" could be any length, f.i. it could be stored
as a CLOB.

What I would like EMF to produce is:

<?xml version="1.0" encoding="UTF-8"?>
<epo:PurchaseOrder xmlns:epo="http://www.example.com/ExtendedPO">
<details>
<description>This could potentially be a very long string.</description >
</details>
</epo:PurchaseOrder>

Is it possible to get EMF to co-operate in this way?

Thanks,
Joel
--
Joel Rosi-Schwartz
Etish Limited [http://www.etish.org]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
^...^
/ o,o \ The proud parents of Useme
|) ::: (| The Open Requirements Management Too
====w=w==== [https://useme.dev.java.net]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Re: How to get Element Content rather than Attribute [message #383201 is a reply to message #383195] Fri, 05 September 2008 20:15 Go to previous messageGo to next message
Joel Rosi-Schwartz is currently offline Joel Rosi-SchwartzFriend
Messages: 624
Registered: July 2009
Location: London. England
Senior Member
I have added eclipse.tools.emf to the list as per Ed's advice on another post.

Thanks Ed,
Joel

On 2008-09-01 21:20:58 +0100, Joel Rosi-Schwartz
<Joel.Rosi-Schwartz@Etish.org> said:

> Hi,
>
> I am trying to find a way to coerce EMF to model some text as Element
> content rather than as an Attribute. To make this explicit, how EMF
> normally serialises at String field is as such:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <epo:PurchaseOrder xmlns:epo="http://www.example.com/ExtendedPO">
> <details description="This could potentially be a very long string."/>
> </epo:PurchaseOrder>
>
> The value of "description" could be any length, f.i. it could be stored
> as a CLOB.
>
> What I would like EMF to produce is:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <epo:PurchaseOrder xmlns:epo="http://www.example.com/ExtendedPO">
> <details>
> <description>This could potentially be a very long string.</description >
> </details>
> </epo:PurchaseOrder>
>
> Is it possible to get EMF to co-operate in this way?
>
> Thanks,
> Joel


--
Joel Rosi-Schwartz
Etish Limited [http://www.etish.org]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
^...^
/ o,o \ The proud parents of Useme
|) ::: (| The Open Requirements Management Too
====w=w==== [https://useme.dev.java.net]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Re: How to get Element Content rather than Attribute [message #383203 is a reply to message #383201] Fri, 05 September 2008 20:27 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Joel,

Sorry I missed your original post. :-(

Comments below.


Joel Rosi-Schwartz wrote:
> I have added eclipse.tools.emf to the list as per Ed's advice on
> another post.
>
> Thanks Ed,
> Joel
>
> On 2008-09-01 21:20:58 +0100, Joel Rosi-Schwartz
> <Joel.Rosi-Schwartz@Etish.org> said:
>
>> Hi,
>>
>> I am trying to find a way to coerce EMF to model some text as Element
>> content rather than as an Attribute. To make this explicit, how EMF
>> normally serialises at String field is as such:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <epo:PurchaseOrder xmlns:epo="http://www.example.com/ExtendedPO">
>> <details description="This could potentially be a very long string."/>
>> </epo:PurchaseOrder>
>>
>> The value of "description" could be any length, f.i. it could be
>> stored as a CLOB.
>>
>> What I would like EMF to produce is:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <epo:PurchaseOrder xmlns:epo="http://www.example.com/ExtendedPO">
>> <details>
>> <description>This could potentially be a very long
>> string.</description >
>> </details>
>> </epo:PurchaseOrder>
>>
>> Is it possible to get EMF to co-operate in this way?
Yes. You could include a annotation like this on the "description"
EAttribute.

<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="element"/>
</eAnnotations>

Then you need to ensure that you use
XMLResource.OPTION_EXTENDED_METADATA when serializing. If you have a
generated resource factory the option should be generated for you. If
you don't, you can use the GenPackage Resource Type property to ensure
one gets generated. Keep in mind that plugin.xml isn't regenerated so
the registration won't get added if there already is one.

>>
>> Thanks,
>> Joel
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to get Element Content rather than Attribute [message #383208 is a reply to message #383203] Mon, 08 September 2008 10:18 Go to previous message
Joel Rosi-Schwartz is currently offline Joel Rosi-SchwartzFriend
Messages: 624
Registered: July 2009
Location: London. England
Senior Member
Works like a charm, thanks Ed. One small correction is that it is
XMLResource.OPTION_EXTENDED_META_DATA rather than
XMLResource.OPTION_EXTENDED_METADATA

Btw, for others who may use this thread for assistance in the future, I
found that Chapter 9 "XML Schema" of the "EMF: Eclipse Modeling
Framework, Second Edition" fills in a lot of the details about this. It
is currently on Safari Rough Cuts at
http://safari.oreilly.com/9780321331885

All the best,
Joel
--
Joel Rosi-Schwartz
Etish Limited [http://www.etish.org]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
^...^
/ o,o \ The proud parents of Useme
|) ::: (| The Open Requirements Management Too
====w=w==== [https://useme.dev.java.net]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Re: How to get Element Content rather than Attribute [message #610547 is a reply to message #383195] Fri, 05 September 2008 20:15 Go to previous message
Joel Rosi-Schwartz is currently offline Joel Rosi-SchwartzFriend
Messages: 624
Registered: July 2009
Location: London. England
Senior Member
I have added eclipse.tools.emf to the list as per Ed's advice on another post.

Thanks Ed,
Joel

On 2008-09-01 21:20:58 +0100, Joel Rosi-Schwartz
<Joel.Rosi-Schwartz@Etish.org> said:

> Hi,
>
> I am trying to find a way to coerce EMF to model some text as Element
> content rather than as an Attribute. To make this explicit, how EMF
> normally serialises at String field is as such:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <epo:PurchaseOrder xmlns:epo="http://www.example.com/ExtendedPO">
> <details description="This could potentially be a very long string."/>
> </epo:PurchaseOrder>
>
> The value of "description" could be any length, f.i. it could be stored
> as a CLOB.
>
> What I would like EMF to produce is:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <epo:PurchaseOrder xmlns:epo="http://www.example.com/ExtendedPO">
> <details>
> <description>This could potentially be a very long string.</description >
> </details>
> </epo:PurchaseOrder>
>
> Is it possible to get EMF to co-operate in this way?
>
> Thanks,
> Joel


--
Joel Rosi-Schwartz
Etish Limited [http://www.etish.org]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
^...^
/ o,o \ The proud parents of Useme
|) ::: (| The Open Requirements Management Too
====w=w==== [https://useme.dev.java.net]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Re: How to get Element Content rather than Attribute [message #610548 is a reply to message #383201] Fri, 05 September 2008 20:27 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Joel,

Sorry I missed your original post. :-(

Comments below.


Joel Rosi-Schwartz wrote:
> I have added eclipse.tools.emf to the list as per Ed's advice on
> another post.
>
> Thanks Ed,
> Joel
>
> On 2008-09-01 21:20:58 +0100, Joel Rosi-Schwartz
> <Joel.Rosi-Schwartz@Etish.org> said:
>
>> Hi,
>>
>> I am trying to find a way to coerce EMF to model some text as Element
>> content rather than as an Attribute. To make this explicit, how EMF
>> normally serialises at String field is as such:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <epo:PurchaseOrder xmlns:epo="http://www.example.com/ExtendedPO">
>> <details description="This could potentially be a very long string."/>
>> </epo:PurchaseOrder>
>>
>> The value of "description" could be any length, f.i. it could be
>> stored as a CLOB.
>>
>> What I would like EMF to produce is:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <epo:PurchaseOrder xmlns:epo="http://www.example.com/ExtendedPO">
>> <details>
>> <description>This could potentially be a very long
>> string.</description >
>> </details>
>> </epo:PurchaseOrder>
>>
>> Is it possible to get EMF to co-operate in this way?
Yes. You could include a annotation like this on the "description"
EAttribute.

<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="element"/>
</eAnnotations>

Then you need to ensure that you use
XMLResource.OPTION_EXTENDED_METADATA when serializing. If you have a
generated resource factory the option should be generated for you. If
you don't, you can use the GenPackage Resource Type property to ensure
one gets generated. Keep in mind that plugin.xml isn't regenerated so
the registration won't get added if there already is one.

>>
>> Thanks,
>> Joel
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to get Element Content rather than Attribute [message #610551 is a reply to message #383203] Mon, 08 September 2008 10:18 Go to previous message
Joel Rosi-Schwartz is currently offline Joel Rosi-SchwartzFriend
Messages: 624
Registered: July 2009
Location: London. England
Senior Member
Works like a charm, thanks Ed. One small correction is that it is
XMLResource.OPTION_EXTENDED_META_DATA rather than
XMLResource.OPTION_EXTENDED_METADATA

Btw, for others who may use this thread for assistance in the future, I
found that Chapter 9 "XML Schema" of the "EMF: Eclipse Modeling
Framework, Second Edition" fills in a lot of the details about this. It
is currently on Safari Rough Cuts at
http://safari.oreilly.com/9780321331885

All the best,
Joel
--
Joel Rosi-Schwartz
Etish Limited [http://www.etish.org]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
^...^
/ o,o \ The proud parents of Useme
|) ::: (| The Open Requirements Management Too
====w=w==== [https://useme.dev.java.net]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Previous Topic:aggregation relation & containmentfeature
Next Topic:aggregation relation & containmentfeature
Goto Forum:
  


Current Time: Tue Apr 23 09:33:51 GMT 2024

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

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

Back to the top