Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » XML comments missed
| | | | | |
Re: XML comments missed [message #714790 is a reply to message #496528] |
Thu, 11 August 2011 14:02 |
Studs Terkel Messages: 27 Registered: July 2011 |
Junior Member |
|
|
I have a problem which is related to this in some kind.
I have a XSD in which the complexType´s are elementOnly. So if I generate a model and editors out of it, I do not have the opportunity to set comments, process information, CDATA and text within the EMF editor. This is ok. But what is not ok is that when there are xml comments <!-- --> in the underlying file and if I load, edit and save the file with the EMF editor, the comments are gone in the xml...
I have a validator, which use the XSD to validate the underlying file (not the emf validator). For this validator comments <!-- -->, PI <? ?> and CDATA <![CDATA[]]> are ok within an elementOnly complexType. Plain text is not allowed.
If I change the XSD (<xs:complexType name="Wurst" mixed="true">), the generated editor is capable of adding and editing these xml markup elements. But its also possible to add plain text. I dont want that.
My questions now: Who is wrong? The validator which is allowing markup elements in elementOnly complex types? Or EMF in not allowing/enabling xml markup elements in elementOnly types? Why the emf editor even open these files with markup elements in the wrong place?
Is there nothing inbetween elementOnly and mixed="true"? I want comments, process information and CDATA, but no plain text.
I am really confused, please help me out...
|
|
|
Re: XML comments missed [message #714821 is a reply to message #714790] |
Thu, 11 August 2011 14:52 |
Ed Merks Messages: 33216 Registered: July 2009 |
Senior Member |
|
|
Comments below.
On 11/08/2011 7:02 AM, fkluthe wrote:
> I have a problem which is related to this in some kind.
> I have a XSD in which the complexType´s are elementOnly.
So no mixed content.
> So if I generate a model and editors out of it, I do not have the
> opportunity to set comments, process information, CDATA and text
> within the EMF editor.
Indeed, it's just white space and isn't recorded outside of mixed
content. There is place to record it in the model in this case.
> This is ok. But what is not ok is that when there are xml comments
> <!-- --> in the underlying file and if I load, edit and save the file
> with the EMF editor, the comments are gone in the xml...
That's what happens with white space, it's not preserved. Meaningful
information should be part of the schema/model.
> I have a validator, which use the XSD to validate the underlying file
> (not the emf validator). For this validator comments <!-- -->, PI <?
> ?> and CDATA <![CDATA[]]> are ok within an elementOnly complexType.
They're always okay anywhere.
> Plain text is not allowed.
> If I change the XSD (<xs:complexType name="Wurst" mixed="true">), the
> generated editor is capable of adding and editing these xml markup
> elements. But its also possible to add plain text. I dont want that.
It's also possible to avoid it, even though it's possible.
>
> My questions now: Who is wrong?
Sounds like something is allowing mixed content where it's not normally
allowed.
> The validator which is allowing markup elements in elementOnly complex
> types?
White space (comments and processing instructions) are allowed
anywhere. Mixed content, including CDATA, is only allowed where mixed
content is allowed.
> Or EMF in not allowing/enabling xml markup elements in elementOnly types?
EMF just uses SAX so that's all very permissive allowing anything that's
well formed. EMF will happily ignore mixed content when it's not
expecting it.
> Why the emf editor even open these files with markup elements in the
> wrong place?
SAX allows it and EMF happily overlooks it. It's possible to configure
the SAX parser so that it's a validating parser and will strictly adhere
to what's allowed in your schema.
> Is there nothing inbetween elementOnly and mixed="true"?
No.
> I want comments, process information and CDATA, but no plain text.
CDATA and plain text are semantically identical. Nothing in XML Schema
will allow one but not the other.
> I am really confused, please help me out...
If you must, you can specialize XMLHandler to allow or disallow specific
things coming in through SAX.
>
>
>
>
>
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
| |
Re: XML comments missed [message #715159 is a reply to message #715072] |
Fri, 12 August 2011 14:58 |
Ed Merks Messages: 33216 Registered: July 2009 |
Senior Member |
|
|
Comments below.
On 12/08/2011 2:49 AM, fkluthe wrote:
> Thx for your reply.
> "CDATA and plain text are semantically identical." Oh I did not
> realize that; i played around with different content and just put in
> "<![CDATA[]]>" - without any content. Of course this was not criticize
> by the validator, so I thought it was allowed in elementOnly complex
> types...
When it just expands to white space (or the empty string), I suppose
it's okay...
>
> "Meaningful information should be part of the schema/model." True
> true... but actually more than one party is involved. I personally
> think this would be the best solution but I also doubt we agree on that.
The parties should have it explained to them that in general, they
should expect tools not to preserve white space.
> The thing is, I have to persist the given xml-comments. While
> searching for an easy way to do this I came across this thread and try
> out the mixed="true" thing. By adding this to the model, EMF will
> generate all I need (persist the comments, adding comments as
> childnodes in the editor). Now I could make it impossible for the user
> to insert CDATA into the complexTypes but in return the changed XSD,
> which is the basis for validation, will allow CDATA; not necessarily
> added on my side. Using 2 different XSD´s? One for code generation one
> for validation? Possible but messy with reference to maintainability.
A bit messy, but life is a compromise.
>
> Anyway, thanks for the support. I like emf and you have done great in
> the past. I know you have to accommodate a number of things, but one
> thing I would suggest is that emf should offer the opportunity to add
> and persist xml-comments and process information with the editor by
> default/or configuration - since they are allowed anywhere in xml
> anyway. One thing I quite not understand is why the opportunity to add
> comments and PI comes with the mixed="true" attribute - it only gives
> indication that there is character data allowed to appear between the
> child elements. :?
Part of the problem comes down to "what in the model will store the
data." In the case of mixed content, the opportunity is perfect. We
have a feature for storing the data, i.e., the mixed feature map. That
feature is perfect for preserving the mixed order between the element
content and the "non-content". In all other cases, there's no place in
the model to store the data and even if there was a special feature, it
wouldn't preserve the mixed order.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Goto Forum:
Current Time: Sat Sep 21 05:12:06 GMT 2024
Powered by FUDForum. Page generated in 0.04020 seconds
|