Methods Summary |
---|
public org.w3c.dom.DOMImplementation | getDOMImplementation()
return DOMImplementationImpl.getDOMImplementation();
|
final com.sun.org.apache.xerces.internal.parsers.DOMParser | getDOMParser()
return domParser;
|
public javax.xml.validation.Schema | getSchema()Get a reference to the the GrammarCache being used by
the XML processor.
If no cache is being used, null is returned.
return grammar;
|
public boolean | isNamespaceAware()
try {
return domParser.getFeature(Constants.SAX_FEATURE_PREFIX +
Constants.NAMESPACES_FEATURE);
} catch (SAXException x) {
throw new IllegalStateException(x.getMessage());
}
|
public boolean | isValidating()
try {
return domParser.getFeature(Constants.SAX_FEATURE_PREFIX +
Constants.VALIDATION_FEATURE);
} catch (SAXException x) {
throw new IllegalStateException(x.getMessage());
}
|
public boolean | isXIncludeAware()
return xincludeAware;
|
public org.w3c.dom.Document | newDocument()Non-preferred: use the getDOMImplementation() method instead of this
one to get a DOM Level 2 DOMImplementation object and then use DOM
Level 2 methods to create a DOM Document object.
return new com.sun.org.apache.xerces.internal.dom.DocumentImpl();
|
public org.w3c.dom.Document | parse(org.xml.sax.InputSource is)
if (is == null) {
throw new IllegalArgumentException(
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
"jaxp-null-input-source", null));
}
if (er != null) {
domParser.setEntityResolver(er);
}
if (eh != null) {
domParser.setErrorHandler(eh);
}
domParser.parse(is);
return domParser.getDocument();
|
public void | reset()Reset this DocumentBuilder to its original configuration.
DocumentBuilder is reset to the same state as when it was created with
{@link DocumentBuilderFactory#newDocumentBuilder()}.
reset() is designed to allow the reuse of existing DocumentBuilder s
thus saving resources associated with the creation of new DocumentBuilder s.
The reset DocumentBuilder is not guaranteed to have the same {@link EntityResolver} or {@link ErrorHandler}
Object s, e.g. {@link Object#equals(Object obj)}. It is guaranteed to have a functionally equal
EntityResolver and ErrorHandler .
if(domParser != null){
try{
//we dont need to worry about any properties being set on this object because
//DocumentBuilder doesn't provide any way to set the properties
//once it is created.
domParser.reset();
}
//xxx: underlying implementation reset throws XNIException what should we do in this case ?
//other question is why underlying implementation should throw an exception is it because
//of properties being set.. if there was any propery that is not being supported
//exception would have been thrown when setting it on the underlying implementation.
catch(XNIException ex){
//coninue.
}
}
|
private void | setDocumentBuilderFactoryAttributes(java.util.Hashtable dbfAttrs)Set any DocumentBuilderFactory attributes of our underlying DOMParser
Note: code does not handle possible conflicts between DOMParser
attribute names and JAXP specific attribute names,
eg. DocumentBuilderFactory.setValidating()
if (dbfAttrs == null) {
// Nothing to do
return;
}
// TODO: reroute those properties to use new JAXP1.3 API. -KK
for (Enumeration e = dbfAttrs.keys(); e.hasMoreElements();) {
String name = (String)e.nextElement();
Object val = dbfAttrs.get(name);
if (val instanceof Boolean) {
// Assume feature
if (Constants.FEATURE_SECURE_PROCESSING.equals(name)){
enableSP = ((Boolean)val).booleanValue();
}else
domParser.setFeature(name, ((Boolean)val).booleanValue());
} else {
// Assume property
if (JAXP_SCHEMA_LANGUAGE.equals(name)) {
// JAXP 1.2 support
//None of the properties will take effect till the setValidating(true) has been called
if ( W3C_XML_SCHEMA.equals(val) ) {
if( isValidating() ) {
domParser.setFeature(
Constants.XERCES_FEATURE_PREFIX +
Constants.SCHEMA_VALIDATION_FEATURE, true);
//also set the schema full checking to true.
domParser.setFeature(Constants.XERCES_FEATURE_PREFIX +
Constants.SCHEMA_FULL_CHECKING,
true);
// this should allow us not to emit DTD errors, as expected by the
// spec when schema validation is enabled
domParser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
}
}
} else if(JAXP_SCHEMA_SOURCE.equals(name)){
if( isValidating() ) {
String value=(String)dbfAttrs.get(JAXP_SCHEMA_LANGUAGE);
if(value !=null && W3C_XML_SCHEMA.equals(value)){
domParser.setProperty(name, val);
}else{
throw new IllegalArgumentException(
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
"jaxp-order-not-supported",
new Object[] {JAXP_SCHEMA_LANGUAGE, JAXP_SCHEMA_SOURCE}));
}
}
}
/*else if(name.equals(Constants.ENTITY_EXPANSION_LIMIT)){
String elimit = (String)value;
if(elimit != null && elimit != ""){
int val = Integer.parseInt(elimit);
secureProcessing.setEntityExpansionLimit(val);
}
}else if(name.equals(Constants.MAX_OCCUR_LIMIT)){
String mlimit = (String)value;
if(mlimit != null && mlimit != ""){
int val = Integer.parseInt(mlimit);
secureProcessing.setMaxOccurNodeLimit(val);
}
}*/ else {
// Let Xerces code handle the property
domParser.setProperty(name, val);
}
}
}
|
public void | setEntityResolver(org.xml.sax.EntityResolver er)
this.er = er;
|
public void | setErrorHandler(org.xml.sax.ErrorHandler eh)
// If app passes in a ErrorHandler of null, then ignore all errors
// and warnings
this.eh = (eh == null) ? new DefaultHandler() : eh;
|