Skip to main content



      Home
Home » Modeling » EMF » XML output unformatted with ecore:mixed
XML output unformatted with ecore:mixed [message #387047] Fri, 13 August 2004 16:31 Go to next message
Eclipse UserFriend
I took the library.xsd example and added ecore:mixed="true" in ordet to
allow XML comments to be preserved.

The output of an instance document comes out flat on one line.
Here is the xsd I used.

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://www.example.eclipse.org/Library"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:lib="http://www.example.eclipse.org/Library"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:complexType name="Book" ecore:mixed="true">
<xsd:sequence>
<xsd:element name="title" type="xsd:string"/>
<xsd:element name="pages" type="xsd:int"/>
<xsd:element name="category" type="lib:BookCategory"/>
<xsd:element name="author" type="xsd:anyURI"
ecore:reference="lib:Writer" ecore:opposite="books"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="Writer" ecore:mixed="true">
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="books"
type="xsd:anyURI" ecore:reference="lib:Book"
ecore:opposite="author"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="Library" ecore:mixed="true">
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
<xsd:element maxOccurs="unbounded" minOccurs="0"
name="writers" type="lib:Writer"/>
<xsd:element maxOccurs="unbounded" minOccurs="0"
name="books" type="lib:Book"/>
</xsd:sequence>
</xsd:complexType>
<xsd:simpleType name="BookCategory">
<xsd:restriction base="xsd:NCName">
<xsd:enumeration value="Mystery"/>
<xsd:enumeration value="ScienceFiction"/>
<xsd:enumeration value="Biography"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
Re: XML output unformatted with ecore:mixed [message #387056 is a reply to message #387047] Mon, 16 August 2004 08:06 Go to previous messageGo to next message
Eclipse UserFriend
Mark,

Once you say it's mixed, you are responsible for the formatting. So if
you read in an instance, the instance formatting will be preserved, but
if you create an instance from scratch, you have to create the
formatting from scratch too.


Mark Brodhun wrote:

> I took the library.xsd example and added ecore:mixed="true" in ordet
> to allow XML comments to be preserved.
>
> The output of an instance document comes out flat on one line.
> Here is the xsd I used.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema targetNamespace="http://www.example.eclipse.org/Library"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
> xmlns:lib="http://www.example.eclipse.org/Library"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema">
> <xsd:complexType name="Book" ecore:mixed="true">
> <xsd:sequence>
> <xsd:element name="title" type="xsd:string"/>
> <xsd:element name="pages" type="xsd:int"/>
> <xsd:element name="category" type="lib:BookCategory"/>
> <xsd:element name="author" type="xsd:anyURI"
> ecore:reference="lib:Writer" ecore:opposite="books"/>
> </xsd:sequence>
> </xsd:complexType>
> <xsd:complexType name="Writer" ecore:mixed="true">
> <xsd:sequence>
> <xsd:element name="name" type="xsd:string"/>
> <xsd:element maxOccurs="unbounded" minOccurs="0" name="books"
> type="xsd:anyURI" ecore:reference="lib:Book"
> ecore:opposite="author"/>
> </xsd:sequence>
> </xsd:complexType>
> <xsd:complexType name="Library" ecore:mixed="true">
> <xsd:sequence>
> <xsd:element name="name" type="xsd:string"/>
> <xsd:element maxOccurs="unbounded" minOccurs="0"
> name="writers" type="lib:Writer"/>
> <xsd:element maxOccurs="unbounded" minOccurs="0"
> name="books" type="lib:Book"/>
> </xsd:sequence>
> </xsd:complexType>
> <xsd:simpleType name="BookCategory">
> <xsd:restriction base="xsd:NCName">
> <xsd:enumeration value="Mystery"/>
> <xsd:enumeration value="ScienceFiction"/>
> <xsd:enumeration value="Biography"/>
> </xsd:restriction>
> </xsd:simpleType>
> </xsd:schema>
Re: XML output unformatted with ecore:mixed [message #398423 is a reply to message #387056] Wed, 08 February 2006 10:03 Go to previous messageGo to next message
Eclipse UserFriend
Hi, I am new at EMF, but have successfully created a model and am
currently reading data from it.

I am trying to use the ecore namespace as default when generation a
model from a schema. Heres the story.


During reading I found that the xsd :
<xs:element name="resulttype">
<xs:complexType mixed="true" />
</xs:element>


Does not allow me to access CDATA like banana

<resulttype>banana</resulttype>

in the generated code.

Adding the ecore namespace to the schema node
and putting mixed in this namespace fixed the problem

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore">
......
<xs:element name="resulttype">
<xs:complexType ecore:mixed="true" />
</xs:element>

now the generated code has the method getMixed() on which I can use the
getValue(0) to get CDATA contents, which is fine.

Back to the question : can I get the emf codegenerator to generate
getMixed as default or define the ecore namespace to be used as default

Regards, Jesper


Ed Merks wrote:
> Mark,
>
> Once you say it's mixed, you are responsible for the formatting. So if
> you read in an instance, the instance formatting will be preserved, but
> if you create an instance from scratch, you have to create the
> formatting from scratch too.
>
>
> Mark Brodhun wrote:
>
>> I took the library.xsd example and added ecore:mixed="true" in ordet
>> to allow XML comments to be preserved.
>>
>> The output of an instance document comes out flat on one line.
>> Here is the xsd I used.
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <xsd:schema targetNamespace="http://www.example.eclipse.org/Library"
>> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
>> xmlns:lib="http://www.example.eclipse.org/Library"
>> xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>> <xsd:complexType name="Book" ecore:mixed="true">
>> <xsd:sequence>
>> <xsd:element name="title" type="xsd:string"/>
>> <xsd:element name="pages" type="xsd:int"/>
>> <xsd:element name="category" type="lib:BookCategory"/>
>> <xsd:element name="author" type="xsd:anyURI"
>> ecore:reference="lib:Writer" ecore:opposite="books"/>
>> </xsd:sequence>
>> </xsd:complexType>
>> <xsd:complexType name="Writer" ecore:mixed="true">
>> <xsd:sequence>
>> <xsd:element name="name" type="xsd:string"/>
>> <xsd:element maxOccurs="unbounded" minOccurs="0" name="books"
>> type="xsd:anyURI" ecore:reference="lib:Book"
>> ecore:opposite="author"/>
>> </xsd:sequence>
>> </xsd:complexType>
>> <xsd:complexType name="Library" ecore:mixed="true">
>> <xsd:sequence>
>> <xsd:element name="name" type="xsd:string"/>
>> <xsd:element maxOccurs="unbounded" minOccurs="0"
>> name="writers" type="lib:Writer"/>
>> <xsd:element maxOccurs="unbounded" minOccurs="0"
>> name="books" type="lib:Book"/>
>> </xsd:sequence>
>> </xsd:complexType>
>> <xsd:simpleType name="BookCategory">
>> <xsd:restriction base="xsd:NCName">
>> <xsd:enumeration value="Mystery"/>
>> <xsd:enumeration value="ScienceFiction"/>
>> <xsd:enumeration value="Biography"/>
>> </xsd:restriction>
>> </xsd:simpleType>
>> </xsd:schema>
>
Re: XML output unformatted with ecore:mixed [message #398425 is a reply to message #398423] Wed, 08 February 2006 11:14 Go to previous messageGo to next message
Eclipse UserFriend
Jesper,

This was fixed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=86118.


Jesper wrote:

> Hi, I am new at EMF, but have successfully created a model and am
> currently reading data from it.
>
> I am trying to use the ecore namespace as default when generation a
> model from a schema. Heres the story.
>
>
> During reading I found that the xsd :
> <xs:element name="resulttype">
> <xs:complexType mixed="true" />
> </xs:element>
>
>
> Does not allow me to access CDATA like banana
>
> <resulttype>banana</resulttype>
>
> in the generated code.
>
> Adding the ecore namespace to the schema node
> and putting mixed in this namespace fixed the problem
>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore">
> .....
> <xs:element name="resulttype">
> <xs:complexType ecore:mixed="true" />
> </xs:element>
>
> now the generated code has the method getMixed() on which I can use
> the getValue(0) to get CDATA contents, which is fine.
>
> Back to the question : can I get the emf codegenerator to generate
> getMixed as default or define the ecore namespace to be used as default
>
> Regards, Jesper
>
>
> Ed Merks wrote:
>
>> Mark,
>>
>> Once you say it's mixed, you are responsible for the formatting. So
>> if you read in an instance, the instance formatting will be
>> preserved, but if you create an instance from scratch, you have to
>> create the formatting from scratch too.
>>
>>
>> Mark Brodhun wrote:
>>
>>> I took the library.xsd example and added ecore:mixed="true" in ordet
>>> to allow XML comments to be preserved.
>>>
>>> The output of an instance document comes out flat on one line.
>>> Here is the xsd I used.
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <xsd:schema targetNamespace="http://www.example.eclipse.org/Library"
>>> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
>>> xmlns:lib="http://www.example.eclipse.org/Library"
>>> xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>>> <xsd:complexType name="Book" ecore:mixed="true">
>>> <xsd:sequence>
>>> <xsd:element name="title" type="xsd:string"/>
>>> <xsd:element name="pages" type="xsd:int"/>
>>> <xsd:element name="category" type="lib:BookCategory"/>
>>> <xsd:element name="author" type="xsd:anyURI"
>>> ecore:reference="lib:Writer" ecore:opposite="books"/>
>>> </xsd:sequence>
>>> </xsd:complexType>
>>> <xsd:complexType name="Writer" ecore:mixed="true">
>>> <xsd:sequence>
>>> <xsd:element name="name" type="xsd:string"/>
>>> <xsd:element maxOccurs="unbounded" minOccurs="0" name="books"
>>> type="xsd:anyURI" ecore:reference="lib:Book"
>>> ecore:opposite="author"/>
>>> </xsd:sequence>
>>> </xsd:complexType>
>>> <xsd:complexType name="Library" ecore:mixed="true">
>>> <xsd:sequence>
>>> <xsd:element name="name" type="xsd:string"/>
>>> <xsd:element maxOccurs="unbounded" minOccurs="0"
>>> name="writers" type="lib:Writer"/>
>>> <xsd:element maxOccurs="unbounded" minOccurs="0"
>>> name="books" type="lib:Book"/>
>>> </xsd:sequence>
>>> </xsd:complexType>
>>> <xsd:simpleType name="BookCategory">
>>> <xsd:restriction base="xsd:NCName">
>>> <xsd:enumeration value="Mystery"/>
>>> <xsd:enumeration value="ScienceFiction"/>
>>> <xsd:enumeration value="Biography"/>
>>> </xsd:restriction>
>>> </xsd:simpleType>
>>> </xsd:schema>
>>
>>
Re: XML output unformatted with ecore:mixed [message #1221683 is a reply to message #387047] Wed, 18 December 2013 03:26 Go to previous messageGo to next message
Eclipse UserFriend
Hi

Is it possible to allow comments for a complex type and to keep formatting working?
Re: XML output unformatted with ecore:mixed [message #1222158 is a reply to message #1221683] Thu, 19 December 2013 14:48 Go to previous messageGo to next message
Eclipse UserFriend
Denis,

No, once you have mixed content, you have to control the format.

On 18/12/2013 9:26 AM, Denis Nikiforov wrote:
> Hi
>
> Is it possible to allow comments for a complex type and to keep
> formatting working?
Re: XML output unformatted with ecore:mixed [message #1222303 is a reply to message #387047] Fri, 20 December 2013 00:17 Go to previous message
Eclipse UserFriend
Thanks for reply!

For newbies like me: JDK 1.6 has a good XML support, and it's very easy to format XML even without 3rd party libraries. There are a lot of examples in a web.
Previous Topic:[EMF] [CDO] [Compare] [Bug?] Compare will not work with certan implementation of EStore
Next Topic:models referencing across editors
Goto Forum:
  


Current Time: Mon Apr 28 05:06:22 EDT 2025

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

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

Back to the top