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 |
Eclipse User |
|
|
|
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 |
Ed Merks 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. For 2) I believe SAX itself tries to load the DTD, by calling
this method in XMLHandler:<br>
<blockquote><small> public InputSource resolveEntity(String publicId,
String systemId) throws SAXException</small><br>
<small> {</small><br>
<small> try</small><br>
<small> {</small><br>
<small> Map<Object, Object> options = new
HashMap<Object, Object>();</small><br>
<small> options.put("publicId", publicId);</small><br>
<small> options.put("systemId", systemId);</small><br>
<small> options.put("baseLocation", resourceURI == null ? null :
resourceURI.toString());</small><br>
<small> URI uri = URI.createURI(systemId);</small><br>
<small> if (resolve && uri.isRelative() &&
uri.hasRelativePath())</small><br>
<small> {</small><br>
<small> uri = helper.resolve(uri, resourceURI);</small><br>
<small> }</small><br>
<small> InputStream inputStream =
getURIConverter().createInputStream(uri, options);</small><br>
<small> InputSource result = new InputSource(inputStream);</small><br>
<small> result.setPublicId(publicId);</small><br>
<small> result.setSystemId(systemId);</small><br>
<small> return result;</small><br>
<small> }</small><br>
<small> catch (IOException exception)</small><br>
<small> {</small><br>
<small> throw new SAXException(exception);</small><br>
<small> }</small><br>
<small> }</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 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 |
Eclipse User |
|
|
|
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 |
Ed Merks 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/
|
|
|
Goto Forum:
Current Time: Thu Apr 25 17:54:03 GMT 2024
Powered by FUDForum. Page generated in 0.03269 seconds
|