Hi Manfred,

I'm sorry the code wasn't quite correct. The EntityResolver is set on
the parser's XMLReader, not on the parser itself:

(def parser (.newSAXParser (SAXParserFactory/newInstance))
(.setEntityResolver (.getXMLReader parser) resolver)

You don't need any external jars: all the classes and interfaces are
in the JRE.

On Aug 1, 5:31 am, Manfred Lotz <manfred.l...@arcor.de> wrote:
> Hi Randy,
> Thanks for your help. A bit late my answer because in the meantime I was
> on vacation and only now found the time to pursue it further.
>
> On Tue, 29 Jun 2010 18:53:30 -0700 (PDT)
>
>
>
>
>
> RandyHudson <randy_hud...@mac.com> wrote:
> > Yes, you can do this by defining an EntityResolver that corrects the
> > bad system id, define a SAXParser that uses that resolver, and pass
> > the parser into the xml/parse call. Something like this:
>
> > (import
> >   '[javax.xml.parsers SAXParserFactory]
> >   '[org.xml.sax EntityResolver InputSource])
>
> > (def resolver
> >   (proxy [EntityResolver] []
> >     (resolveEntity [public-id system-id]
> >       (InputSource.
> >         (if (= system-id the-bad-system-id)
> >           the-good-system-id
> >           system-id)))))
>
> > (def parser
> >   (doto (.newSAXParser (SAXParserFactory/newInstance))
> >     (.setEntityResolver resolver)))
>
> > (defn parse-xml [source] (xml/parse source parser))
>
> The problem I have with it is that I don't seem to find the right jar.
> I get an exception like this:
>
> Exception in thread "main" java.lang.IllegalArgumentException: No
> matching method found: setEntityResolver for class
> com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl (test.clj:14)
>
> I tried sax2r2.jar fromhttp://www.saxproject.org/.
>
> --  
> Manfred

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to