org.apache.xerces.jaxp

## Class DocumentBuilderFactoryImpl

- java.lang.Object
- - javax.xml.parsers.DocumentBuilderFactory
  - - org.apache.xerces.jaxp.DocumentBuilderFactoryImpl

-     public class DocumentBuilderFactoryImpl
      extends javax.xml.parsers.DocumentBuilderFactory

  Version:
    $Id: DocumentBuilderFactoryImpl.java 447237 2006-09-18 05:03:10Z mrglavas $
  Author:
    Rajiv Mordani, Edwin Goei

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DocumentBuilderFactoryImpl()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.Object` | `getAttribute(java.lang.String name)` Allows the user to retrieve specific attributes on the underlying implementation.
    `boolean` | `getFeature(java.lang.String name)` Get the state of the named feature.
    `javax.xml.validation.Schema` | `getSchema()` Gets the `Schema` object specified through the `DocumentBuilderFactory.setSchema(Schema schema)` method.
    `boolean` | `isXIncludeAware()` Get state of XInclude processing.
    `javax.xml.parsers.DocumentBuilder` | `newDocumentBuilder()` Creates a new instance of a `DocumentBuilder` using the currently configured parameters.
    `void` | `setAttribute(java.lang.String name, java.lang.Object value)` Allows the user to set specific attributes on the underlying implementation.
    `void` | `setFeature(java.lang.String name, boolean value)` Set a feature for this `DocumentBuilderFactory` and `DocumentBuilder`s created by this factory.
    `void` | `setSchema(javax.xml.validation.Schema grammar)` Set the `Schema` to be used by parsers created from this factory.
    `void` | `setXIncludeAware(boolean state)` Set state of XInclude processing.

    - ### Methods inherited from class javax.xml.parsers.DocumentBuilderFactory

      `isCoalescing, isExpandEntityReferences, isIgnoringComments, isIgnoringElementContentWhitespace, isNamespaceAware, isValidating, newInstance, newInstance, setCoalescing, setExpandEntityReferences, setIgnoringComments, setIgnoringElementContentWhitespace, setNamespaceAware, setValidating`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### DocumentBuilderFactoryImpl

          public DocumentBuilderFactoryImpl()

  - ### Method Detail

    - #### newDocumentBuilder

          public javax.xml.parsers.DocumentBuilder newDocumentBuilder()
                                                               throws javax.xml.parsers.ParserConfigurationException

      Creates a new instance of a `DocumentBuilder` using the currently configured parameters.
      Specified by:
        `newDocumentBuilder` in class `javax.xml.parsers.DocumentBuilderFactory`
      Returns:
        A new instance of a DocumentBuilder.
      Throws:
        `javax.xml.parsers.ParserConfigurationException` - if a DocumentBuilder cannot be created which satisfies the configuration requested.

    - #### setAttribute

          public void setAttribute(java.lang.String name,
                          java.lang.Object value)
                            throws java.lang.IllegalArgumentException

      Allows the user to set specific attributes on the underlying implementation.
      Specified by:
        `setAttribute` in class `javax.xml.parsers.DocumentBuilderFactory`
      Parameters:
        `name` - name of attribute
        `value` - null means to remove attribute
      Throws:
        `java.lang.IllegalArgumentException` - thrown if the underlying implementation doesn't recognize the attribute.

    - #### getAttribute

          public java.lang.Object getAttribute(java.lang.String name)
                                        throws java.lang.IllegalArgumentException

      Allows the user to retrieve specific attributes on the underlying implementation.
      Specified by:
        `getAttribute` in class `javax.xml.parsers.DocumentBuilderFactory`
      Parameters:
        `name` - The name of the attribute.
      Returns:
        value The value of the attribute.
      Throws:
        `java.lang.IllegalArgumentException` - thrown if the underlying implementation doesn't recognize the attribute.

    - #### getSchema

          public javax.xml.validation.Schema getSchema()

      Description copied from class: `javax.xml.parsers.DocumentBuilderFactory`
      Gets the `Schema` object specified through the `DocumentBuilderFactory.setSchema(Schema schema)` method.
      Overrides:
        `getSchema` in class `javax.xml.parsers.DocumentBuilderFactory`
      Returns:
        the `Schema` object that was last set through the `DocumentBuilderFactory.setSchema(Schema)` method, or null if the method was not invoked since a `DocumentBuilderFactory` is created.

    - #### setSchema

          public void setSchema(javax.xml.validation.Schema grammar)

      Description copied from class: `javax.xml.parsers.DocumentBuilderFactory`

      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 `ErrorHandler` (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 `ErrorHandler` 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.

      Initially, null is set as the `Schema`.

      This processing will take effect even if the `DocumentBuilderFactory.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 `DocumentBuilderFactory.newDocumentBuilder()` is invoked.

      #### Note for implementors

      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.

      Overrides:
        `setSchema` in class `javax.xml.parsers.DocumentBuilderFactory`
      Parameters:
        `grammar` - `Schema` to use or `null` to remove a schema.

    - #### isXIncludeAware

          public boolean isXIncludeAware()

      Description copied from class: `javax.xml.parsers.DocumentBuilderFactory`

      Get state of XInclude processing.

      Overrides:
        `isXIncludeAware` in class `javax.xml.parsers.DocumentBuilderFactory`
      Returns:
        current state of XInclude processing

    - #### setXIncludeAware

          public void setXIncludeAware(boolean state)

      Description copied from class: `javax.xml.parsers.DocumentBuilderFactory`

      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`.

      Overrides:
        `setXIncludeAware` in class `javax.xml.parsers.DocumentBuilderFactory`
      Parameters:
        `state` - Set XInclude processing to `true` or `false`

    - #### getFeature

          public boolean getFeature(java.lang.String name)
                             throws javax.xml.parsers.ParserConfigurationException

      Description copied from class: `javax.xml.parsers.DocumentBuilderFactory`

      Get the state of the named feature.

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

      Specified by:
        `getFeature` in class `javax.xml.parsers.DocumentBuilderFactory`
      Parameters:
        `name` - Feature name.
      Returns:
        State of the named feature.
      Throws:
        `javax.xml.parsers.ParserConfigurationException` - if this `DocumentBuilderFactory` or the `DocumentBuilder`s it creates cannot support this feature.

    - #### setFeature

          public void setFeature(java.lang.String name,
                        boolean value)
                          throws javax.xml.parsers.ParserConfigurationException

      Description copied from class: `javax.xml.parsers.DocumentBuilderFactory`

      Set a feature for this `DocumentBuilderFactory` and `DocumentBuilder`s created by this factory.

      Feature names are fully qualified `URI`s. Implementations may define their own features. An `ParserConfigurationException` is thrown if this `DocumentBuilderFactory` or the `DocumentBuilder`s 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 entity 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 `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.
      Specified by:
        `setFeature` in class `javax.xml.parsers.DocumentBuilderFactory`
      Parameters:
        `name` - Feature name.
        `value` - Is feature state `true` or `false`.
      Throws:
        `javax.xml.parsers.ParserConfigurationException` - if this `DocumentBuilderFactory` or the `DocumentBuilder`s it creates cannot support this feature.

Copyright © 1999-2022 The Apache Software Foundation. All Rights Reserved.