JAXP Parsing API based on
Document Object Model (DOM) and
Simple API for XML Parsing (SAX), and
Streaming API for XML (StAX);
Extensible Stylesheet Language Transformations (XSLT);
JAXP Validation API
based on the XML Schema Definition Language;JAXP Transformation API
or XSLT (Extensible Stylesheet Language Transformations);XML XPath Language API (XPath);XML Catalog API;
Processors are aggregates of parsers (or readers), serializers (or writers),
validators, and transformers that control and perform the processing in their
respective areas. They are defined in their relevant packages.
In the parsers package for example,
are the DocumentBuilder and
SAXParser, that represent the DOM and
SAX processors.
The processors are configured and instantiated with their corresponding factories.
The DocumentBuilder and SAXParser for example are constructed with the
DocumentBuilderFactory
and SAXParserFactory respectively.
javax.xml.catalog.resolve may be used
to set the CatalogFeatures' RESOLVE
property.
The exact time at which system properties are read is unspecified. In order to ensure that the desired values are properly applied, applications should ensure that system properties are set appropriately prior to the creation of the first JAXP factory and are not modified thereafter.
Configuration files are Java java. files that consist
of mappings between system properties and their values defined by various APIs
or processes. The following configuration file entries demonstrate setting the
javax.xml.parsers.DocumentBuilderFactory
and CatalogFeatures.RESOLVE properties:
javax.xml.parsers.DocumentBuilderFactory=packagename.DocumentBuilderFactoryImpl
javax.xml.catalog.resolve=strict
jaxp.properties Filejaxp.properties,
located in the ${java.home}/conf directory; and if the file exists, loads the
specified properties to customize the behavior of the XML factories and processors.
The jaxp.properties file will be read only once during the initialization
of the JAXP implementation and cached in memory. If there is an error accessing
or reading the file, the configuration process proceeds as if the file does not exist.
jaxp.properties file, the system property
java.xml.config.file can be set to specify the location of
a configuration file. If the java.xml.config.file property is included
within a configuration file, it will be ignored.
When the java.xml.config.file is specified, the configuration file will be
read and the included properties will override the same properties that were
defined in the jaxp.properties file. If the java.xml.config.file
has not been set when the JAXP implementation is initialized, no further attempt
will be made to check for its existence.
The java.xml.config.file value must contain a valid pathname
to a configuration file. If the pathname is not absolute, it will be considered
relative to the working directory of the JVM.
If there is an error reading the configuration file, the configuration process
proceeds as if the java.xml.config.file property was not set.
Implementations may optionally issue a warning message.
FEATURE_SECURE_PROCESSING
(FSP) is enabled. The configuration order of precedence for properties is as
follows, from highest to lowest:
The APIs for factories or processors
System Property
User-defined Configuration File
The default JAXP Configuration File jaxp.properties
The default values for JAXP Properties. If the
FSP is true,
the default values will be set to process XML securely.
CatalogFeatures' RESOLVE
property as an example, the following illustrates how these rules are applied:
Properties specified with factory or processor APIs have the highest
precedence. The following code effectively sets the RESOLVE property to
strict, regardless of settings in any other configuration sources.
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setAttribute(CatalogFeatures.Feature.RESOLVE.getPropertyName(), "strict");
If the property is not set on the factory as in the above code, a system property setting will be in effect.
// in the following example, the RESOLVE property is set to 'continue'
// for the entire application
java -Djavax.xml.catalog.resolve=continue myApp
If the property is not set on the factory, or using a system property,
the setting in a configuration file will take effect. The following entry
sets the property to 'continue'.
javax.xml.catalog.resolve=continue
If the property is not set anywhere, it will be resolved to its
default value that is 'strict'.
| Factory | Method | System Property | System Default |
|---|---|---|---|
DatatypeFactory
|
newInstance() |
javax.xml.datatype.DatatypeFactory |
newDefaultInstance() |
DocumentBuilderFactory
|
newInstance() |
javax.xml.parsers.DocumentBuilderFactory |
newDefaultInstance() |
SAXParserFactory
|
newInstance() |
javax.xml.parsers.SAXParserFactory |
newDefaultInstance() |
XMLEventFactory
|
newFactory() |
javax.xml.stream.XMLEventFactory |
newDefaultFactory() |
XMLInputFactory
|
newFactory() |
javax.xml.stream.XMLInputFactory |
newDefaultFactory() |
XMLOutputFactory
|
newFactory() |
javax.xml.stream.XMLOutputFactory |
newDefaultFactory() |
TransformerFactory
|
newInstance() |
javax.xml.transform.TransformerFactory |
newDefaultInstance() |
SchemaFactory
|
newInstance(schemaLanguage) |
javax.xml.validation.SchemaFactory:schemaLanguage[1] |
newDefaultInstance() |
XPathFactory
|
newInstance(uri) |
DEFAULT_PROPERTY_NAME + ":uri"[2] |
newDefaultInstance() |
newInstance(schemaLanguage)
method.
[2] where uri is the parameter to the
newInstance(uri)
method.
The service-provider loading facility, defined by the
java. class, to attempt to locate and load an
implementation of the service using the default loading mechanism:
the service-provider loading facility will use the current thread's context class loader
to attempt to load the service. If the context class
loader is null, the system class loader will be used.
SchemaFactorySchemaFactory,
each potential service provider is required to implement the method
isSchemaLanguageSupported(String schemaLanguage).
The first service provider found that supports the specified schema language
is returned.
XPathFactoryXPathFactory,
each potential service provider is required to implement the method
isObjectModelSupported(String objectModel).
The first service provider found that supports the specified object model is
returned.
Otherwise, the system-default implementation is returned, which is
equivalent to calling the newDefaultInstance() or newDefaultFactory()
method as shown in column System Default of the table
JAXP Factories above.
SchemaFactorySchemaFactory,
there must be a platform default SchemaFactory for W3C XML Schema.
XPathFactoryXPathFactory,
there must be a
platform default
XPathFactory for the W3C DOM, i.e.
DEFAULT_OBJECT_MODEL_URI.
| Source | Files |
|---|---|
java. |
preferences.dtd |
java. |
properties.dtd |
|
XML Schema Part 1: Structures Second Edition XML Schema Part 2: Datatypes Second Edition |
XMLSchema.dtd datatypes.dtd XMLSchema.xsd datatypes.xsd |
| XHTML™ 1.0 The Extensible HyperText Markup Language |
xhtml1-frameset.dtd xhtml1-strict.dtd xhtml1-transitional.dtd |
| XHTML™ 1.0 in XML Schema |
xhtml1-frameset.xsd xhtml1-strict.xsd xhtml1-transitional.xsd |
| XHTML™ 1.1 - Module-based XHTML - Second Edition | xhtml11.dtd |
| XHTML 1.1 XML Schema Definition | xhtml11.xsd |
| XML DTD for W3C specifications | xmlspec.dtd |
| The "xml:" Namespace | xml.xsd |
The catalog is loaded once when the first JAXP processor factory is created.
CatalogResolver
with the built-in catalog when needed. This CatalogResolver is used as the
default external resource resolver.
XML processors may use resolvers (such as EntityResolver,
XMLResolver, and CatalogResolver)
to handle external references. In the absence of the user-defined resolvers,
the JDK XML processors fall back to the default CatalogResolver to attempt to
find a resolution before making a connection to fetch the resources. The fall-back
also takes place if a user-defined resolver exists but allows the process to
continue when unable to resolve the resource.
If the default CatalogResolver is unable to locate a resource, it may signal
the XML processors to continue processing, or skip the resource, or
throw a CatalogException. The behavior is configured with the
jdk.xml.jdkcatalog.resolve property.
jdk.xml.". These properties also follow the
configuration process as defined in the Configuration section.
Refer to the Implementation Specific Properties table for the list of properties supported by the JDK implementation.
| ID | Name | Method 1: setAttribute/Parameter/Property | Method 2: setFeature |
|---|---|---|---|
| DOM | DOM Parser |
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();dbf.setAttribute(name, value);
|
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();dbf.setFeature(name, value);
|
| SAX | SAX Parser |
SAXParserFactory spf = SAXParserFactory.newInstance();SAXParser parser = spf.newSAXParser();parser.setProperty(name, value);
|
SAXParserFactory spf = SAXParserFactory.newInstance();spf.setFeature(name, value); |
| StAX | StAX Parser |
XMLInputFactory xif = XMLInputFactory.newInstance();xif.setProperty(name, value);
|
XMLInputFactory xif = XMLInputFactory.newInstance();xif.setProperty(name, value);
|
| Validation | XML Validation API |
SchemaFactory schemaFactory = SchemaFactory.newInstance(schemaLanguage);schemaFactory.setProperty(name, value);
|
SchemaFactory schemaFactory = SchemaFactory.newInstance(schemaLanguage);schemaFactory.setFeature(name, value);
|
| Transform | XML Transform API |
TransformerFactory factory = TransformerFactory.newInstance();factory.setAttribute(name, value);
|
TransformerFactory factory = TransformerFactory.newInstance();factory.setFeature(name, value);
|
| XSLTC Serializer | XSLTC Serializer |
Transformer transformer = TransformerFactory.newInstance().newTransformer();transformer.setOutputProperty(name, value);
|
|
| DOMLS | DOM Load and Save |
LSSerializer serializer = domImplementation.createLSSerializer(); serializer.getDomConfig().setParameter(name, value);
|
|
| XPath | XPath |
XPathFactory factory = XPathFactory.newInstance();factory.setProperty(name, value);
|
XPathFactory factory = XPathFactory.newInstance(); factory.setFeature(name, value);
|
Full Name (prefix jdk.xml.)
[1] |
Description | System Property [2] | Value [3] | Security [4] | Supported Processor [5] | Since [6] | ||||
|---|---|---|---|---|---|---|---|---|---|---|
| Type | Value | Default | Enforced | ID | Set Method | |||||
jdk.xml.entityExpansionLimit |
Limits the number of entity expansions. | yes | Integer | A positive integer. A value less than or equal to 0 indicates no limit. If the value is not an integer, a NumberFormatException is thrown. | 2500 | 2500 | Yes |
DOM SAX StAX Validation Transform |
Method 1 | 8 |
jdk.xml.elementAttributeLimit |
Limits the number of attributes an element can have. | 200 | 200 | |||||||
jdk.xml.maxOccurLimit |
Limits the number of content model nodes that may be created when building a grammar for a W3C XML Schema that contains maxOccurs attributes with values other than "unbounded". | 5000 | 5000 | |||||||
jdk.xml.totalEntitySizeLimit |
Limits the total size of all entities that include general and parameter entities. The size is calculated as an aggregation of all entities. | 100000 | 100000 | |||||||
jdk.xml.maxGeneralEntitySizeLimit |
Limits the maximum size of any general entities. | 100000 | 100000 | |||||||
jdk.xml.maxParameterEntitySizeLimit |
Limits the maximum size of any parameter entities, including the result of nesting multiple parameter entities. | 15000 | 15000 | |||||||
jdk.xml.entityReplacementLimit |
Limits the total number of nodes in all entity references. | 100000 | 100000 | |||||||
jdk.xml.maxElementDepth |
Limits the maximum element depth. | 100 | 100 | |||||||
jdk.xml.maxXMLNameLimit |
Limits the maximum size of XML names, including element name, attribute name and namespace prefix and URI. | 1000 | 1000 | |||||||
jdk.xml.isStandalone |
Indicates that the serializer should treat the output as a
standalone document. The property can be used to ensure a newline is written
after the XML declaration. Unlike the property
xml-declaration, this property
does not have an effect on whether an XML declaration should be written out.
|
boolean | true/false | false | N/A | No | DOMLS | 17 | ||
jdk.xml.xsltcIsStandalone |
Indicates that the XSLTC serializer should
treat the output as a standalone document. The property can be used to ensure
a newline is written after the XML declaration. Unlike the property
OMIT_XML_DECLARATION,
this property does not have an effect on whether an XML declaration should be
written out.
This property behaves similar to that for DOMLS above, except that it is for the XSLTC Serializer and its value is a String. |
String | yes/no | no | N/A | No | XSLTC Serializer | 17 | ||
jdk.xml.cdataChunkSize |
Instructs the parser to return the data in a CData section in a single chunk when the property is zero or unspecified, or in multiple chunks when it is greater than zero. The parser shall split the data by linebreaks, and any chunks that are larger than the specified size to ones that are equal to or smaller than the size. | yes | Integer | A positive integer. A value less than or equal to 0 indicates that the property is not specified. If the value is not an integer, a NumberFormatException is thrown. | 0 | N/A | No | SAX StAX |
9 | |
| jdk.xml.extensionClassLoader | Sets a non-null ClassLoader instance to be used for loading XSLTC java extension functions. | no | Object | A reference to a ClassLoader object. Null if the value is not specified. | null | N/A | No | Transform | 9 | |
| jdk.xml.xpathExprGrpLimit | Limits the number of groups an XPath expression can contain. | yes | Integer | A positive integer. A value less than or equal to 0 indicates no limit. If the value is not an integer, a NumberFormatException is thrown. | 10 | 10 | Yes |
Transform XPath |
19 | |
| jdk.xml.xpathExprOpLimit | Limits the number of operators an XPath expression can contain. | 100 | 100 | |||||||
| jdk.xml.xpathTotalOpLimit | Limits the total number of XPath operators in an XSL Stylesheet. | 10000 | 10000 |
Transform |
||||||
jdk.xml.enableExtensionFunctions |
Determines whether extension functions in the Transform API are to be allowed. The extension functions in the XPath API are not affected by this property. | yes | Boolean | true or false. True indicates that extension functions are allowed; False otherwise. | false | false | Yes |
Transform |
Method 2 | 8 |
jdk.xml.overrideDefaultParser |
Enables the use of a 3rd party's parser implementation to override the system-default parser for the JDK's Transform, Validation and XPath implementations. | true or false. True enables the use of 3rd party's parser implementations to override the system-default implementation during XML Transform, Validation or XPath operation. False disables the use of 3rd party's parser implementations. | false | false | Yes |
Transform Validation XPath |
Method 2 | 9 | ||
jdk.xml.resetSymbolTable |
Instructs the parser to reset its internal symbol table during each parse operation. |
true or false. True indicates that the SymbolTable associated with a parser needs to be
reallocated during each parse operation. False indicates that the parser's SymbolTable instance shall be reused during subsequent parse operations. |
false | N/A | No | SAX | Method 2 | 9 | ||
jdk.xml.dtd.support[7] |
Instructs the parser to handle DTDs in accordance with the setting of this property.
The options are:
|
String |
allow, ignore, and deny. Values are case-insensitive.
|
allow | No | Yes |
DOM SAX StAX Validation Transform |
Method 1 | 22 | |
jdk.xml.jdkcatalog.resolve |
Instructs the JDK default CatalogResolver to act in accordance with the setting
of this property when unable to resolve an external reference with the built-in Catalog.
The options are:
|
String |
continue, ignore, and strict. Values are case-insensitive.
|
continue | No | Yes |
DOM SAX StAX Validation Transform |
Method 1 | 22 | |
[1] The full name of a property should be used to set the property.
[2] A value "yes" indicates there is a corresponding System Property for the property, "no" otherwise. The name of the System Property is the same as that of the property.
[3] The value must be exactly as listed in this table, case-sensitive.
The value of the corresponding System Property is the String representation of
the property value. If the type is boolean, the system property is true only
if it is "true"; If the type is String, the system property is true only if
it is exactly the same string representing the positive value (e.g. "yes" for
xsltcIsStandalone); The system property is false otherwise. If the type
is Integer, the value of the System Property is the String representation of
the value (e.g. "64000" for entityExpansionLimit).
[4] A value "yes" indicates the property is a Security Property. As indicated
in the Property Precedence, the values listed in the column
enforced will be used to initialize these properties when
FSP is true.
[5] One or more processors that support the property. The IDs and Set Method are as shown in the table Processors.
[6] Indicates the initial release the property is introduced.
[7] The jdk.xml.dtd.support property complements the two existing
DTD-related properties, disallow-doctype-decl(fully qualified name:
http://apache.org/xml/features/disallow-doctype-decl) and supportDTD
(javax.xml.stream.supportDTD), by providing a uniformed support for the
processors listed and a system property that can be used in the
JAXP Configuration File. When disallow-doctype-decl is
set on the DOM or SAX factory, or supportDTD on StAX factory, the jdk.xml.dtd.support
property will have no effect.
These three properties control whether DTDs as a whole shall be processed. When they are set to deny or ignore, other properties that regulate a part or an aspect of DTD shall have no effect.
The following table lists the properties and their corresponding legacy names.
| Property | Legacy Property Name(s) |
|---|---|
jdk.xml.entityExpansionLimit |
http://www.oracle.com/xml/jaxp/properties/entityExpansionLimit |
jdk.xml.elementAttributeLimit |
http://www.oracle.com/xml/jaxp/properties/elementAttributeLimit |
jdk.xml.maxOccurLimit |
http://www.oracle.com/xml/jaxp/properties/maxOccurLimit |
jdk.xml.totalEntitySizeLimit |
http://www.oracle.com/xml/jaxp/properties/totalEntitySizeLimit |
jdk.xml.maxGeneralEntitySizeLimit |
http://www.oracle.com/xml/jaxp/properties/maxGeneralEntitySizeLimit |
jdk.xml.maxParameterEntitySizeLimit |
http://www.oracle.com/xml/jaxp/properties/maxParameterEntitySizeLimit |
jdk.xml.entityReplacementLimit |
http://www.oracle.com/xml/jaxp/properties/entityReplacementLimit |
jdk.xml.maxElementDepth |
http://www.oracle.com/xml/jaxp/properties/maxElementDepth |
jdk.xml.maxXMLNameLimit |
http://www.oracle.com/xml/jaxp/properties/maxXMLNameLimit |
jdk.xml.isStandalone |
http://www.oracle.com/xml/jaxp/properties/isStandalone |
jdk.xml.xsltcIsStandalone |
http://www.oracle.com/xml/is-standalonehttp://www.oracle.com/xml/jaxp/properties/xsltcIsStandalone |
jdk.xml.extensionClassLoader |
jdk.xml.transform.extensionClassLoader |
jdk.xml.enableExtensionFunctions |
http://www.oracle.com/xml/jaxp/properties/enableExtensionFunctions |
Implementation Note
| Modifier and Type | Package and Description |
|---|---|
| internal package | |
| internal package | com.
This package contains basic classes for the Byte Code Engineering Library and constants defined by the JVM specification. |
| internal package | com.
This package contains the classes that describe the structure of a Java class file and a class file parser. |
| internal package | com.
This package contains the "generic" part of the Byte Code Engineering Library, i.e., classes to dynamically modify class objects and byte code instructions. |
| internal package | com.
This package contains utility classes for the Byte Code Engineering Library, namely:
|
| internal package | com.
Implementation of Xalan Extension Mechanism. |
| internal package | com.
Extension elements and functions shipped with Xalan-Java, including EXSLT functions. |
| internal package | com.
Contains strings that require internationalization. |
| internal package | com.
This package now only contain the classes used by XSLTC. |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | com.
This package provides interfaces for accessing actual value information through PSVI for XML Schema 1.0 data types. |
| package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | com.
Processes SAX events into streams. |
| internal package | |
| internal package | |
| package | com.
Implementation of Xalan utility classes. Exported to |
| internal package | |
| package | com.
Implementation of XPath; for the most part, only classes meant for public use are found at this root level of the XPath packages. Exported to |
| internal package | com.
Implementation of XPath LocationPath support -- primary classes are LocPathIterator and UnionPathIterator. |
| package | com.
Implements an XPath parser which produces an OpMap, and a so-called Compiler which produces an expression tree for fast evaluation. Exported to |
| package | com.
Implements XPath functions -- each function is derived from Function, FunctionOneArg, Function2Args, etc, with number-of-arguments checking being applied mainly at compile time -- this package only implements XPath functions, XSLT functions are found in the "templates" package. Exported to |
| internal package | |
| package | com.
Implementation of XPath polymorphic type objects -- this package will grow as XPath objects are expanded to support XML Schema data types. Exported to |
| internal package | com.
Support for XPath operations, such as +, -, string(), etc.
|
| internal package | com.
Implementation of XPath nodeTest support, and XSLT pattern matching support. |
| package | com.
Contains strings for XPath support that require internationalization. Exported to |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| internal package | |
| exported package | javax.
Defines constants for XML processing. |
| exported package | javax.
Provides the classes for implementing XML Catalogs OASIS Standard V1.1, 7 October 2005. |
| exported package | javax.
Defines XML/Java Type Mappings. |
| exported package | javax.
Defines XML Namespace processing. |
| exported package | javax.
Provides the classes for processing XML documents with a SAX (Simple API for XML) parser or a DOM (Document Object Model) Document builder. |
| exported package | javax.
Defines interfaces and classes for the Streaming API for XML (StAX). |
| exported package | javax.
Defines event interfaces for the Streaming API for XML (StAX). |
| exported package | javax.
Provides utility classes for the Streaming API for XML (StAX). |
| exported package | javax.
Defines the generic APIs for processing transformation instructions, and performing a transformation from source to result. |
| exported package | javax.
Provides DOM specific transformation classes. |
| exported package | javax.
Provides SAX specific transformation classes. |
| exported package | javax.
Provides StAX specific transformation classes. |
| exported package | javax.
Provides stream and URI specific transformation classes. |
| exported package | javax.
Provides an API for validation of XML documents. |
| exported package | javax.
Provides an object-model neutral API for the evaluation of XPath expressions and access to the evaluation environment. |
| internal package | |
| exported package | org.
Provides the interfaces for the Document Object Model (DOM). |
| exported package | org.
Provides a factory for obtaining instances of |
| exported package | org.
Provides interfaces for DOM Level 2 Events. |
| exported package | org.
Provides interfaces for DOM Level 3 Load and Save. |
| exported package | org.
Provides interfaces for DOM Level 2 Range. |
| exported package | org.
Provides interfaces for DOM Level 2 Traversal. |
| exported package | org.
Provides interfaces for DOM Level 2 Views. |
| exported package | org.
Provides the interfaces for the Simple API for XML (SAX). |
| exported package | org.
Provides interfaces to SAX2 facilities that conformant SAX drivers won't necessarily support. |
| exported package | org.
Provides helper classes, including support for bootstrapping SAX-based applications. |