Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [xcore] xml
[xcore] xml [message #892892] Sun, 01 July 2012 14:09 Go to next message
Martin Jacob is currently offline Martin JacobFriend
Messages: 191
Registered: July 2009
Senior Member
Hi,

I try to use xml instead of xmi to save my ecore model. I use xcore to define the model but i can
not find a way to generate xml.

here my example

@GenModel(resource="XML", editDirectory="/test.xcore.edit/src",
editorDirectory="/test.xcore.editor/src", fileExtensions="xc", generateSchema="true")
package test.xcore

@ExtendedMetaData(kind="elementOnly", name="ROOT")
class RootElement
{
@ExtendedMetaData(kind="element", name="CHILDS")
contains Child [] child

}
@ExtendedMetaData(name="ChildClass")

class Child
{
@ExtendedMetaData(kind="attribute", name="nameAttribute")
String name

}


Could any one give me a hint what I am missing?

thanks, Martin
Re: [xcore] xml [message #892893 is a reply to message #892892] Sun, 01 July 2012 14:39 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Martin,<br>
<br>
Comments below.<br>
<br>
<div class="moz-cite-prefix">On 01/07/2012 4:09 PM, Martin Jacob
wrote:<br>
</div>
<blockquote cite="mid:jsplnm$pd8$1@xxxxxxxxe.org" type="cite">Hi,
<br>
<br>
I try to use xml instead of xmi to save my ecore model. I use
xcore to define the model but i can not find a way to generate
xml.
<br>
</blockquote>
What do you mean by generate XML?&nbsp; When I generate the tests project
and run the generated example, I get the following:<br>
<blockquote>&lt;?xml version="1.0" encoding="ASCII"?&gt;<br>
&lt;xcore:ROOT xmlns:xcore="test.xcore"/&gt;<br>
</blockquote>
So that looks to be what's expected...<br>
<blockquote cite="mid:jsplnm$pd8$1@xxxxxxxxe.org" type="cite">
<br>
here my example
<br>
<br>
@GenModel(resource="XML", editDirectory="/test.xcore.edit/src",
<br>
editorDirectory="/test.xcore.editor/src", fileExtensions="xc",
generateSchema="true")
<br>
package test.xcore
<br>
<br>
@ExtendedMetaData(kind="elementOnly", name="ROOT")
<br>
class RootElement
<br>
{
<br>
&nbsp;&nbsp;&nbsp;&nbsp;@ExtendedMetaData(kind="element", name="CHILDS")
<br>
&nbsp;&nbsp;&nbsp;&nbsp;contains Child [] child
<br>
<br>
}
<br>
@ExtendedMetaData(name="ChildClass")
<br>
<br>
class Child
<br>
{
<br>
&nbsp;&nbsp;&nbsp;&nbsp;@ExtendedMetaData(kind="attribute", name="nameAttribute")
<br>
&nbsp;&nbsp;&nbsp;&nbsp;String name
<br>
<br>
}
<br>
<br>
<br>
Could any one give me a hint what I am missing?
<br>
</blockquote>
Is your file extension registered in the plugin.xml (keeping in mind
that the plugin.xml doesn't regenerate once it exists).<br>
<blockquote cite="mid:jsplnm$pd8$1@xxxxxxxxe.org" type="cite">
<br>
thanks,&nbsp;&nbsp;&nbsp; Martin
<br>
</blockquote>
<br>
<br>
</body>
</html>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [xcore] xml [message #892895 is a reply to message #892893] Sun, 01 July 2012 15:05 Go to previous messageGo to next message
Martin Jacob is currently offline Martin JacobFriend
Messages: 191
Registered: July 2009
Senior Member
Thanks Ed,
yes I wan to get what you got but I get:
<?xml version="1.0" encoding="UTF-8"?>
<xcore:RootElement xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xcore="test.xcore">
<child/>
<child/>
<child/>
</xcore:RootElement>

I deleted the edit and editor projects to generate them new from scratch but still getting the XMI
as above.

I also deleted the generated model code in src-gen folder to generate them once more but this did
not help.

Do I need to change any thing else in the project setup than setting the @GenModel(resource="XML")
in the *.xcore file?

I am using latest eclipse (4.2.0).

Martin

Ed Merks wrote, On 01.07.2012 16:39:
> Martin,
>
> Comments below.
>
> On 01/07/2012 4:09 PM, Martin Jacob wrote:
>> Hi,
>>
>> I try to use xml instead of xmi to save my ecore model. I use xcore to define the model but i can
>> not find a way to generate xml.
> What do you mean by generate XML? When I generate the tests project and run the generated example, I
> get the following:
>
> <?xml version="1.0" encoding="ASCII"?>
> <xcore:ROOT xmlns:xcore="test.xcore"/>
>
> So that looks to be what's expected...
>>
>> here my example
>>
>> @GenModel(resource="XML", editDirectory="/test.xcore.edit/src",
>> editorDirectory="/test.xcore.editor/src", fileExtensions="xc", generateSchema="true")
>> package test.xcore
>>
>> @ExtendedMetaData(kind="elementOnly", name="ROOT")
>> class RootElement
>> {
>> @ExtendedMetaData(kind="element", name="CHILDS")
>> contains Child [] child
>>
>> }
>> @ExtendedMetaData(name="ChildClass")
>>
>> class Child
>> {
>> @ExtendedMetaData(kind="attribute", name="nameAttribute")
>> String name
>>
>> }
>>
>>
>> Could any one give me a hint what I am missing?
> Is your file extension registered in the plugin.xml (keeping in mind that the plugin.xml doesn't
> regenerate once it exists).
>>
>> thanks, Martin
>
>
Re: [xcore] xml [message #892899 is a reply to message #892895] Sun, 01 July 2012 15:48 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Martin,

What's in your plugin.xml for the model?

<extension point="org.eclipse.emf.ecore.extension_parser">
<parser
type="xc"
class="test.xcore.util.XcoreResourceFactoryImpl"/>
</extension>

Does your resource factory look like this:

public Resource createResource(URI uri)
{
XMLResource result = new XcoreResourceImpl(uri);
result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);

result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION,
Boolean.TRUE);

result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE,
Boolean.TRUE);
result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE,
Boolean.TRUE);

result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER,
Boolean.TRUE);
return result;
}

