Home » Language IDEs » ServerTools (WTP) » org.w3c.dom.DOMException when using jre 1.6
org.w3c.dom.DOMException when using jre 1.6 [message #218231] |
Fri, 25 July 2008 14:22  |
Eclipse User |
|
|
|
Hello,
When using sun jre 1.6 , when transforming a w3c document to an xml file ,
I get the following exception
Caused by: org.w3c.dom.DOMException: Not implmented in this version
at
org.eclipse.wst.xml.core.internal.document.DocumentImpl.getX mlStandalone(DocumentImpl.java:1121)
at
com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.setDocum entInfo(Unknown
Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Un known
Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Un known
Source)
at
com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl .transformIdentity(Unknown
Source.
This problem does not occur when I use sun jre 2.3.
Can someone plz help?
Thanks,
Wishwas.
|
|
| |
Re: org.w3c.dom.DOMException when using jre 1.6 [message #218269 is a reply to message #218231] |
Fri, 25 July 2008 19:15   |
Eclipse User |
|
|
|
On Fri, 25 Jul 2008 14:22:51 -0400, Wishwas <eclipsedevel@gmail.com> wrote:
> Hello,
>
> When using sun jre 1.6 , when transforming a w3c document to an xml file ,
> I get the following exception
>
> Caused by: org.w3c.dom.DOMException: Not implmented in this version
....
>
> This problem does not occur when I use sun jre 2.3.
>
2.3?
But, back to the main point ... Valentin described the technical reason why this happens,
but let's back up ... what did you do to get this exception? I assume you are extending WTP
in some way?
There are issues other than this exception, if you are trying to use the WTP's XML DOM with
XSL Transforms, or any technology that is expecting a true XML parser (there's several area's that WTP's DOM is not a compliant XML parser, end-of-line handling being one of the most obvious).
So, it is normally discouraged to use WTP's DOM in those contexts.
If you are just trying to format a Document, there might be other ways.
If you are stuck with what you have for some reason, and you are extending WTP, one work around is for you to pre-req
the org.apache.xalan plugin that is in Orbit. This will at least give a consistent implementation of XSL that won't change from VM to VM.
BTW, some would say it is a bug in Sun's processor, that they call DOM3 APIs, without checking
that the DOM Implementation does indeed support DOM3 APIs ... but, not sure if we in WTP are
compliant enough to even allow that.
|
|
|
Re: org.w3c.dom.DOMException when using jre 1.6 [message #218285 is a reply to message #218246] |
Sat, 26 July 2008 04:26   |
Eclipse User |
|
|
|
Hello Valentin,
Thanks for the reply. It is true.
I create the document as below:
IStructuredModel structuredModel =
StructuredModelManager.getModelManager().getModelForEdit(fil eInput.getFile());
When I make modifications to this Document and try to serialize it as
below, I get the exception.
Transformer serializer = TransformerFactory.newInstance().newTransformer();
try {
serializer.setOutputProperty(OutputKeys.ENCODING,
"iso-8859-1")serializer.setOutputProperty(OutputKeys.INDENT, "yes");
serializer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION ,
"yes"); serializer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount",
"4");
serializer.setOutputProperty(OutputKeys.METHOD,
"xml"); serializer.setOutputProperty(OutputKeys.STANDALONE, "yes");
} catch (IllegalArgumentException e) {
// unsupported properties
}
serializer.transform(domSource, new StreamResult(writer));
The problem that I have is if I create the Document using
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
Document document = docBuilder.parse(file);
I get an IO exception because, the xml has a doctype with a reference to a
DTD which cannot be found.
Is it possible to ignore the Doctype declaration when building the
Document ?
Also, How do I add a CSS reference to the Document built ?
Thanks in advance,
Wishwas.
Valentin wrote:
> Seems like the XSLT processor from the Sun 1.6 JRE is using some DOM Level 3
> methods. These are not yet implemented (yet) by the WTP SSE DOM and throw
> that exception.
> Regards, Valentin
> "Wishwas" <eclipsedevel@gmail.com> wrote in message
> news:12f7a2f20f7f0ae647cc46ae623638af$1@www.eclipse.org...
>> Hello,
>>
>> When using sun jre 1.6 , when transforming a w3c document to an xml file ,
>> I get the following exception
>>
>> Caused by: org.w3c.dom.DOMException: Not implmented in this version
>> at
>>
org.eclipse.wst.xml.core.internal.document.DocumentImpl.getX mlStandalone(DocumentImpl.java:1121)
>> at
>> com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.setDocum entInfo(Unknown
>> Source)
>> at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Un known
>> Source)
>> at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Un known
>> Source)
>> at
>>
com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl .transformIdentity(Unknown
>> Source.
>>
>> This problem does not occur when I use sun jre 2.3.
>>
>> Can someone plz help?
>>
>> Thanks,
>> Wishwas.
>>
|
|
|
Re: org.w3c.dom.DOMException when using jre 1.6 [message #218293 is a reply to message #218269] |
Sat, 26 July 2008 04:45   |
Eclipse User |
|
|
|
Oops. It was the IBM jre that I was speaking abt. It works fine on IBM jre.
I have tried to explain what I need to do in my other post in this thread.
Basically, I am extending the WTP editor to have a browser which can show
my xml file with associated CSS ref. I need to make two modifications in
my Document for that.
1. Add the css ref in the Document.
2. Make some changes to Display the images that are referenced in the xml
file. (I wrap the xml tags with html tags for this purpose.)
I then serialize this document to get the file which would be the input to
the Browser (Mozilla in my case).
I have given the code for parsing and serializing that I currently use. As
I said, This works on IBM Jre but not on Sun Jre.
But, I need to use Sun jre coz The schema based validations seem to be
better in the Sun jre (Gives the exact line whr the error is) compared to
that using IBM jre (Points to the parent tag of the error tag.)
Thanks,
Wishwas.
David Williams wrote:
> On Fri, 25 Jul 2008 14:22:51 -0400, Wishwas <eclipsedevel@gmail.com> wrote:
>> Hello,
>>
>> When using sun jre 1.6 , when transforming a w3c document to an xml file ,
>> I get the following exception
>>
>> Caused by: org.w3c.dom.DOMException: Not implmented in this version
> ....
>>
>> This problem does not occur when I use sun jre 2.3.
>>
> 2.3?
> But, back to the main point ... Valentin described the technical reason why
this happens,
> but let's back up ... what did you do to get this exception? I assume you
are extending WTP
> in some way?
> There are issues other than this exception, if you are trying to use the
WTP's XML DOM with
> XSL Transforms, or any technology that is expecting a true XML parser
(there's several area's that WTP's DOM is not a compliant XML parser,
end-of-line handling being one of the most obvious).
> So, it is normally discouraged to use WTP's DOM in those contexts.
> If you are just trying to format a Document, there might be other ways.
> If you are stuck with what you have for some reason, and you are extending
WTP, one work around is for you to pre-req
> the org.apache.xalan plugin that is in Orbit. This will at least give a
consistent implementation of XSL that won't change from VM to VM.
> BTW, some would say it is a bug in Sun's processor, that they call DOM3
APIs, without checking
> that the DOM Implementation does indeed support DOM3 APIs ... but, not sure
if we in WTP are
> compliant enough to even allow that.
|
|
| | |
Re: org.w3c.dom.DOMException when using jre 1.6 [message #218335 is a reply to message #218285] |
Sun, 27 July 2008 03:45   |
Eclipse User |
|
|
|
On Sat, 26 Jul 2008 04:26:34 -0400, Wishwas <eclipsedevel@gmail.com> wrote:
> Is it possible to ignore the Doctype declaration when building the Document ?
Yes. There's a couple of different things you have to do, with 'set-feature', if memory serves me correctly.
You might want to become familiar with
http://xerces.apache.org/xerces2-j/features.html
and you can probably google around for examples.
The two things I remember are to
1) turn validation off.
2) I think you also need to set the "entity resolver" to a "null resolver" so it won't try to look-up character entities. I think, even if you don't don't use entities, the parser's default entity resolver will still try to read the dtd just to see if it declares any ... sort of "getting ready in advance".
> Also, How do I add a CSS reference to the Document built ?
You mean after the fact? I'm not sure there is a way. I'm no expert, but I've seen the css specified in the document, in a PI statement, such as
<?xml-stylesheet href="rss.css" type="text/css"?>
And googling around, I did see this "no way to associate" in the w3c spec,
http://www.w3.org/TR/DOM-Level-2-Style/
<quote>
Interface DOMImplementationCSS (introduced in DOM Level 2)
This interface allows the DOM user to create a CSSStyleSheet outside the context of a document. There is no way to associate the new CSSStyleSheet with a document in DOM Level 2.
</quote>
HTH
|
|
|
Re: org.w3c.dom.DOMException when using jre 1.6 [message #218342 is a reply to message #218309] |
Sun, 27 July 2008 07:29   |
Eclipse User |
|
|
|
Hello David,
First of all, there are no problems when I use the ibm jre. The problem
occurs when I use Sun jre.
As mentioned in my other post,
I create the document as below:
IStructuredModel structuredModel =
StructuredModelManager.getModelManager().getModelForEdit(fil eInput.getFile());
When I make modifications to this Document and try to serialize it as
below, I get the exception.
Transformer serializer = TransformerFactory.newInstance().newTransformer();
try {
serializer.setOutputProperty(OutputKeys.ENCODING,
"iso-8859-1")serializer.setOutputProperty(OutputKeys.INDENT, "yes");
serializer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION , "yes");
serializer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount",
"4"); serializer.setOutputProperty(OutputKeys.METHOD, "xml");
serializer.setOutputProperty(OutputKeys.STANDALONE, "yes");
} catch (IllegalArgumentException e) {
// unsupported properties
}
serializer.transform(domSource, new StreamResult(writer));
The problem that I have is if I create the Document using
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
Document document = docBuilder.parse(file);
When I parse the document as above, The exception is not thrown. But when
I try to associate the style sheet and try to open it in a browser , I get
question marks in place of spaces in the styled document. I guess this is
because of the improper indentation.
Could you please let me know if you know of any solution ?
Also , could you please let me know if the document in the
org.eclipse.wst.sse.core.internal.provisional.IStructuredMod el is
different from org.w3c.dom.Document.
Thanks,
Wishwas.
David Carver wrote:
> The WTP DOM only has partial support for DOM Level 2. Do you get this
> same error with the official Xalan 2.7.1 from Apache, and not Sun's
> hacked version? It could be a problem with the XSLTC and the WTP DOM
> not acting well together. If you can give more information on where
> an when this is happening we can help to track down the problem.
> I would also recommend opening a bug report, and possibly putting some
> comments on the following related bugs:
> WTP DOM Fails W3C DOM Test Suite:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=214439
> Add Full DOM Level 2 support:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=231990
> Add Full DOM Level 3 support:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=231992
> It also appears that the Sun Version of apache xalan isn't checking to
> see if the DOM that is being passed is compliant to a specific level
> before using DOM Level II functionality.
|
|
|
Re: org.w3c.dom.DOMException when using jre 1.6 [message #218351 is a reply to message #218335] |
Sun, 27 July 2008 07:56   |
Eclipse User |
|
|
|
The Doctype declaration is ignored by just setting a dummy EntityResolver.
Also, I was able to add the CSS reference by adding a PI in the document.
I now have another problem. When the file created thus is opened in the
browser, I get question marks(?) in place of spaces in the styled
document. I guess this is because of indentation problems.
David Williams wrote:
> On Sat, 26 Jul 2008 04:26:34 -0400, Wishwas <eclipsedevel@gmail.com> wrote:
>> Is it possible to ignore the Doctype declaration when building the Document
?
> Yes. There's a couple of different things you have to do, with
'set-feature', if memory serves me correctly.
> You might want to become familiar with
> http://xerces.apache.org/xerces2-j/features.html
> and you can probably google around for examples.
> The two things I remember are to
> 1) turn validation off.
> 2) I think you also need to set the "entity resolver" to a "null resolver"
so it won't try to look-up character entities. I think, even if you don't
don't use entities, the parser's default entity resolver will still try to
read the dtd just to see if it declares any ... sort of "getting ready in
advance".
>> Also, How do I add a CSS reference to the Document built ?
> You mean after the fact? I'm not sure there is a way. I'm no expert, but
I've seen the css specified in the document, in a PI statement, such as
> <?xml-stylesheet href="rss.css" type="text/css"?>
> And googling around, I did see this "no way to associate" in the w3c spec,
> http://www.w3.org/TR/DOM-Level-2-Style/
> <quote>
> Interface DOMImplementationCSS (introduced in DOM Level 2)
> This interface allows the DOM user to create a CSSStyleSheet outside the
context of a document. There is no way to associate the new CSSStyleSheet with
a document in DOM Level 2.
> </quote>
> HTH
|
|
| |
Re: org.w3c.dom.DOMException when using jre 1.6 [message #218372 is a reply to message #218351] |
Sun, 27 July 2008 09:07   |
Eclipse User |
|
|
|
Originally posted by: dcarver.starstandard.org
Wishwas wrote:
> The Doctype declaration is ignored by just setting a dummy EntityResolver.
>
> Also, I was able to add the CSS reference by adding a PI in the document.
>
> I now have another problem. When the file created thus is opened in the
> browser, I get question marks(?) in place of spaces in the styled
> document. I guess this is because of indentation problems.
This probably has to do with the encoding format that the Transformer is
serialzing the output into and the web browser is expecting. Make sure
that your XML declaration specifies the encoding format of the file and
that SHOULD take care of the issue.
Dave
> David Williams wrote:
>
>> On Sat, 26 Jul 2008 04:26:34 -0400, Wishwas <eclipsedevel@gmail.com>
>> wrote:
>
>>> Is it possible to ignore the Doctype declaration when building the
>>> Document
> ?
>
>> Yes. There's a couple of different things you have to do, with
> 'set-feature', if memory serves me correctly.
>> You might want to become familiar with
>> http://xerces.apache.org/xerces2-j/features.html and you can probably
>> google around for examples. The two things I remember are to 1) turn
>> validation off. 2) I think you also need to set the "entity resolver"
>> to a "null resolver"
> so it won't try to look-up character entities. I think, even if you
> don't don't use entities, the parser's default entity resolver will
> still try to read the dtd just to see if it declares any ... sort of
> "getting ready in advance".
>>> Also, How do I add a CSS reference to the Document built ?
>
>> You mean after the fact? I'm not sure there is a way. I'm no expert, but
> I've seen the css specified in the document, in a PI statement, such as
>> <?xml-stylesheet href="rss.css" type="text/css"?>
>
>> And googling around, I did see this "no way to associate" in the w3c
>> spec, http://www.w3.org/TR/DOM-Level-2-Style/
>
>> <quote>
>> Interface DOMImplementationCSS (introduced in DOM Level 2)
>
>> This interface allows the DOM user to create a CSSStyleSheet
>> outside the
> context of a document. There is no way to associate the new
> CSSStyleSheet with a document in DOM Level 2.
>> </quote>
>
>> HTH
>
>
|
|
|
Re: org.w3c.dom.DOMException when using jre 1.6 [message #218385 is a reply to message #218372] |
Mon, 28 July 2008 02:28   |
Eclipse User |
|
|
|
Oh yes. Absolutely right. It is fixed now.
In any case using the Document object created by,
IStructuredModel structuredModel =
StructuredModelManager.getModelManager().getModelForEdit(fil eInput.getFile());
seems to be the culprit.
The problem gets fixed if I create the document using DocumentBuilder.
The only problem is since I dont get the working model , the model can be
updated only on saving the file and not when the editor is dirty.
Thanks,
Wishwas.
David Carver wrote:
> Wishwas wrote:
>> The Doctype declaration is ignored by just setting a dummy EntityResolver.
>>
>> Also, I was able to add the CSS reference by adding a PI in the document.
>>
>> I now have another problem. When the file created thus is opened in the
>> browser, I get question marks(?) in place of spaces in the styled
>> document. I guess this is because of indentation problems.
> This probably has to do with the encoding format that the Transformer is
> serialzing the output into and the web browser is expecting. Make sure
> that your XML declaration specifies the encoding format of the file and
> that SHOULD take care of the issue.
> Dave
>> David Williams wrote:
>>
>>> On Sat, 26 Jul 2008 04:26:34 -0400, Wishwas <eclipsedevel@gmail.com>
>>> wrote:
>>
>>>> Is it possible to ignore the Doctype declaration when building the
>>>> Document
>> ?
>>
>>> Yes. There's a couple of different things you have to do, with
>> 'set-feature', if memory serves me correctly.
>>> You might want to become familiar with
>>> http://xerces.apache.org/xerces2-j/features.html and you can probably
>>> google around for examples. The two things I remember are to 1) turn
>>> validation off. 2) I think you also need to set the "entity resolver"
>>> to a "null resolver"
>> so it won't try to look-up character entities. I think, even if you
>> don't don't use entities, the parser's default entity resolver will
>> still try to read the dtd just to see if it declares any ... sort of
>> "getting ready in advance".
>>>> Also, How do I add a CSS reference to the Document built ?
>>
>>> You mean after the fact? I'm not sure there is a way. I'm no expert, but
>> I've seen the css specified in the document, in a PI statement, such as
>>> <?xml-stylesheet href="rss.css" type="text/css"?>
>>
>>> And googling around, I did see this "no way to associate" in the w3c
>>> spec, http://www.w3.org/TR/DOM-Level-2-Style/
>>
>>> <quote>
>>> Interface DOMImplementationCSS (introduced in DOM Level 2)
>>
>>> This interface allows the DOM user to create a CSSStyleSheet
>>> outside the
>> context of a document. There is no way to associate the new
>> CSSStyleSheet with a document in DOM Level 2.
>>> </quote>
>>
>>> HTH
>>
>>
|
|
| | |
Re: org.w3c.dom.DOMException when using jre 1.6 [message #218448 is a reply to message #218434] |
Tue, 29 July 2008 12:48  |
Eclipse User |
|
|
|
Originally posted by: dcarver.starstandard.org
Wishwas wrote:
> Thanks a lot David. I will surely my comments and votes to the relevant
> bugs.
>
> I am currently trying to use ther official version of Xalan instead of
> using the sun modified. I am facing some problems. Though I add the jar
> into the build path, the application still looks into the sun modified
> jar (rt.jar) and hence the problem persists.
>
> Can you please let me know if there are any other ways to make my
> application look into the external jar and not the jar in the JRE?
>
There are a couple of ways you can handle this.
1. You can set a System Property to tell JAXP which processor it should
use for the transformation.
System.setProperty("javax.xml.transform.TransformerFactory", "net.sf.saxon.TransformerFactoryImpl");
Would set it for SAXON 8 or 9. For Xalan without the XSLTC, the path
to use is: org.apache.xalan.processor.TransformerFactoryImpl
2. You can also get a transformer by directly, instantiating the
particular Transformer.
More information can be found here:
http://xml.apache.org/xalan-j/usagepatterns.html#plug
Dave
|
|
|
Goto Forum:
Current Time: Sun Jul 13 23:07:35 EDT 2025
Powered by FUDForum. Page generated in 0.12600 seconds
|