Hello Ittay,

A Document's DOMConfiguration [1] is used when 
Document.normalizeDocument() is invoked. I wouldn't assume that Xalan 
calls that method so you likely need to call it yourself. Probably worth 
noting that in-memory DTD validation using normalizeDocument() was 
completely broken prior to Xerces 2.8.0. I spent a couple weeks last year 
fixing many of the major bugs but didn't get around to all of them before 
the release (though I hope to stamp the rest out before Xerces 2.9). I've 
never checked whether getElementById() works after calling 
normalizeDocument() with DTD validation enabled but glancing over the 
current code I suspect it doesn't.

[1] 
http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#Document3-domConfig

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: [EMAIL PROTECTED]
E-mail: [EMAIL PROTECTED]

Ittay Dror <[EMAIL PROTECTED]> wrote on 04/09/2006 09:27:15 AM:

> i've turned on the schema and validation features, and set a schema 
> to my html, but getElementById still doesn't work (i'm using the 
> latest of xerces, xalan and tagsoup, xhtml1-transitional.dtd and 
> entities are saved locally.
> 
> this is my html:
> <html>
> <body>
>         <div id="foo">hello</div>
> </body>
> </html>
> 
> this is my code:
> import org.apache.xalan.xsltc.trax.SAX2DOM;
> import org.apache.xerces.jaxp.DocumentBuilderFactoryImpl;
> import org.ccil.cowan.tagsoup.Parser;
> import org.w3c.dom.DOMConfiguration;
> import org.w3c.dom.Document;
> import org.xml.sax.InputSource;
> import org.xml.sax.SAXException;
> 
> public class Test {
>    public static class HTMLDocumentBuilderFactory extends 
> DocumentBuilderFactoryImpl {
>       public HTMLDocumentBuilderFactory() throws SAXException, 
> ParserConfigurationException {
>             setValidating(true);
>             setFeature("http://apache.org/xml/features/validation/schema
> ", true);
>             setFeature("http://xml.org/sax/features/validation";, true);
>       }
>    }
> 
>  public final static void main(String[] args) throws Exception {
> 
>   Parser p = new Parser();
>   System.setProperty("javax.xml.parsers.DocumentBuilderFactory", 
> HTMLDocumentBuilderFactory.class.getName());
>   SAX2DOM sax2dom = new SAX2DOM();
>   Document doc = (Document)sax2dom.getDOM();
>   DOMConfiguration config = doc.getDomConfig();
>   config.setParameter("schema-type","http://www.w3.org/TR/REC-xml";);
>   config.setParameter("schema-location", 
"/tmp/xhtml1-transitional.dtd");
>   p.setContentHandler(sax2dom);
> 
>   InputSource docsrc = new InputSource("/tmp/test.html");
>   p.parse(docsrc);
> 
>   System.out.println(doc.getElementById("foo"));
>  }
> }
> 
> thanx, 
> ittay
> 
> -- 
> ===================================
> Ittay Dror 
> openQRM Team Leader, 
> R&D, Qlusters Inc.
> [EMAIL PROTECTED]
> +972-3-6081994 Fax: +972-3-6081841
> 
> http://www.openQRM.org
> - Keeps your Data-Center Up and Running
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to