Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » serialization and document issues when OPTION_SAVE_DOCTYPE enabled
serialization and document issues when OPTION_SAVE_DOCTYPE enabled [message #524408] Wed, 31 March 2010 20:10 Go to next message
Eclipse UserFriend
Originally posted by: murbieta.gpi.com.ar

Hi, i have been facing some unexpected behaviour when enabling
OPTION_SAVE_DOCTYPE option on a XMLResource.

1) document is written dtd's comments are added at top of xml. how can
i avoid it?

2) Issue 1) implies that dtd file is downloaded and when working
off-line my gmf editor stop working. how can i disable validation ?

Thanks in advance
Re: serialization and document issues when OPTION_SAVE_DOCTYPE enabled [message #524443 is a reply to message #524408] Wed, 31 March 2010 23:47 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------080700010604060007000602
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Matias,

I'm not sure what you're expecting for 1) nor what you're actually
getting. For 2) I believe SAX itself tries to load the DTD, by calling
this method in XMLHandler:

public InputSource resolveEntity(String publicId, String systemId)
throws SAXException
{
try
{
Map<Object, Object> options = new HashMap<Object, Object>();
options.put("publicId", publicId);
options.put("systemId", systemId);
options.put("baseLocation", resourceURI == null ? null :
resourceURI.toString());
URI uri = URI.createURI(systemId);
if (resolve && uri.isRelative() && uri.hasRelativePath())
{
uri = helper.resolve(uri, resourceURI);
}
InputStream inputStream =
getURIConverter().createInputStream(uri, options);
InputSource result = new InputSource(inputStream);
result.setPublicId(publicId);
result.setSystemId(systemId);
return result;
}
catch (IOException exception)
{
throw new SAXException(exception);
}
}

So you could provide a URI mapping in the resource set's URI converter
to redirect that DTD's URI to something local.


Matias Urbieta wrote:
> Hi, i have been facing some unexpected behaviour when enabling
> OPTION_SAVE_DOCTYPE option on a XMLResource.
>
> 1) document is written dtd's comments are added at top of xml. how
> can i avoid it?
>
> 2) Issue 1) implies that dtd file is downloaded and when working
> off-line my gmf editor stop working. how can i disable validation ?
>
> Thanks in advance
>

--------------080700010604060007000602
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Matias,<br>
<br>
I'm not sure what you're expecting for 1) nor what you're actually
getting.&nbsp; For 2) I believe SAX itself tries to load the DTD, by calling
this method in XMLHandler:<br>
<blockquote><small>&nbsp; public InputSource resolveEntity(String publicId,
String systemId) throws SAXException</small><br>
<small>&nbsp; {</small><br>
<small>&nbsp;&nbsp;&nbsp; try</small><br>
<small>&nbsp;&nbsp;&nbsp; {</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Map&lt;Object, Object&gt; options = new
HashMap&lt;Object, Object&gt;();</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; options.put("publicId", publicId);</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; options.put("systemId", systemId);</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; options.put("baseLocation", resourceURI == null ? null :
resourceURI.toString());</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; URI uri = URI.createURI(systemId);</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (resolve &amp;&amp; uri.isRelative() &amp;&amp;
uri.hasRelativePath())</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; uri = helper.resolve(uri, resourceURI);</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; InputStream inputStream =
getURIConverter().createInputStream(uri, options);</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; InputSource result = new InputSource(inputStream);</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; result.setPublicId(publicId);</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; result.setSystemId(systemId);</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return result;</small><br>
<small>&nbsp;&nbsp;&nbsp; }</small><br>
<small>&nbsp;&nbsp;&nbsp; catch (IOException exception)</small><br>
<small>&nbsp;&nbsp;&nbsp; {</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw new SAXException(exception);</small><br>
<small>&nbsp;&nbsp;&nbsp; }</small><br>
<small>&nbsp; }</small><br>
</blockquote>
So you could provide a URI mapping in the resource set's URI converter
to redirect that DTD's URI to something local.<br>
<br>
<br>
Matias Urbieta wrote:
<blockquote cite="mid:hp09s8$vek$1@build.eclipse.org" type="cite">Hi, i
have been facing some unexpected behaviour when enabling
OPTION_SAVE_DOCTYPE option on a XMLResource.
<br>
<br>
1) document is written dtd's comments are added at&nbsp; top of xml. how can
i avoid it?
<br>
<br>
2) Issue 1) implies that dtd file is downloaded and when working
off-line my gmf editor stop working. how can i disable validation ?
<br>
<br>
Thanks in advance
<br>
<br>
</blockquote>
</body>
</html>

