Dear Roger,
My code is very similar. However, I've never run into this problem, since we do not reference the DTDs. But why not actually give it the correct URI and download the DTD externally? Or else go ahead and manually download the DTD locally so you have it there for the parser? I have a suspicion, that if you provide the DTD URI with the XML, the parser (depending on the implementation) my want it, whether you tell it to turn off the validation or not...
Sorry, wish I had more info.
Greg
-----Original Message-----
From: Paul Franz [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 30, 2003 9:28 AM
To: jdjlist
Subject: [jdjlist] Re: XML Question
Shouldn't:
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
docBuilderFactory.setValidating(false);
be:
docBuilderFactory.setValidating(false);
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
???
Paul Franz
----- Original Message -----
From: "Roger Lacroix" <[EMAIL PROTECTED]>
To: "jdjlist" <[EMAIL PROTECTED]>
Sent: Thursday, October 30, 2003 12:18 PM
Subject: [jdjlist] XML Question
> All:
>
> I have the following problem:
>
> I am trying to do a quick tree-view (JTree) display of a XML message. I
read
> the message from the queue, parse it, create nodes and display the tree.
>
> If the XML does NOT reference a DTD (<!DOCTYPE ...) everything works just
fine.
> But if the XML does reference a DTD then it throws an error
> (org.xml.sax.SAXParseException: Relative URI "xxxxxxx.dtd"; can not be
resolved
> without a base URI.).
>
> So, I thought, "oh, it is trying to validate the XML with the DTD" - but I
do
> NOT have the DTD locally. So, I tried to turn validating off with
setValidating
> (false) but I still get the error.
>
> Here is a code snippet:
>
> DocumentBuilderFactory docBuilderFactory =
DocumentBuilderFactory.newInstance
> ();
> DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
>
> docBuilderFactory.setValidating(false);
>
> StringReader stringreader = new StringReader(buffer.toString());
> InputSource in = new InputSource(stringreader);
>
> Document doc = docBuilder.parse(in);
>
> Element root = doc.getDocumentElement();
> root.normalize();
>
> DefaultMutableTreeNode top = createTreeNode(root);
>
> m_model.setRoot(top);
> m_tree.treeDidChange();
>
>
> What can I do to stop the parser from attemping to validate against the
DTD?
> (Because I don't have a local copy of the DTD.)
>
> Any help would be appreciated.
>
> Regards,
> Roger Lacroix
>
>
> ---
> You are currently subscribed to jdjlist as: [EMAIL PROTECTED]
> To unsubscribe send a blank email to
[EMAIL PROTECTED]
> http://www.sys-con.com/fusetalk
> To unsubscribe from all mailing lists, click:
>
http://sys-con.com/[EMAIL PROTECTED]
on.com
---
You are currently subscribed to jdjlist as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
http://www.sys-con.com/fusetalk
To unsubscribe from all mailing lists, click:
http://sys-con.com/[EMAIL PROTECTED]
You are currently subscribed to jdjlist as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
http://www.sys-con.com/fusetalk To unsubscribe from all mailing lists, click:
http://sys-con.com/[EMAIL PROTECTED]
