Problem XML serialization [message #429946] |
Thu, 07 May 2009 09:56 |
Ander Messages: 19 Registered: July 2009 |
Junior Member |
|
|
This is a multi-part message in MIME format.
--------------080104070502040607060402
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Hello,
I have defined a simple metamodel using Ecore and I have generated the
plugins. When I create a model conforming to that metamodel, the
serialized thext looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<Library xmlns="http://sLibMM" xmlns:_="" _:name="theLibrary">
<Book ref="1" available="no">
<title>myBook</title>
<author>me</author>
</Book>
<Book ref="2" available="no">
<title>yourBook</title>
<author>you</author>
</Book>
</Library>
And I would like it to be:
<?xml version="1.0" encoding="UTF-8"?>
<Library name="theLibrary">
<Book ref="1" available="no">
<title>myBook</title>
<author>me</author>
</Book>
<Book ref="2" available="no">
<title>yourBook</title>
<author>you</author>
</Book>
</Library>
That is, I don't want the xmlns attribute in my XML.
Any idea how can I do it?
I attach my Ecore metamodel.
Thanks in advance.
Ander
--------------080104070502040607060402
Content-Type: text/xml;
name="slib.ecore"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="slib.ecore"
<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="sLibMM"
nsURI="http://sLibMM" nsPrefix="">
<eClassifiers xsi:type="ecore:EClass" name="Library">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="elementOnly"/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="attribute"/>
<details key="namespace" value=""/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EReference" name="Book" upperBound="-1" eType="#//Book"
containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Book">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="elementOnly"/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="ref" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="attribute"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="available" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"
defaultValueLiteral="">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="attribute"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="title" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="element"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="author" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="element"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="category" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="element"/>
</eAnnotations>
</eStructuralFeatures>
</eClassifiers>
</ecore:EPackage>
--------------080104070502040607060402
Content-Type: text/xml;
name="slib.ecorediag"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="slib.ecorediag"
<?xml version="1.0" encoding="UTF-8"?>
<notation:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.1/notation" xmi:id="_R2y5ETrbEd6PJt7yRKGdHg" type="EcoreTools" measurementUnit="Pixel">
<children xmi:type="notation:Node" xmi:id="_UKBf8DrbEd6PJt7yRKGdHg" type="1001">
<children xmi:type="notation:Node" xmi:id="_UKKp4DrbEd6PJt7yRKGdHg" type="4001"/>
<children xmi:type="notation:Node" xmi:id="_UKKp4TrbEd6PJt7yRKGdHg" type="5001">
<children xmi:type="notation:Node" xmi:id="_WY7AcDrbEd6PJt7yRKGdHg" type="2001">
<element xmi:type="ecore:EAttribute" href="slib.ecore#//Library/name"/>
<layoutConstraint xmi:type="notation:Location" xmi:id="_WY7AcTrbEd6PJt7yRKGdHg"/>
</children>
<styles xmi:type="notation:DrawerStyle" xmi:id="_UKKp4jrbEd6PJt7yRKGdHg"/>
<styles xmi:type="notation:SortingStyle" xmi:id="_UKKp4zrbEd6PJt7yRKGdHg"/>
<styles xmi:type="notation:FilteringStyle" xmi:id="_UKKp5DrbEd6PJt7yRKGdHg"/>
</children>
<children xmi:type="notation:Node" xmi:id="_UKKp5TrbEd6PJt7yRKGdHg" type="5002">
<styles xmi:type="notation:DrawerStyle" xmi:id="_UKKp5jrbEd6PJt7yRKGdHg"/>
<styles xmi:type="notation:SortingStyle" xmi:id="_UKKp5zrbEd6PJt7yRKGdHg"/>
<styles xmi:type="notation:FilteringStyle" xmi:id="_UKKp6DrbEd6PJt7yRKGdHg"/>
</children>
<styles xmi:type="notation:ShapeStyle" xmi:id="_UKBf8TrbEd6PJt7yRKGdHg" fontHeight="10" fillColor="13761016" lineColor="0"/>
<element xmi:type="ecore:EClass" href="slib.ecore#//Library"/>
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_UKBf8jrbEd6PJt7yRKGdHg" x="80" y="205"/>
</children>
<children xmi:type="notation:Node" xmi:id="_ahuB0DrbEd6PJt7yRKGdHg" type="1001">
<children xmi:type="notation:Node" xmi:id="_ahuB0zrbEd6PJt7yRKGdHg" type="4001"/>
<children xmi:type="notation:Node" xmi:id="_ahuB1DrbEd6PJt7yRKGdHg" type="5001">
<children xmi:type="notation:Node" xmi:id="_bfHeMDrbEd6PJt7yRKGdHg" type="2001">
<element xmi:type="ecore:EAttribute" href="slib.ecore#//Book/ref"/>
<layoutConstraint xmi:type="notation:Location" xmi:id="_bfHeMTrbEd6PJt7yRKGdHg"/>
</children>
<children xmi:type="notation:Node" xmi:id="_btHd8DrbEd6PJt7yRKGdHg" type="2001">
<element xmi:type="ecore:EAttribute" href="slib.ecore#//Book/available"/>
<layoutConstraint xmi:type="notation:Location" xmi:id="_btHd8TrbEd6PJt7yRKGdHg"/>
</children>
<children xmi:type="notation:Node" xmi:id="_b3aCYDrbEd6PJt7yRKGdHg" type="2001">
<element xmi:type="ecore:EAttribute" href="slib.ecore#//Book/title"/>
<layoutConstraint xmi:type="notation:Location" xmi:id="_b3aCYTrbEd6PJt7yRKGdHg"/>
</children>
<children xmi:type="notation:Node" xmi:id="_b7uhsDrbEd6PJt7yRKGdHg" type="2001">
<element xmi:type="ecore:EAttribute" href="slib.ecore#//Book/author"/>
<layoutConstraint xmi:type="notation:Location" xmi:id="_b7uhsTrbEd6PJt7yRKGdHg"/>
</children>
<children xmi:type="notation:Node" xmi:id="_b_ckEDrbEd6PJt7yRKGdHg" type="2001">
<element xmi:type="ecore:EAttribute" href="slib.ecore#//Book/category"/>
<layoutConstraint xmi:type="notation:Location" xmi:id="_b_ckETrbEd6PJt7yRKGdHg"/>
</children>
<styles xmi:type="notation:DrawerStyle" xmi:id="_ahuB1TrbEd6PJt7yRKGdHg"/>
<styles xmi:type="notation:SortingStyle" xmi:id="_ahuB1jrbEd6PJt7yRKGdHg"/>
<styles xmi:type="notation:FilteringStyle" xmi:id="_ahuB1zrbEd6PJt7yRKGdHg"/>
</children>
<children xmi:type="notation:Node" xmi:id="_ahuB2DrbEd6PJt7yRKGdHg" type="5002">
<styles xmi:type="notation:DrawerStyle" xmi:id="_ahuB2TrbEd6PJt7yRKGdHg"/>
<styles xmi:type="notation:SortingStyle" xmi:id="_ahuB2jrbEd6PJt7yRKGdHg"/>
<styles xmi:type="notation:FilteringStyle" xmi:id="_ahuB2zrbEd6PJt7yRKGdHg"/>
</children>
<styles xmi:type="notation:ShapeStyle" xmi:id="_ahuB0TrbEd6PJt7yRKGdHg" fontHeight="10" fillColor="13761016" lineColor="0"/>
<element xmi:type="ecore:EClass" href="slib.ecore#//Book"/>
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_ahuB0jrbEd6PJt7yRKGdHg" x="360" y="189"/>
</children>
<styles xmi:type="notation:DiagramStyle" xmi:id="_R2y5EjrbEd6PJt7yRKGdHg"/>
<element xmi:type="ecore:EPackage" href="slib.ecore#/"/>
<edges xmi:type="notation:Edge" xmi:id="_Bl3y0DrcEd6PJt7yRKGdHg" type="3002" source="_UKBf8DrbEd6PJt7yRKGdHg" target="_ahuB0DrbEd6PJt7yRKGdHg">
<children xmi:type="notation:Node" xmi:id="_Bl3y1DrcEd6PJt7yRKGdHg" type="4011">
<layoutConstraint xmi:type="notation:Location" xmi:id="_Bl3y1TrcEd6PJt7yRKGdHg" x="-10" y="-10"/>
</children>
<children xmi:type="notation:Node" xmi:id="_Bl3y1jrcEd6PJt7yRKGdHg" type="4012">
<layoutConstraint xmi:type="notation:Location" xmi:id="_Bl3y1zrcEd6PJt7yRKGdHg" x="10" y="10"/>
</children>
<styles xmi:type="notation:ConnectorStyle" xmi:id="_Bl3y0TrcEd6PJt7yRKGdHg" lineColor="0"/>
<styles xmi:type="notation:FontStyle" xmi:id="_Bl3y0jrcEd6PJt7yRKGdHg" fontHeight="10"/>
<element xmi:type="ecore:EReference" href="slib.ecore#//Library/Book"/>
<bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_Bl3y0zrcEd6PJt7yRKGdHg" points="[58, 4, -294, -18]$[356, 22, 4, 0]"/>
<targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_BmA8wDrcEd6PJt7yRKGdHg" id="(0.9699248,0.5495495)"/>
</edges>
</notation:Diagram>
--------------080104070502040607060402--
|
|
|
|
|
Re: Problem XML serialization [message #429965 is a reply to message #429959] |
Thu, 07 May 2009 16:16 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
Anders,
Hmmm. Maybe there needs to be a document root too... I'd have to try
and am about to fly...
I'd suggest creating a small schema as a starting point. Note that you
can ever export your model to an XML Schema (from the Generator menubar
item) as a starting point.
aZubi wrote:
> Ed Merks wrote:
>> Ander,
>>
>> You'll want to add an annotation to the package to indicate it's like
>> a no namespace schema:
>> < http://www.eclipse.org/modeling/emf/docs/overviews/XMLSchema ToEcoreMapping.pdf>
>>
>>
>>
>> http://www.eclipse.org/modeling/emf/docs/overviews/XMLSchema ToEcoreMapping.pdf
>>
>>
>>
>> aZubi wrote:
>>> Hello,
>>>
>>> I have defined a simple metamodel using Ecore and I have generated
>>> the plugins. When I create a model conforming to that metamodel, the
>>> serialized thext looks like this:
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <Library xmlns="http://sLibMM" xmlns:_="" _:name="theLibrary">
>>> <Book ref="1" available="no">
>>> <title>myBook</title>
>>> <author>me</author>
>>> </Book>
>>> <Book ref="2" available="no">
>>> <title>yourBook</title>
>>> <author>you</author>
>>> </Book>
>>> </Library>
>>>
>>> And I would like it to be:
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <Library name="theLibrary">
>>> <Book ref="1" available="no">
>>> <title>myBook</title>
>>> <author>me</author>
>>> </Book>
>>> <Book ref="2" available="no">
>>> <title>yourBook</title>
>>> <author>you</author>
>>> </Book>
>>> </Library>
>>>
>>> That is, I don't want the xmlns attribute in my XML.
>>> Any idea how can I do it?
>>>
>>> I attach my Ecore metamodel.
>>>
>>> Thanks in advance.
>>>
>>> Ander
>
> Hello,
>
> Thank you for your answer. I have been trying in different ways, but I
> didn't get to the result I want.
>
> Do I have to create a DocumentRoot class in my metamodel? I haven't
> generated the metamodel from a XML Schema.
>
> Ander
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03315 seconds