Thanks for the response. If i understand you correctly, i should do this:

           XMLReader r = XMLReaderFactory.createXMLReader();
           MyXMLFilter filter = new MyXMLFilter();
           filter.setParent(r);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
           DocumentBuilder db = dbf.newDocumentBuilder();
           Document d = db.newDocument();
TransformerFactory tf = TransformerFactory.newInstance();
           Transformer t = tf.newTransformer();
t.transform(new SAXSource(filter, new InputSource(srcHtml)), new DOMResult(d));

and i should expect the

skippedEntity(String entity)

method of my filter to get called when a   is found.

However this method is never called for me. Am I missing something?


Michael Glavassevich wrote:

Hi,

You're making assumptions about the implementation which aren't required and certainly aren't true for Xerces. There is no underlying SAX parser. The DOM is built from XNI events. You cannot plug SAX handlers into it.

If you want to build a SAX filter for replacing skipped entities [1] and then build a DOM from that, you could try using the Transformer API instead (i.e. javax.xml.transform.Transformer.transform(SAXSource, DOMResult)) where the SAXSource contains your XMLFilter [2] which does this resolution.

Thanks.

[1] http://xerces.apache.org/xerces2-j/javadocs/api/org/xml/sax/ContentHandler.html#skippedEntity(java.lang.String) <http://xerces.apache.org/xerces2-j/javadocs/api/org/xml/sax/ContentHandler.html#skippedEntity%28java.lang.String%29> [2] http://xerces.apache.org/xerces2-j/javadocs/api/org/xml/sax/XMLFilter.html

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrgla...@ca.ibm.com
E-mail: mrgla...@apache.org

"dbros...@mebigfatguy.com" <dbros...@mebigfatguy.com> wrote on 11/08/2009 12:52:53 PM:

> I want to be able to resolve unknown entities while using
> DocumentBuilder.parse. I see sax has a LexicalHandler for this purpose,
> and i'd assume that there's some way to tell DOM to pass a handler into
> the underlying sax parser that builds the dom, but i haven't found it.
> Could someone point me in the right direction?
>
> thanks.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscr...@xerces.apache.org
> For additional commands, e-mail: j-users-h...@xerces.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscr...@xerces.apache.org
For additional commands, e-mail: j-users-h...@xerces.apache.org

Reply via email to