Re: JDK1.5 Xpath problem





abcd_68@xxxxxxxxxxx wrote:


However, if I unplug the network, I get (after a *long* timeout) a
java.net.SocketException. I looked around and I found out that I have
to define a class implementing EntityResolver to change the default
behaviour (i.e., fetch the DTD over the net) and obtain an InputSource
from it.

Now my problem is: How do I do it? Neither in javax.xml.xpath.XPath nor
in javax.xml.xpath.XPathFactory did I find an appropriate place nor did
I find a method to gain access to the underlying SAX parser.

I don't know how to do it if you pass an InputSource to the evaluate method. You can however also pass in an object where the object is a W3C DOM Node. And if you look at DocumentBuilder it has a method setEntityResolver. That should allow you to create a DOM Document without fetching the DTD from the remote host, and you can then pass in the Document to the evaluate method. I am not sure a DOM Node/Document is the most efficient data structure to do XPath on but at least that approach might work for your problem.

--

Martin Honnen
http://JavaScript.FAQTs.com/
.



Relevant Pages

  • Re: XML generator
    ... I have done a similar exercise with DTD; ... - use transform on DOM to get resulting XML ... > bunch of Java Objects and spit out an XML which follows the template? ...
    (comp.lang.java.programmer)
  • Re: Fixed attribute and multiple namespaces issue (Xerces-C 2.7.0)
    ... When default attribute values are defined in the DTD, the DOM is expected to reinstantiate them with the default value when an explicit setting is removed. ... Basically, if there is a default defined in the DTD or Schema, it really is a default and you can't remove the attribute entirely. ...
    (comp.text.xml)
  • Re: xml.dom.minidom question
    ... from xml.dom.minidom import parse ... dom = makeChangesToMyDomTree ... You should verify that this works properly but it should. ... at one point observing a problem with a document that declared a DTD, ...
    (comp.lang.python)