KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > icl > saxon > om > DocumentBuilderFactoryImpl


1 package com.icl.saxon.om;
2
3 import javax.xml.parsers.DocumentBuilderFactory JavaDoc;
4 import javax.xml.parsers.DocumentBuilder JavaDoc;
5 import javax.xml.parsers.ParserConfigurationException JavaDoc;
6
7 /**
8 * Implementation of JAXP 1.1 DocumentBuilderFactory. To build a Document using
9 * Saxon, set the system property javax.xml.parsers.DocumentBuilderFactory to
10 * "com.icl.saxon.om.DocumentBuilderFactoryImpl" and then call
11 * DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(InputSource);
12 */

13
14 public class DocumentBuilderFactoryImpl extends DocumentBuilderFactory JavaDoc {
15     
16     public DocumentBuilderFactoryImpl() {
17         setCoalescing(true);
18         setExpandEntityReferences(true);
19         setIgnoringComments(false);
20         setIgnoringElementContentWhitespace(false);
21         setNamespaceAware(true);
22         setValidating(false);
23     }
24
25     public Object JavaDoc getAttribute(String JavaDoc name) {
26         throw new IllegalArgumentException JavaDoc("Unrecognized attribute name: " + name);
27     }
28     
29     public DocumentBuilder JavaDoc newDocumentBuilder() throws ParserConfigurationException JavaDoc {
30
31         // Check that configuration options are all available
32

33         if (!isExpandEntityReferences()) {
34             throw new ParserConfigurationException JavaDoc(
35                 "Saxon parser always expands entity references");
36         }
37         if (isIgnoringComments()) {
38             throw new ParserConfigurationException JavaDoc(
39                 "Saxon parser does not allow comments to be ignored");
40         }
41         if (isIgnoringElementContentWhitespace()) {
42             throw new ParserConfigurationException JavaDoc(
43                 "Saxon parser does not allow whitespace in element content to be ignored");
44         }
45         if (!isNamespaceAware()) {
46             throw new ParserConfigurationException JavaDoc(
47                 "Saxon parser is always namespace aware");
48         }
49         if (isValidating()) {
50             throw new ParserConfigurationException JavaDoc(
51                 "Saxon parser is non-validating");
52         }
53
54         return new DocumentBuilderImpl();
55     }
56     
57     public void setAttribute(String JavaDoc name, Object JavaDoc value) {
58         throw new IllegalArgumentException JavaDoc("Unrecognized attribute name: " + name);
59     }
60
61 }
62     
Popular Tags