--------------080700010604060007000602--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: serialization and document issues when OPTION_SAVE_DOCTYPE enabled [message #526113 is a reply to message #524443] Thu, 08 April 2010 17:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: murbieta.gpi.com.ar

Hi Ed, first thanks for the response. I'll rewrite the first issue
because it was unintelligible. When writing an XML with DTD descriptor
enabled, the parser writes those comments with dtd documentation for
serialized xml elements (tags). Documentation is read from the resolved
dtd document.
I believe this behavior is related to the second issue you answered in
the previous mail; it likely is a parameterizable sax behavior.
Next i present an example where for a given XML document its metadata
documentation is appended on top.

//more comments with documentation
....
<!--
A list of validators.

Used in: action, intial-step, result, unconditional-result
-->
<!DOCTYPE workflow PUBLIC "-//OpenSymphony Group//DTD OSWorkflow
2.6//EN" "http://www.opensymphony.com/osworkflow/workflow_2_6.dtd">
<workflow>
<initial-actions/>
<steps>
....
</steps>
</workflow>

Thanks in advance.





Ed Merks escribió:
> Matias,
>
> I'm not sure what you're expecting for 1) nor what you're actually
> getting. For 2) I believe SAX itself tries to load the DTD, by calling
> this method in XMLHandler:
>
> public InputSource resolveEntity(String publicId, String systemId)
> throws SAXException
> {
> try
> {
> Map<Object, Object> options = new HashMap<Object, Object>();
> options.put("publicId", publicId);
> options.put("systemId", systemId);
> options.put("baseLocation", resourceURI == null ? null :
> resourceURI.toString());
> URI uri = URI.createURI(systemId);
> if (resolve && uri.isRelative() && uri.hasRelativePath())
> {
> uri = helper.resolve(uri, resourceURI);
> }
> InputStream inputStream =
> getURIConverter().createInputStream(uri, options);
> InputSource result = new InputSource(inputStream);
> result.setPublicId(publicId);
> result.setSystemId(systemId);
> return result;
> }
> catch (IOException exception)
> {
> throw new SAXException(exception);
> }
> }
>
> So you could provide a URI mapping in the resource set's URI converter
> to redirect that DTD's URI to something local.
>
>
> Matias Urbieta wrote:
>> Hi, i have been facing some unexpected behaviour when enabling
>> OPTION_SAVE_DOCTYPE option on a XMLResource.
>>
>> 1) document is written dtd's comments are added at top of xml. how
>> can i avoid it?
>>
>> 2) Issue 1) implies that dtd file is downloaded and when working
>> off-line my gmf editor stop working. how can i disable validation ?
>>
>> Thanks in advance
>>
Re: serialization and document issues when OPTION_SAVE_DOCTYPE enabled [message #526124 is a reply to message #526113] Thu, 08 April 2010 18:50 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Matias,

I think you're saying that comments in the DTD itself end up being
treated like comments in the original document and then end up being
serialized as well, right? It's probably easy to fix, so please open a
bugzilla with a reproducible test case and then I'll look at how to
avoid such an issue.


Matias Urbieta wrote:
> Hi Ed, first thanks for the response. I'll rewrite the first issue
> because it was unintelligible. When writing an XML with DTD descriptor
> enabled, the parser writes those comments with dtd documentation for
> serialized xml elements (tags). Documentation is read from the
> resolved dtd document.
> I believe this behavior is related to the second issue you answered
> in the previous mail; it likely is a parameterizable sax behavior.
> Next i present an example where for a given XML document its metadata
> documentation is appended on top.
>
> //more comments with documentation
> ...
> <!--
> A list of validators.
>
> Used in: action, intial-step, result, unconditional-result
> -->
> <!DOCTYPE workflow PUBLIC "-//OpenSymphony Group//DTD OSWorkflow
> 2.6//EN" "http://www.opensymphony.com/osworkflow/workflow_2_6.dtd">
> <workflow>
> <initial-actions/>
> <steps>
> ...
> </steps>
> </workflow>
>
> Thanks in advance.
>
>
>
>
>
> Ed Merks escribió:
>> Matias,
>>
>> I'm not sure what you're expecting for 1) nor what you're actually
>> getting. For 2) I believe SAX itself tries to load the DTD, by
>> calling this method in XMLHandler:
>>
>> public InputSource resolveEntity(String publicId, String systemId)
>> throws SAXException
>> {
>> try
>> {
>> Map<Object, Object> options = new HashMap<Object, Object>();
>> options.put("publicId", publicId);
>> options.put("systemId", systemId);
>> options.put("baseLocation", resourceURI == null ? null :
>> resourceURI.toString());
>> URI uri = URI.createURI(systemId);
>> if (resolve && uri.isRelative() && uri.hasRelativePath())
>> {
>> uri = helper.resolve(uri, resourceURI);
>> }
>> InputStream inputStream =
>> getURIConverter().createInputStream(uri, options);
>> InputSource result = new InputSource(inputStream);
>> result.setPublicId(publicId);
>> result.setSystemId(systemId);
>> return result;
>> }
>> catch (IOException exception)
>> {
>> throw new SAXException(exception);
>> }
>> }
>>
>> So you could provide a URI mapping in the resource set's URI
>> converter to redirect that DTD's URI to something local.
>>
>>
>> Matias Urbieta wrote:
>>> Hi, i have been facing some unexpected behaviour when enabling
>>> OPTION_SAVE_DOCTYPE option on a XMLResource.
>>>
>>> 1) document is written dtd's comments are added at top of xml. how
>>> can i avoid it?
>>>
>>> 2) Issue 1) implies that dtd file is downloaded and when working
>>> off-line my gmf editor stop working. how can i disable validation ?
>>>
>>> Thanks in advance
>>>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:attribute not transient must have datatype serializable
Next Topic:EMF Dependencies in VE
Goto Forum:
  


Current Time: Thu Apr 25 17:54:03 GMT 2024

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

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

Back to the top