I don't know how dom4j works, but in JAXP you attach the EntityResolver to the parser which is going to parse the document. I'm surprised you can attach an EntityResolver in dom4j to a Document, I would have thought it was the output of a parser. But evidently it isn't.
Is your EntityResolver being called at all? Perhaps your string comparison isn't quite correct.
Thank you very much for your prompt reply, Paul, and Yves also.
I had initially put a big debug statement outside of the if in the EntityResolver, but as you suspected it isn't getting called at all, so it isn't an incorrect if statement since the code is never getting called.
I was under the impression that perhaps supplying the dom4j Document object itself with an EntityResolver somehow was detected by the Transformer, or the parser the Transormer is using behind the scenes I suppose, and was used to resolve the ID locally.
It makes sense from a theoretical standpoint, but it is surprising as Paul said. What didn't help much was there is not much documentation on what the setEntityResolver method is supposed to do. I wouldn't be shocked if it turns out that I'm just using it incorrectly, but I don't know what else to do. There isn't a way of giving a TransformerFactory or a Transformer your own EntityResolver.
I tried playing with a URIResolver and I supplied that to the TransfomerFactory but that also isn't getting called which makes me think that the underlying implementation, xalan, is simply ignoring resolvers all together.
Is there a better way of applying the transformation needed without depending on a specific implementation? If not, which implementation do you suggest I use and how?
Thanks again guys.
Joined: Aug 31, 2008
The EntityResolver has always worked for me with DOM4J(When using DOM4J with or without JAXP). What I always do is pass the EntityResolver in a SAXReader before creating the DOM4J document:
Joined: Sep 26, 2008
Thank you for replying again, Yves.
I ended up giving up on trying to figure out what the point of dom4j's Document.setEntityResolver method and instead went with a similar approach to what you suggested.
Then I get a Transformer instance through TransformerHandler etc.
I now KNOW that my entity resolver is getting called and that it is functioning properly.
Thanks for all your time and assistance. [ October 01, 2008: Message edited by: Mike Wallace ]