javax.xml.parsers

Class DocumentBuilderFactory

Known Direct Subclasses:
DocumentBuilderFactoryImpl

public abstract class DocumentBuilderFactory
extends Object

Defines a factory API that enables applications to obtain a parser that produces DOM object trees from XML documents.

Constructor Summary

DocumentBuilderFactory()

Method Summary

abstract Object
getAttribute(String name)
Allows the user to retrieve specific attributes on the underlying implementation.
abstract boolean
getFeature(String name)
Get the state of the named feature.
Schema
getSchema()
Gets the Schema object specified through the setSchema(Schema schema) method.
boolean
isCoalescing()
Indicates whether or not the factory is configured to produce parsers which converts CDATA nodes to Text nodes and appends it to the adjacent (if any) Text node.
boolean
isExpandEntityReferences()
Indicates whether or not the factory is configured to produce parsers which expand entity reference nodes.
boolean
isIgnoringComments()
Indicates whether or not the factory is configured to produce parsers which ignores comments.
boolean
isIgnoringElementContentWhitespace()
Indicates whether or not the factory is configured to produce parsers which ignore ignorable whitespace in element content.
boolean
isNamespaceAware()
Indicates whether or not the factory is configured to produce parsers which are namespace aware.
boolean
isValidating()
Indicates whether or not the factory is configured to produce parsers which validate the XML content during parse.
boolean
isXIncludeAware()
Get state of XInclude processing.
abstract DocumentBuilder
newDocumentBuilder()
Creates a new instance of a DocumentBuilder using the currently configured parameters.
static DocumentBuilderFactory
newInstance()
Obtain a new instance of a DocumentBuilderFactory.
abstract void
setAttribute(String name, Object value)
Allows the user to set specific attributes on the underlying implementation.
void
setCoalescing(boolean coalescing)
Specifies that the parser produced by this code will convert CDATA nodes to Text nodes and append it to the adjacent (if any) text node.
void
setExpandEntityReferences(boolean expandEntityRef)
Specifies that the parser produced by this code will expand entity reference nodes.
abstract void
setFeature(String name, boolean value)
Set a feature for this DocumentBuilderFactory and DocumentBuilders created by this factory.
void
setIgnoringComments(boolean ignoreComments)
Specifies that the parser produced by this code will ignore comments.
void
setIgnoringElementContentWhitespace(boolean whitespace)
Specifies that the parsers created by this factory must eliminate whitespace in element content (sometimes known loosely as 'ignorable whitespace') when parsing XML documents (see XML Rec 2.10).
void
setNamespaceAware(boolean awareness)
Specifies that the parser produced by this code will provide support for XML namespaces.
void
setSchema(Schema schema)
Set the Schema to be used by parsers created from this factory.
void
setValidating(boolean validating)
Specifies that the parser produced by this code will validate documents as they are parsed.
void
setXIncludeAware(boolean state)
Set state of XInclude processing.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

DocumentBuilderFactory

protected DocumentBuilderFactory()

Method Details

getAttribute

public abstract Object getAttribute(String name)
            throws IllegalArgumentException
Allows the user to retrieve specific attributes on the underlying implementation.
Parameters:
name - The name of the attribute.
Returns:
value The value of the attribute.
Throws:
IllegalArgumentException - thrown if the underlying implementation doesn't recognize the attribute.
Usages and Demos :

