You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by "Amthauer, Heiner" <He...@t-systems.com> on 2002/10/16 15:30:33 UTC

AW: EntityResolver (was: Error parsing files, when filename conta ins german umlauts)

Hi there!

Well, if the saxParser would behave like you have pointed out, I would have
a bunch of other questions. However, your answer gave me the right hint. As
shown below, I did use the method saxParser.parse(file, handler) and my
content handler is derived from DefaultHandler. Since the DefaultHandler
implements an EntityResolver, the setting setEntityResolver(...) is ignored.
Now, all I had to do was overriding the method resolveEntity(...) and that's
it.

Thanx for your patients.

greetings
Heiner

-----Ursprüngliche Nachricht-----
Von: Sander Bos [mailto:sander@x-hive.com]
Gesendet am: Mittwoch, 16. Oktober 2002 14:36
An: xerces-j-user@xml.apache.org
Betreff: RE: EntityResolver (was: Error parsing files, when filename
contains german umlauts)


Hi Heiner,

> (Xerces 2.0.2, JRE1.3.1)
> 
> I discovered, that the early mentioned problem can be nicely 
> avoided, when
> using an entity resolver. I set the resolver with the following code:
> 
> ...
> org.xml.sax.SAXParser saxParser =
> SAXParserFactory.newInstance().newSAXParser();
> ...
> saxParser.getXMLReader().setEntityResolver(new MyEntityResolver());
> saxParser.parse(file, this);
> 
> However, using this code, the instance of MyEntityResolver is 
> never accessed
> in any way. Whats wrong?

Since you ask it every 5 minutes, let me as a lurker make an attempt to
answer your question. I notice that you set the entity resolver on the
xml-reader but parse on the parser. Perhaps you could try

XMLReader myReader = saxParser.getXMLReader();
myReader.setEntityResolver(new MyEntityResolver());
myReader.setContentHandler(this);
myReader.parse(file);

or something like that.

I did not try this (although our entity resolvers in Xerces work like a
charm), but looking at the Xerces source code for 5 seconds (so not a
definite answer) I would say saxParser.parse(...) does not use the xml
reader object on which you set the entity resolver.

Kind regards,

--Sander.


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org