On 01/07/2012 5:05 PM, Martin Jacob wrote:
> Thanks Ed,
> yes I wan to get what you got but I get:
> <?xml version="1.0" encoding="UTF-8"?>
> <xcore:RootElement xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI" xmlns:xcore="test.xcore">
> <child/>
> <child/>
> <child/>
> </xcore:RootElement>
>
> I deleted the edit and editor projects to generate them new from
> scratch but still getting the XMI as above.
>
> I also deleted the generated model code in src-gen folder to generate
> them once more but this did not help.
>
> Do I need to change any thing else in the project setup than setting
> the @GenModel(resource="XML") in the *.xcore file?
>
> I am using latest eclipse (4.2.0).
>
> Martin
>
> Ed Merks wrote, On 01.07.2012 16:39:
>> Martin,
>>
>> Comments below.
>>
>> On 01/07/2012 4:09 PM, Martin Jacob wrote:
>>> Hi,
>>>
>>> I try to use xml instead of xmi to save my ecore model. I use xcore
>>> to define the model but i can
>>> not find a way to generate xml.
>> What do you mean by generate XML? When I generate the tests project
>> and run the generated example, I
>> get the following:
>>
>> <?xml version="1.0" encoding="ASCII"?>
>> <xcore:ROOT xmlns:xcore="test.xcore"/>
>>
>> So that looks to be what's expected...
>>>
>>> here my example
>>>
>>> @GenModel(resource="XML", editDirectory="/test.xcore.edit/src",
>>> editorDirectory="/test.xcore.editor/src", fileExtensions="xc",
>>> generateSchema="true")
>>> package test.xcore
>>>
>>> @ExtendedMetaData(kind="elementOnly", name="ROOT")
>>> class RootElement
>>> {
>>> @ExtendedMetaData(kind="element", name="CHILDS")
>>> contains Child [] child
>>>
>>> }
>>> @ExtendedMetaData(name="ChildClass")
>>>
>>> class Child
>>> {
>>> @ExtendedMetaData(kind="attribute", name="nameAttribute")
>>> String name
>>>
>>> }
>>>
>>>
>>> Could any one give me a hint what I am missing?
>> Is your file extension registered in the plugin.xml (keeping in mind
>> that the plugin.xml doesn't
>> regenerate once it exists).
>>>
>>> thanks, Martin
>>
>>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [xcore] xml [message #892902 is a reply to message #892899] Sun, 01 July 2012 16:19 Go to previous message
Martin Jacob is currently offline Martin JacobFriend
Messages: 191
Registered: July 2009
Senior Member
thanks Ed,

the missing part in my setup was the below mentioned extension in my model plugin.

thanks again, Martin


Ed Merks wrote, On 01.07.2012 17:48:
> Martin,
>
> What's in your plugin.xml for the model?
>
> <extension point="org.eclipse.emf.ecore.extension_parser">
> <parser
> type="xc"
> class="test.xcore.util.XcoreResourceFactoryImpl"/>
> </extension>
>
> Does your resource factory look like this:
>
> public Resource createResource(URI uri)
> {
> XMLResource result = new XcoreResourceImpl(uri);
> result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
> result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
>
> result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);
>
> result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
> result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
>
> result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE);
> return result;
> }
>
> On 01/07/2012 5:05 PM, Martin Jacob wrote:
>> Thanks Ed,
>> yes I wan to get what you got but I get:
>> <?xml version="1.0" encoding="UTF-8"?>
>> <xcore:RootElement xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xcore="test.xcore">
>> <child/>
>> <child/>
>> <child/>
>> </xcore:RootElement>
>>
>> I deleted the edit and editor projects to generate them new from scratch but still getting the XMI
>> as above.
>>
>> I also deleted the generated model code in src-gen folder to generate them once more but this did
>> not help.
>>
>> Do I need to change any thing else in the project setup than setting the @GenModel(resource="XML")
>> in the *.xcore file?
>>
>> I am using latest eclipse (4.2.0).
>>
>> Martin
>>
>> Ed Merks wrote, On 01.07.2012 16:39:
>>> Martin,
>>>
>>> Comments below.
>>>
>>> On 01/07/2012 4:09 PM, Martin Jacob wrote:
>>>> Hi,
>>>>
>>>> I try to use xml instead of xmi to save my ecore model. I use xcore to define the model but i can
>>>> not find a way to generate xml.
>>> What do you mean by generate XML? When I generate the tests project and run the generated example, I
>>> get the following:
>>>
>>> <?xml version="1.0" encoding="ASCII"?>
>>> <xcore:ROOT xmlns:xcore="test.xcore"/>
>>>
>>> So that looks to be what's expected...
>>>>
>>>> here my example
>>>>
>>>> @GenModel(resource="XML", editDirectory="/test.xcore.edit/src",
>>>> editorDirectory="/test.xcore.editor/src", fileExtensions="xc", generateSchema="true")
>>>> package test.xcore
>>>>
>>>> @ExtendedMetaData(kind="elementOnly", name="ROOT")
>>>> class RootElement
>>>> {
>>>> @ExtendedMetaData(kind="element", name="CHILDS")
>>>> contains Child [] child
>>>>
>>>> }
>>>> @ExtendedMetaData(name="ChildClass")
>>>>
>>>> class Child
>>>> {
>>>> @ExtendedMetaData(kind="attribute", name="nameAttribute")
>>>> String name
>>>>
>>>> }
>>>>
>>>>
>>>> Could any one give me a hint what I am missing?
>>> Is your file extension registered in the plugin.xml (keeping in mind that the plugin.xml doesn't
>>> regenerate once it exists).
>>>>
>>>> thanks, Martin
>>>
>>>
>
>
Previous Topic:technology for persistence on a new project?
Next Topic:Strange serialization behavior
Goto Forum:
  


Current Time: Wed Apr 24 21:33:22 GMT 2024

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

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

Back to the top