View More Examples of getAttribute(String name)
   1: import javax.xml.XMLConstants;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5:     void setAttr(boolean setSrc) {
   6:         DocumentBuilderFactory docBFactory = DocumentBuilderFactory.newInstance();
   7:         Schema sch = createSchema();
   8:         docBFactory.setSchema(sch);
   9:         docBFactory.setNamespaceAware(true);

View Full Code Here
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5: 
   6: public class DocumentBuilderFactoryImpl extends DocumentBuilderFactory
   7: {
   8:         ...
   9: 
  10:    private DocumentBuilderFactory delegate;
  11: 
  12:         ...
  13:    {
  14:       return delegate.getAttribute(name);

View Full Code Here
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5: 
   6: public class ValidatingDocumentBuilderFactory extends DocumentBuilderFactory
   7: {
   8:         ...
   9:     protected Schema _Schema;
  10:     protected DocumentBuilderFactory _WrappedFactory;
  11:     
  12:         ...
  13:     {
  14:         return _WrappedFactory.getAttribute(name);

View Full Code Here
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5: 
   6: public class DocumentBuilderFactoryImpl extends DocumentBuilderFactory {
   7:     
   8:         ...
   9:     private final DocumentBuilderFactory core;
  10: 
  11:         ...
  12:             }
  13:         return core.getAttribute(name);

View Full Code Here

getFeature

public abstract boolean getFeature(String name)
            throws ParserConfigurationException
Get the state of the named feature.

Feature names are fully qualified URIs. Implementations may define their own features. An ParserConfigurationException is thrown if this DocumentBuilderFactory or the DocumentBuilders it creates cannot support the feature. It is possible for an DocumentBuilderFactory to expose a feature value but be unable to change its state.

Parameters:
name - Feature name.
Returns:
State of the named feature.
Throws:
ParserConfigurationException - if this DocumentBuilderFactory or the DocumentBuilders it creates cannot support this feature.
Usages and Demos :

View More Examples of getFeature(String name)
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5: 
   6: public class DocumentBuilderFactoryImpl extends DocumentBuilderFactory
   7: {
   8:         ...
   9: 
  10:    private DocumentBuilderFactory delegate;
  11: 
  12:         ...
  13:    {
  14:       return delegate.getFeature(name);

View Full Code Here
   1:     
   2:     DocumentBuilderFactory dbf = null;
   3:     
   4:         ...
   5:         try{
   6:             dbf = DocumentBuilderFactory.newInstance();
   7:             DocumentBuilder parser = dbf.newDocumentBuilder();
   8:         ...
   9:         try{
  10:             dbf = DocumentBuilderFactory.newInstance();
  11:             dbf.setNamespaceAware(true);
  12:         ...
  13:             dbf = DocumentBuilderFactory.newInstance();
  14:             assertTrue("Default value for secureProcessing feature should be true",dbf.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING));

View Full Code Here

getSchema

public Schema getSchema()
Gets the Schema object specified through the setSchema(Schema schema) method.
Returns:
the Schema object that was last set through the setSchema(Schema) method, or null if the method was not invoked since a SAXParserFactory is created.
Throws:
UnsupportedOperationException - For backward compatibility, when implementations for earlier versions of JAXP is used, this exception will be thrown.
Since:
1.5

isCoalescing

public boolean isCoalescing()
Indicates whether or not the factory is configured to produce parsers which converts CDATA nodes to Text nodes and appends it to the adjacent (if any) Text node.
Returns:
true if the factory is configured to produce parsers which converts CDATA nodes to Text nodes and appends it to the adjacent (if any) Text node; false otherwise.
Usages and Demos :

View More Examples of isCoalescing()
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5: 
   6: public class ValidatingDocumentBuilderFactory extends DocumentBuilderFactory
   7: {
   8:         ...
   9:     protected Schema _Schema;
  10:     protected DocumentBuilderFactory _WrappedFactory;
  11:     
  12:         ...
  13:     public boolean isCoalescing()
  14:     { return _WrappedFactory.isCoalescing(); }

View Full Code Here
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5: 
   6: public class DocumentBuilderFactoryImpl extends DocumentBuilderFactory {
   7:     
   8:         ...
   9:     private final DocumentBuilderFactory core;
  10: 
  11:         ...
  12:     public boolean isCoalescing() {
  13:         return core.isCoalescing();

View Full Code Here
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5: 
   6:     private DocumentBuilderFactory dbf;
   7: 
   8:         ...
   9: 
  10:     DocumentBuilderImpl(DocumentBuilderFactory dbf)
  11:         throws ParserConfigurationException
  12:         ...
  13:         builder.setIgnoreComments(dbf.isIgnoringComments());
  14:         builder.setPutCDATAIntoText(dbf.isCoalescing());

View Full Code Here

isExpandEntityReferences

public boolean isExpandEntityReferences()
Indicates whether or not the factory is configured to produce parsers which expand entity reference nodes.
Returns:
true if the factory is configured to produce parsers which expand entity reference nodes; false otherwise.
Usages and Demos :

View More Examples of isExpandEntityReferences()
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5: 
   6: public class ValidatingDocumentBuilderFactory extends DocumentBuilderFactory
   7: {
   8:         ...
   9:     protected Schema _Schema;
  10:     protected DocumentBuilderFactory _WrappedFactory;
  11:     
  12:         ...
  13:     public boolean isExpandEntityReference()
  14:     { return _WrappedFactory.isExpandEntityReferences(); }

View Full Code Here
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5: 
   6: public class DocumentBuilderFactoryImpl extends DocumentBuilderFactory {
   7:     
   8:         ...
   9:     private final DocumentBuilderFactory core;
  10: 
  11:         ...
  12:     public boolean isExpandEntityReference() {
  13:         return core.isExpandEntityReferences();

View Full Code Here
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5: 
   6:     private DocumentBuilderFactory dbf;
   7: 
   8:         ...
   9: 
  10:     DocumentBuilderImpl(DocumentBuilderFactory dbf)
  11:         throws ParserConfigurationException
  12:         ...
  13:         builder.setIgnoreWhitespace(dbf.isIgnoringElementContentWhitespace());
  14:         builder.setExpandEntityReferences(dbf.isExpandEntityReferences());

View Full Code Here
   1: 
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import java.io.FileNotFoundException;
   4:         ...
   5: 
   6:   public void setConfig(DocumentBuilderFactory factory)
   7:   {
   8:         ...
   9:     _isCoalescing = factory.isCoalescing();
  10:     setExpandEntities(factory.isExpandEntityReferences());
  11:     setSkipComments(factory.isIgnoringComments());

View Full Code Here
   1: 
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import java.io.FileNotFoundException;
   4:         ...
   5: 
   6:   public void setConfig(DocumentBuilderFactory factory)
   7:   {
   8:         ...
   9:     _isCoalescing = factory.isCoalescing();
  10:     setExpandEntities(factory.isExpandEntityReferences());
  11:     setSkipComments(factory.isIgnoringComments());

View Full Code Here

isIgnoringComments

public boolean isIgnoringComments()
Indicates whether or not the factory is configured to produce parsers which ignores comments.
Returns:
true if the factory is configured to produce parsers which ignores comments; false otherwise.
Usages and Demos :

View More Examples of isIgnoringComments()
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5: 
   6: public class ValidatingDocumentBuilderFactory extends DocumentBuilderFactory
   7: {
   8:         ...
   9:     protected Schema _Schema;
  10:     protected DocumentBuilderFactory _WrappedFactory;
  11:     
  12:         ...
  13:     public boolean isIgnoringComments()
  14:     { return _WrappedFactory.isIgnoringComments(); }

View Full Code Here
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5: 
   6: public class DocumentBuilderFactoryImpl extends DocumentBuilderFactory {
   7:     
   8:         ...
   9:     private final DocumentBuilderFactory core;
  10: 
  11:         ...
  12:     public boolean isIgnoringComments() {
  13:         return core.isIgnoringComments();

View Full Code Here
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5: 
   6:     private DocumentBuilderFactory dbf;
   7: 
   8:         ...
   9: 
  10:     DocumentBuilderImpl(DocumentBuilderFactory dbf)
  11:         throws ParserConfigurationException
  12:         ...
  13:         builder.setExpandEntityReferences(dbf.isExpandEntityReferences());
  14:         builder.setIgnoreComments(dbf.isIgnoringComments());

View Full Code Here
   1: 
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import java.io.FileNotFoundException;
   4:         ...
   5: 
   6:   public void setConfig(DocumentBuilderFactory factory)
   7:   {
   8:         ...
   9:     setExpandEntities(factory.isExpandEntityReferences());
  10:     setSkipComments(factory.isIgnoringComments());
  11:     setSkipWhitespace(factory.isIgnoringElementContentWhitespace());

View Full Code Here
   1: 
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import java.io.FileNotFoundException;
   4:         ...
   5: 
   6:   public void setConfig(DocumentBuilderFactory factory)
   7:   {
   8:         ...
   9:     setExpandEntities(factory.isExpandEntityReferences());
  10:     setSkipComments(factory.isIgnoringComments());
  11:     setSkipWhitespace(factory.isIgnoringElementContentWhitespace());

View Full Code Here

isIgnoringElementContentWhitespace

public boolean isIgnoringElementContentWhitespace()
Indicates whether or not the factory is configured to produce parsers which ignore ignorable whitespace in element content.
Returns:
true if the factory is configured to produce parsers which ignore ignorable whitespace in element content; false otherwise.
Usages and Demos :

View More Examples of isIgnoringElementContentWhitespace()
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5: 
   6: public class ValidatingDocumentBuilderFactory extends DocumentBuilderFactory
   7: {
   8:         ...
   9:     protected Schema _Schema;
  10:     protected DocumentBuilderFactory _WrappedFactory;
  11:     
  12:         ...
  13:     public boolean isIgnoringElementContentWhitespace()
  14:     { return _WrappedFactory.isIgnoringElementContentWhitespace(); }

View Full Code Here
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5: 
   6:     private static DocumentBuilderFactory documentBuilderFactory;
   7: 
   8:         ...
   9:                 || documentBuilderFactory.isNamespaceAware() != namespace
  10:                 || documentBuilderFactory.isIgnoringElementContentWhitespace() != whitespace) {
  11:             documentBuilderFactory = DocumentBuilderFactory.newInstance();

View Full Code Here
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5: 
   6: public class DocumentBuilderFactoryImpl extends DocumentBuilderFactory {
   7:     
   8:         ...
   9:     private final DocumentBuilderFactory core;
  10: 
  11:         ...
  12:     public boolean isIgnoringElementContentWhitespace() {
  13:         return core.isIgnoringElementContentWhitespace();

View Full Code Here
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5: 
   6:     private DocumentBuilderFactory dbf;
   7: 
   8:         ...
   9: 
  10:     DocumentBuilderImpl(DocumentBuilderFactory dbf)
  11:         throws ParserConfigurationException
  12:         ...
  13: 
  14:         builder.setIgnoreWhitespace(dbf.isIgnoringElementContentWhitespace());

View Full Code Here
   1: 
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import java.io.FileNotFoundException;
   4:         ...
   5: 
   6:   public void setConfig(DocumentBuilderFactory factory)
   7:   {
   8:         ...
   9:     setSkipComments(factory.isIgnoringComments());
  10:     setSkipWhitespace(factory.isIgnoringElementContentWhitespace());
  11:     setNamespaceAware(factory.isNamespaceAware());

View Full Code Here

isNamespaceAware

public boolean isNamespaceAware()
Indicates whether or not the factory is configured to produce parsers which are namespace aware.
Returns:
true if the factory is configured to produce parsers which are namespace aware; false otherwise.
Usages and Demos :

View More Examples of isNamespaceAware()
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5: 
   6: public class ValidatingDocumentBuilderFactory extends DocumentBuilderFactory
   7: {
   8:         ...
   9:     protected Schema _Schema;
  10:     protected DocumentBuilderFactory _WrappedFactory;
  11:     
  12:         ...
  13:     public boolean isNamespaceAware()
  14:     { return _WrappedFactory.isNamespaceAware(); }

View Full Code Here
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5: 
   6:     private static DocumentBuilderFactory documentBuilderFactory;
   7: 
   8:         ...
   9:         if (XPathUtil.documentBuilderFactory == null || documentBuilderFactory.isValidating() != validate
  10:                 || documentBuilderFactory.isNamespaceAware() != namespace
  11:                 || documentBuilderFactory.isIgnoringElementContentWhitespace() != whitespace) {

View Full Code Here
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5: 
   6: public class DocumentBuilderFactoryImpl extends DocumentBuilderFactory {
   7:     
   8:         ...
   9:     private final DocumentBuilderFactory core;
  10: 
  11:         ...
  12:     public boolean isNamespaceAware() {
  13:         return core.isNamespaceAware();

View Full Code Here
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5: 
   6:     private DocumentBuilderFactory dbf;
   7: 
   8:         ...
   9: 
  10:     DocumentBuilderImpl(DocumentBuilderFactory dbf)
  11:         throws ParserConfigurationException
  12:         ...
  13:         this.dbf = dbf;
  14:         namespaceAware = dbf.isNamespaceAware();

View Full Code Here
   1: 
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import java.io.FileNotFoundException;
   4:         ...
   5: 
   6:   public void setConfig(DocumentBuilderFactory factory)
   7:   {
   8:         ...
   9:     setSkipWhitespace(factory.isIgnoringElementContentWhitespace());
  10:     setNamespaceAware(factory.isNamespaceAware());
  11:     setNamespacePrefixes(false);

View Full Code Here

isValidating

public boolean isValidating()
Indicates whether or not the factory is configured to produce parsers which validate the XML content during parse.
Returns:
true if the factory is configured to produce parsers which validate the XML content during parse; false otherwise.
Usages and Demos :

View More Examples of isValidating()
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5: 
   6: public class DocumentBuilderFactoryImpl extends DocumentBuilderFactory {
   7:     
   8:         ...
   9:     private final DocumentBuilderFactory core;
  10: 
  11:         ...
  12:     public boolean isValidating() {
  13:         return core.isValidating();

View Full Code Here
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5: 
   6:     private DocumentBuilderFactory dbf;
   7: 
   8:         ...
   9: 
  10:     DocumentBuilderImpl(DocumentBuilderFactory dbf)
  11:         throws ParserConfigurationException
  12:         ...
  13:         try {
  14:             validating = dbf.isValidating();

View Full Code Here
   1: 
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import java.io.FileNotFoundException;
   4:         ...
   5: 
   6:   public void setConfig(DocumentBuilderFactory factory)
   7:   {
   8:         ...
   9:     setNamespacePrefixes(false);
  10:     setValidating(factory.isValidating());
  11:   }

View Full Code Here
   1: 
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import java.io.FileNotFoundException;
   4:         ...
   5: 
   6:   public void setConfig(DocumentBuilderFactory factory)
   7:   {
   8:         ...
   9:     setNamespacePrefixes(false);
  10:     setValidating(factory.isValidating());
  11:   }

View Full Code Here

isXIncludeAware

public boolean isXIncludeAware()
Get state of XInclude processing.
Returns:
current state of XInclude processing
Throws:
UnsupportedOperationException - For backward compatibility, when implementations for earlier versions of JAXP is used, this exception will be thrown.
Since:
1.5

newDocumentBuilder

public abstract DocumentBuilder newDocumentBuilder()
            throws ParserConfigurationException
Creates a new instance of a DocumentBuilder using the currently configured parameters.
Returns:
A new instance of a DocumentBuilder.
Throws:
ParserConfigurationException - if a DocumentBuilder cannot be created which satisfies the configuration requested.
Usages and Demos :

View More Examples of newDocumentBuilder()
   1:     public DocumentBuilder getDomParser() throws Exception {
   2:          DocumentBuilderFactory docBF = DocumentBuilderFactory.newInstance();
   3:         ...
   4:          return docBF.newDocumentBuilder();
   5:     }
   6: }

View Full Code Here
   1:     protected void setUp() throws Exception {
   2:         DocumentBuilderFactory factory =
   3:             new DocumentBuilderFactoryImpl();
   4:         ...
   5:         DocumentBuilder documentBuilder =
   6:             factory.newDocumentBuilder();
   7: 
   8:         documentBuilder.setEntityResolver(
   9:             new StringEntityResolver(""));

View Full Code Here
   1: 
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: 
   4:         ...
   5:         try {
   6:             DocumentBuilderFactory factory =
   7:         ...
   8:                     DocumentBuilderFactory.newInstance();
   9:             
  10:         ...
  11:             factory.setCoalescing(isCoalescing());
  12:             return factory.newDocumentBuilder().parse(stream);

View Full Code Here
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5:         try {
   6:             DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
   7:             dbf.setNamespaceAware(true);
   8:         ...
   9:             return dbf.newDocumentBuilder();
  10:         } catch( ParserConfigurationException e ) {

View Full Code Here
   1:         {
   2:             DocumentBuilderFactory factory =
   3:         ...
   4:                 DocumentBuilderFactory.newInstance();
   5:             factory.setIgnoringComments(true);
   6:         ...
   7:             DocumentBuilder builder =
   8:                 factory.newDocumentBuilder();
   9:             return builder.parse(new InputSource(name));

View Full Code Here

newInstance

public static DocumentBuilderFactory newInstance()
Obtain a new instance of a DocumentBuilderFactory. This static method creates a new factory instance. This method uses the following ordered lookup procedure to determine the DocumentBuilderFactory implementation class to load:
  • Use the javax.xml.parsers.DocumentBuilderFactory system property.
  • Use the properties file "lib/jaxp.properties" in the JRE directory. This configuration file is in standard java.util.Properties format and contains the fully qualified name of the implementation class with the key being the system property defined above. The jaxp.properties file is read only once by the JAXP implementation and it's values are then cached for future use. If the file does not exist when the first attempt is made to read from it, no further attempts are made to check for its existence. It is not possible to change the value of any property in jaxp.properties after it has been read for the first time.
  • Use the Services API (as detailed in the JAR specification), if available, to determine the classname. The Services API will look for a classname in the file META-INF/services/javax.xml.parsers.DocumentBuilderFactory in jars available to the runtime.
  • Platform default DocumentBuilderFactory instance.
Once an application has obtained a reference to a DocumentBuilderFactory it can use the factory to configure and obtain parser instances.

Tip for Trouble-shooting

Setting the jaxp.debug system property will cause this method to print a lot of debug messages to System.err about what it is doing and where it is looking at.

If you have problems loading DocumentBuilders, try:

 java -Djaxp.debug=1 YourProgram ....
 
Returns:
New instance of a DocumentBuilderFactory
Usages and Demos :

View More Examples of newInstance()
   1:   public DOMTest2(String uri) throws Exception {
   2:     DocumentBuilderFactory factory =
   3:         ...
   4:         DocumentBuilderFactory.newInstance();
   5:     factory.setValidating(true);
   6:     DocumentBuilder builder = factory.newDocumentBuilder();
   7:     Document doc = builder.parse(uri);

View Full Code Here
   1:         DocumentBuilder parser = 
   2:             DocumentBuilderFactory.newInstance().newDocumentBuilder();
   3:         Document document = parser.parse( new InputSource("zooinventory.xml") );
   4:         ...
   5:         Transformer transformer = 
   6:             TransformerFactory.newInstance().newTransformer();
   7:         Source source = new DOMSource( document );
   8:         Result output = new StreamResult( System.out );
   9:         transformer.transform( source, output );

View Full Code Here
   1:   public DOMTest6() throws Exception {
   2:     DocumentBuilderFactory factory =
   3:         ...
   4:         DocumentBuilderFactory.newInstance();
   5:     factory.setValidating(true);
   6:     DocumentBuilder builder = factory.newDocumentBuilder();

View Full Code Here
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: 
   4:         ...
   5:         super.setUp();
   6:         final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
   7:         ...
   8:         final DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
   9:         document = documentBuilder.newDocument();

View Full Code Here
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: 
   4:         ...
   5:     public StaticXsltView() throws Exception {
   6:         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
   7:         DocumentBuilder db = dbf.newDocumentBuilder();
   8:         this.doc = db.parse(new File("C:\\work\\book\\ticket\\war\\xsl\\in.xml"));
   9:         logger.warning("Cached XML document");

View Full Code Here

setAttribute

public abstract void setAttribute(String name,
                                  Object value)
            throws IllegalArgumentException
Allows the user to set specific attributes on the underlying implementation.
Parameters:
name - The name of the attribute.
value - The value of the attribute.
Throws:
IllegalArgumentException - thrown if the underlying implementation doesn't recognize the attribute.
Usages and Demos :

View More Examples of setAttribute(String name,Object value)
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import java.io.File;
   4:         ...
   5:    public static void main(String[] args) throws Exception {
   6:       DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
   7:       DocumentBuilder documentBuilder = builderFactory.newDocumentBuilder();
   8:       Document document = documentBuilder.parse(new File(args[0]));
   9:       System.out.println(document.getClass());

View Full Code Here
   1:   public void print(String fileName) throws SAXException, IOException {
   2:    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
   3:    factory.setValidating(true);
   4:    factory.setNamespaceAware(true);
   5:    try {

View Full Code Here
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5:   {
   6:     DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
   7:     documentBuilderFactory.setNamespaceAware(true);
   8:     documentBuilderFactory.setValidating(false);
   9:     try

View Full Code Here
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5:         
   6:         DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
   7: 
   8: 

View Full Code Here
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import java.io.File;
   4:         ...
   5:             {
   6:                 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
   7:                 LocalFileEntityResolver entityResolver = LocalFileEntityResolver.getInstance();
   8:                 
   9:                 if (_schemaFileName != null) {

View Full Code Here

setCoalescing

public void setCoalescing(boolean coalescing)
Specifies that the parser produced by this code will convert CDATA nodes to Text nodes and append it to the adjacent (if any) text node. By default the value of this is set to false
Parameters:
coalescing - true if the parser produced will convert CDATA nodes to Text nodes and append it to the adjacent (if any) text node; false otherwise.
Usages and Demos :

View More Examples of setCoalescing(boolean coalescing)
   1: 
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: 
   4:         ...
   5:         try {
   6:             DocumentBuilderFactory factory =
   7:         ...
   8:                     DocumentBuilderFactory.newInstance();
   9:             
  10:         ...
  11:             factory.setIgnoringComments(isIgnoringComments());
  12:             factory.setCoalescing(isCoalescing());

View Full Code Here
   1:     {
   2:         DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
   3: 
   4:         DocumentBuilder parser = factory.newDocumentBuilder();

View Full Code Here
   1: 
   2:     DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
   3: 
   4:         ...
   5:     dbf.setExpandEntityReferences(true);
   6:     dbf.setCoalescing(true);
   7: 
   8:     DocumentBuilder db = null;
   9:     try {

View Full Code Here
   1: 
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5:         Document doc = null;
   6:         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
   7:         dbf.setValidating(false);
   8:         ...
   9:         dbf.setNamespaceAware(true);
  10:         dbf.setCoalescing(false);
  11:         doc = STAXUtils.read(dbf.newDocumentBuilder(), context.getInMessage()

View Full Code Here
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: 
   4:         ...
   5:   private void parseConfiguration(InputStream is) throws Exception {
   6:     DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
   7:     factory.setIgnoringComments(true);
   8:         ...
   9:     factory.setCoalescing(true);
  10:     factory.setNamespaceAware(false);

View Full Code Here

setExpandEntityReferences

public void setExpandEntityReferences(boolean expandEntityRef)
Specifies that the parser produced by this code will expand entity reference nodes. By default the value of this is set to true
Parameters:
expandEntityRef - true if the parser produced will expand entity reference nodes; false otherwise.
Usages and Demos :

View More Examples of setExpandEntityReferences(boolean expandEntityRef)
   1: 
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: 
   4:         ...
   5:         try {
   6:             DocumentBuilderFactory factory =
   7:         ...
   8:                     DocumentBuilderFactory.newInstance();
   9:             
  10:         ...
  11:                     isIgnoringElementContentWhitespace());
  12:             factory.setExpandEntityReferences(isExpandEntityReferences());

View Full Code Here
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5:         if (builder == null) {
   6:             DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
   7:             factory.setNamespaceAware(false);
   8:         ...
   9:             factory.setExpandEntityReferences(false);
  10:             builder = factory.newDocumentBuilder();

View Full Code Here
   1: 
   2:     DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
   3: 
   4:         ...
   5:     dbf.setIgnoringElementContentWhitespace(false);
   6:     dbf.setExpandEntityReferences(true);
   7:     dbf.setCoalescing(true);
   8: 
   9:     DocumentBuilder db = null;

View Full Code Here
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5: 
   6: public class ValidatingDocumentBuilderFactory extends DocumentBuilderFactory
   7: {
   8:         ...
   9:     protected Schema _Schema;
  10:     protected DocumentBuilderFactory _WrappedFactory;
  11:     
  12:         ...
  13:     public void setExpandEntityReference(boolean expandEntityRef)
  14:     { _WrappedFactory.setExpandEntityReferences(expandEntityRef); }

View Full Code Here
   1: import org.w3c.dom.Document;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.DocumentBuilder;
   4:         ...
   5:         
   6:         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
   7:         DocumentBuilder db = null;
   8:         ...
   9:         dbf.setCoalescing(true);
  10:         dbf.setExpandEntityReferences(true);

View Full Code Here

setFeature

public abstract void setFeature(String name,
                                boolean value)
            throws ParserConfigurationException
Set a feature for this DocumentBuilderFactory and DocumentBuilders created by this factory.

Feature names are fully qualified URIs. Implementations may define their own features. An ParserConfigurationException is thrown if this DocumentBuilderFactory or the DocumentBuilders it creates cannot support the feature. It is possible for an DocumentBuilderFactory to expose a feature value but be unable to change its state.

All implementations are required to support the XMLConstants.FEATURE_SECURE_PROCESSING feature. When the feature is:

  • true: the implementation will limit XML processing to conform to implementation limits. Examples include enity expansion limits and XML Schema constructs that would consume large amounts of resources. If XML processing is limited for security reasons, it will be reported via a call to the registered org.xml.sax.ErrorHandler.fatalError(SAXParseException exception). See DocumentBuilder.setErrorHandler(org.xml.sax.ErrorHandler errorHandler).
  • false: the implementation will processing XML according to the XML specifications without regard to possible implementation limits.
Parameters:
name - Feature name.
value - Is feature state true or false.
Throws:
ParserConfigurationException - if this DocumentBuilderFactory or the DocumentBuilders it creates cannot support this feature.
NullPointerException - If the name parameter is null.
Usages and Demos :

View More Examples of setFeature(String name,boolean value)
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: 
   4:         ...
   5:             }
   6:             DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
   7:         ...
   8:             dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING,enableSecureProcessing);
   9:             

View Full Code Here
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5: 
   6: public class DocumentBuilderFactoryImpl extends DocumentBuilderFactory
   7: {
   8:         ...
   9: 
  10:    private DocumentBuilderFactory delegate;
  11: 
  12:         ...
  13:    {
  14:       delegate.setFeature(name, value);

View Full Code Here
   1:     
   2:     DocumentBuilderFactory dbf = null;
   3:     
   4:         ...
   5:         try{
   6:             dbf = DocumentBuilderFactory.newInstance();
   7:             DocumentBuilder parser = dbf.newDocumentBuilder();
   8:         ...
   9:         try{
  10:             dbf = DocumentBuilderFactory.newInstance();
  11:             dbf.setNamespaceAware(true);
  12:         ...
  13:             dbf = DocumentBuilderFactory.newInstance();
  14:             dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING,false);

View Full Code Here

setIgnoringComments

public void setIgnoringComments(boolean ignoreComments)
Specifies that the parser produced by this code will ignore comments. By default the value of this is set to false .
Parameters:
ignoreComments - boolean value to ignore comments during processing
Usages and Demos :

View More Examples of setIgnoringComments(boolean ignoreComments)
   1: 
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: 
   4:         ...
   5:         try {
   6:             DocumentBuilderFactory factory =
   7:         ...
   8:                     DocumentBuilderFactory.newInstance();
   9:             
  10:         ...
  11:             factory.setExpandEntityReferences(isExpandEntityReferences());
  12:             factory.setIgnoringComments(isIgnoringComments());

View Full Code Here
   1:     {
   2:         DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
   3: 
   4:         DocumentBuilder parser = factory.newDocumentBuilder();

View Full Code Here
   1:         {
   2:             DocumentBuilderFactory factory =
   3:         ...
   4:                 DocumentBuilderFactory.newInstance();
   5:         ...
   6:             factory.setIgnoringComments(true);
   7:             factory.setIgnoringElementContentWhitespace(true);

View Full Code Here
   1: 
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5:         Document doc = null;
   6:         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
   7:         dbf.setValidating(false);
   8:         ...
   9:         dbf.setIgnoringComments(false);
  10:         dbf.setIgnoringElementContentWhitespace(false);

View Full Code Here
   1:   {
   2:     DocumentBuilderFactory Factory =
   3:         ...
   4:       DocumentBuilderFactory.newInstance();
   5: 
   6:         ...
   7:     Factory.setIgnoringElementContentWhitespace(true);
   8:     Factory.setIgnoringComments(true);
   9:     Factory.setAttribute(JAXPConstants.JAXP_SCHEMA_LANGUAGE,

View Full Code Here

setIgnoringElementContentWhitespace

public void setIgnoringElementContentWhitespace(boolean whitespace)
Specifies that the parsers created by this factory must eliminate whitespace in element content (sometimes known loosely as 'ignorable whitespace') when parsing XML documents (see XML Rec 2.10). Note that only whitespace which is directly contained within element content that has an element only content model (see XML Rec 3.2.1) will be eliminated. Due to reliance on the content model this setting requires the parser to be in validating mode. By default the value of this is set to false.
Parameters:
whitespace - true if the parser created must eliminate whitespace in the element content when parsing XML documents; false otherwise.
Usages and Demos :

View More Examples of setIgnoringElementContentWhitespace(boolean whitespace)
   1:         {
   2:             DocumentBuilderFactory factory =
   3:         ...
   4:                 DocumentBuilderFactory.newInstance();
   5:             factory.setIgnoringComments(true);
   6:         ...
   7:             factory.setIgnoringElementContentWhitespace(true);
   8:             factory.setValidating(true);

View Full Code Here
   1: 
   2:     DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
   3: 
   4:         ...
   5:     dbf.setValidating(false);
   6:     dbf.setIgnoringElementContentWhitespace(false);
   7:     dbf.setExpandEntityReferences(true);
   8:     dbf.setCoalescing(true);

View Full Code Here
   1: 
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5:         Document doc = null;
   6:         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
   7:         dbf.setValidating(false);
   8:         ...
   9:         dbf.setIgnoringComments(false);
  10:         dbf.setIgnoringElementContentWhitespace(false);
  11:         dbf.setNamespaceAware(true);

View Full Code Here
   1:   {
   2:     DocumentBuilderFactory Factory =
   3:         ...
   4:       DocumentBuilderFactory.newInstance();
   5: 
   6:         ...
   7:     Factory.setNamespaceAware(true);
   8:     Factory.setIgnoringElementContentWhitespace(true);
   9:     Factory.setIgnoringComments(true);

View Full Code Here
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5: 
   6: public class ValidatingDocumentBuilderFactory extends DocumentBuilderFactory
   7: {
   8:         ...
   9:     protected Schema _Schema;
  10:     protected DocumentBuilderFactory _WrappedFactory;
  11:     
  12:         ...
  13:     public void setIgnoringElementContentWhitespace(boolean whitespace)
  14:     { _WrappedFactory.setIgnoringElementContentWhitespace(whitespace); }

View Full Code Here

setNamespaceAware

public void setNamespaceAware(boolean awareness)
Specifies that the parser produced by this code will provide support for XML namespaces. By default the value of this is set to false
Parameters:
awareness - true if the parser produced will provide support for XML namespaces; false otherwise.
Usages and Demos :

View More Examples of setNamespaceAware(boolean awareness)
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5:     {
   6:         DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
   7:         ...
   8:         dfactory.setNamespaceAware(true);
   9:         DocumentBuilder docBuilder = dfactory.newDocumentBuilder();
  10:         ...
  11:         DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
  12:         dfactory.setNamespaceAware(true);

View Full Code Here
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import org.w3c.dom.Document;
   4:         ...
   5:     public void parse(InputStream document, OutputStream finf, String workingDirectory) throws Exception {
   6:         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
   7:         ...
   8:         dbf.setNamespaceAware(true);
   9:         DocumentBuilder db = dbf.newDocumentBuilder();

View Full Code Here
   1: import javax.xml.transform.stream.StreamResult;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5: 
   6:             DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
   7:         ...
   8:             dbf.setNamespaceAware(true);
   9:             Document doc = dbf.newDocumentBuilder().parse(args[0]);

View Full Code Here
   1: import javax.xml.transform.stream.StreamResult;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5: 
   6:             DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
   7:         ...
   8:             dbf.setNamespaceAware(true);
   9:             Document doc = dbf.newDocumentBuilder().parse(args[0]);

View Full Code Here
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import org.apache.xml.security.c14n.Canonicalizer;
   4:         ...
   5: 
   6:       DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
   7:         ...
   8:       dfactory.setNamespaceAware(true);
   9:       dfactory.setValidating(true);

View Full Code Here

setSchema

public void setSchema(Schema schema)
Set the Schema to be used by parsers created from this factory.

When a Schema is non-null, a parser will use a validator created from it to validate documents before it passes information down to the application.

When errors are found by the validator, the parser is responsible to report them to the user-specified DOMErrorHandler (or if the error handler is not set, ignore them or throw them), just like any other errors found by the parser itself. In other words, if the user-specified DOMErrorHandler is set, it must receive those errors, and if not, they must be treated according to the implementation specific default error handling rules.

A validator may modify the outcome of a parse (for example by adding default values that were missing in documents), and a parser is responsible to make sure that the application will receive modified DOM trees.

Initialy, null is set as the Schema.

This processing will take effect even if the isValidating() method returns false.

It is an error to use the http://java.sun.com/xml/jaxp/properties/schemaSource property and/or the http://java.sun.com/xml/jaxp/properties/schemaLanguage property in conjunction with a Schema object. Such configuration will cause a ParserConfigurationException exception when the newDocumentBuilder() is invoked.

Note for implmentors

A parser must be able to work with any Schema implementation. However, parsers and schemas are allowed to use implementation-specific custom mechanisms as long as they yield the result described in the specification.

Parameters:
schema - Schema to use or null to remove a schema.
Throws:
UnsupportedOperationException - For backward compatibility, when implementations for earlier versions of JAXP is used, this exception will be thrown.
Since:
1.5
Usages and Demos :

View More Examples of setSchema(Schema schema)
   1: import javax.xml.XMLConstants;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5:     void setAttr(boolean setSrc) {
   6:         DocumentBuilderFactory docBFactory = DocumentBuilderFactory.newInstance();
   7:         Schema sch = createSchema();
   8:         ...
   9:         docBFactory.setSchema(sch);
  10:         docBFactory.setNamespaceAware(true);

View Full Code Here
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.SAXParserFactory;
   4:         ...
   5:     public void testDomPrewire() throws Exception {
   6:         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
   7:         dbf.setNamespaceAware(true);
   8:         ...
   9:         dbf.setSchema(loadXsdSchema("Camera.xsd"));
  10:         DocumentBuilder builder = dbf.newDocumentBuilder();
  11:         ...
  12:         spf.setNamespaceAware(true);
  13:         spf.setSchema(loadXsdSchema("Camera.xsd"));

View Full Code Here
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: 
   4:         ...
   5:     public void test1() throws Exception {
   6:         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
   7:         System.out.println(Which4J.which(dbf.getClass()));
   8:         ...
   9:         dbf.setSchema(loadKSchema());
  10:         DocumentBuilder db = dbf.newDocumentBuilder();
  11:         ...
  12:         System.out.println(Which4J.which(dbf.getClass()));
  13:         dbf.setSchema(loadXsdSchema("Test2.xsd"));

View Full Code Here

setValidating

public void setValidating(boolean validating)
Specifies that the parser produced by this code will validate documents as they are parsed. By default the value of this is set to false.

Note that "the validation" here means a validating parser as defined in the XML recommendation. In other words, it essentially just controls the DTD validation. (except the legacy two properties defined in JAXP 1.2. See here for more details.)

To use modern schema languages such as W3C XML Schema or RELAX NG instead of DTD, you can configure your parser to be a non-validating parser by leaving the setValidating(boolean) method false, then use the setSchema(Schema) method to associate a schema to a parser.

Parameters:
validating - true if the parser produced will validate documents as they are parsed; false otherwise.
Usages and Demos :

View More Examples of setValidating(boolean validating)
   1:   public DOMTest2(String uri) throws Exception {
   2:     DocumentBuilderFactory factory =
   3:         ...
   4:         DocumentBuilderFactory.newInstance();
   5:         ...
   6:     factory.setValidating(true);
   7:     DocumentBuilder builder = factory.newDocumentBuilder();

View Full Code Here
   1:   public DOMTest6() throws Exception {
   2:     DocumentBuilderFactory factory =
   3:         ...
   4:         DocumentBuilderFactory.newInstance();
   5:         ...
   6:     factory.setValidating(true);
   7:     DocumentBuilder builder = factory.newDocumentBuilder();

View Full Code Here
   1:   public DOMTest4(String uri) throws Exception {
   2:     DocumentBuilderFactory factory =
   3:         ...
   4:         DocumentBuilderFactory.newInstance();
   5:         ...
   6:     factory.setValidating(true);
   7:     DocumentBuilder builder = factory.newDocumentBuilder();

View Full Code Here
   1:   public DOMTest3(String uri) throws Exception {
   2:     DocumentBuilderFactory factory =
   3:         ...
   4:         DocumentBuilderFactory.newInstance();
   5:         ...
   6:     factory.setValidating(true);
   7:     DocumentBuilder builder = factory.newDocumentBuilder();

View Full Code Here
   1:   
   2:     DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
   3:         ...
   4:     dbf.setValidating(false);
   5:     DocumentBuilder db = null;
   6: 
   7:     try {

View Full Code Here

setXIncludeAware

public void setXIncludeAware(boolean state)
Set state of XInclude processing.

If XInclude markup is found in the document instance, should it be processed as specified in XML Inclusions (XInclude) Version 1.0.

XInclude processing defaults to false.

Parameters:
state - Set XInclude processing to true or false
Throws:
UnsupportedOperationException - For backward compatibility, when implementations for earlier versions of JAXP is used, this exception will be thrown.
Since:
1.5
Usages and Demos :

View More Examples of setXIncludeAware(boolean state)
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import org.w3c.dom.DOMError;
   4:         ...
   5:         try{
   6:             DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
   7:         ...
   8:             dbf.setXIncludeAware(true);
   9:             dbf.setNamespaceAware(true);

View Full Code Here
   1: import javax.xml.parsers.DocumentBuilder;
   2: import javax.xml.parsers.DocumentBuilderFactory;
   3: import javax.xml.parsers.ParserConfigurationException;
   4:         ...
   5:           {
   6:             DocumentBuilderFactory f = DocumentBuilderFactory.newInstance();
   7:         ...
   8:             f.setXIncludeAware(true);
   9:             f.setNamespaceAware(namespaceAware);

View Full Code Here