1 package net.sf.saxon.dom; 2 3 import javax.xml.parsers.DocumentBuilder ; 4 import javax.xml.parsers.DocumentBuilderFactory ; 5 import javax.xml.parsers.ParserConfigurationException ; 6 7 13 14 public class DocumentBuilderFactoryImpl extends DocumentBuilderFactory { 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 void setAttribute(String name, Object value) { 26 throw new IllegalArgumentException ("Unrecognized attribute name: " + name); 27 } 28 29 public Object getAttribute(String name) { 30 throw new IllegalArgumentException ("Unrecognized attribute name: " + name); 31 } 32 33 public DocumentBuilder newDocumentBuilder() throws ParserConfigurationException { 34 35 37 if (!isExpandEntityReferences()) { 38 throw new ParserConfigurationException ( 39 "Saxon parser always expands entity references"); 40 } 41 if (isIgnoringComments()) { 42 throw new ParserConfigurationException ( 43 "Saxon parser does not allow comments to be ignored"); 44 } 45 if (isIgnoringElementContentWhitespace()) { 46 throw new ParserConfigurationException ( 47 "Saxon parser does not allow whitespace in element content to be ignored"); 48 } 49 if (!isNamespaceAware()) { 50 throw new ParserConfigurationException ( 51 "Saxon parser is always namespace aware"); 52 } 53 if (isValidating()) { 54 throw new ParserConfigurationException ( 55 "Saxon parser is non-validating"); 56 } 57 58 return new DocumentBuilderImpl(); 59 } 60 61 96 public void setFeature(String name, boolean value) throws ParserConfigurationException { 97 if (name.equals(javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING) && !value) { 98 } else { 100 throw new ParserConfigurationException ("Unsupported feature or value: " + name); 101 } 102 } 103 104 121 public boolean getFeature(String name) throws ParserConfigurationException { 122 if (name.equals(javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING)) { 123 return false; 124 } else { 125 throw new ParserConfigurationException ("Unsupported feature: " + name); 126 } 127 } 128 129 } 130 131 132 | Popular Tags |