Package com.helger.xml
Class XMLFactory
- java.lang.Object
-
- com.helger.xml.XMLFactory
-
public final class XMLFactory extends Object
Utility class for creating XML DOM documents.- Author:
- Philip Helger
-
-
Field Summary
Fields Modifier and Type Field Description static booleanDEFAULT_DOM_COALESCINGDocumentBuilderFactory is by default coalescingstatic booleanDEFAULT_DOM_EXPAND_ENTITY_REFERENCESDocumentBuilderFactory is by default entity reference expandingstatic booleanDEFAULT_DOM_IGNORING_COMMENTSDocumentBuilderFactory is by default ignoring commentsstatic booleanDEFAULT_DOM_IGNORING_ELEMENT_CONTENT_WHITESPACEDocumentBuilderFactory is by default not ignoring element content whitespacestatic booleanDEFAULT_DOM_NAMESPACE_AWAREDocumentBuilderFactory is by default namespace awarestatic booleanDEFAULT_DOM_VALIDATINGDocumentBuilderFactory is by default not DTD validatingstatic booleanDEFAULT_DOM_XINCLUDE_AWAREDocumentBuilderFactory is by default not XInclude aware
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static DocumentBuilderFactorycreateDefaultDocumentBuilderFactory()Create a newDocumentBuilderFactoryusing the defaults defined in this class (DEFAULT_DOM_NAMESPACE_AWARE,DEFAULT_DOM_VALIDATINGetc.).static DocumentBuildercreateDocumentBuilder()Create a document builder without a certain schema, using the defaultDocumentBuilderFactory.static DocumentBuildercreateDocumentBuilder(DocumentBuilderFactory aDocBuilderFactory)Create a document builder without a certain schema, using the passedDocumentBuilderFactory.static DocumentBuildercreateDocumentBuilder(Schema aSchema)Create a document builder for a certain schema.static DocumentBuilderFactorycreateDocumentBuilderFactory(Schema aSchema)Create a newDocumentBuilderFactoryfor the specified schema, with the following settings: coalescing, comment ignoring and namespace aware.static DocumentBuildergetDocumentBuilder()static DocumentBuilderFactorygetDocumentBuilderFactory()static DOMImplementationgetDOMImplementation()static DocumentnewDocument()Create a new XML document without document type using versionEXMLVersion.XML_10.static DocumentnewDocument(EXMLVersion eVersion)Create a new XML document without document type using the default document builder.static DocumentnewDocument(EXMLVersion eVersion, String sQualifiedName, String sPublicId, String sSystemId)Create a new document with a document type using the default document builder.static DocumentnewDocument(String sQualifiedName, String sPublicId, String sSystemId)Create a new document with a document type using versionEXMLVersion.XML_10.static DocumentnewDocument(DocumentBuilder aDocBuilder)Create a new XML document without document type using versionEXMLVersion.XML_10.static DocumentnewDocument(DocumentBuilder aDocBuilder, EXMLVersion eVersion)Create a new XML document without document type using a custom document builder.static DocumentnewDocument(DocumentBuilder aDocBuilder, EXMLVersion eVersion, String sQualifiedName, String sPublicId, String sSystemId)Create a new document with a document type using a custom document builder.static voidreinitialize()Reinitialize the document builder factory.
-
-
-
Field Detail
-
DEFAULT_DOM_NAMESPACE_AWARE
public static final boolean DEFAULT_DOM_NAMESPACE_AWARE
DocumentBuilderFactory is by default namespace aware- See Also:
- Constant Field Values
-
DEFAULT_DOM_VALIDATING
public static final boolean DEFAULT_DOM_VALIDATING
DocumentBuilderFactory is by default not DTD validating- See Also:
- Constant Field Values
-
DEFAULT_DOM_IGNORING_ELEMENT_CONTENT_WHITESPACE
public static final boolean DEFAULT_DOM_IGNORING_ELEMENT_CONTENT_WHITESPACE
DocumentBuilderFactory is by default not ignoring element content whitespace- See Also:
- Constant Field Values
-
DEFAULT_DOM_EXPAND_ENTITY_REFERENCES
public static final boolean DEFAULT_DOM_EXPAND_ENTITY_REFERENCES
DocumentBuilderFactory is by default entity reference expanding- See Also:
- Constant Field Values
-
DEFAULT_DOM_IGNORING_COMMENTS
public static final boolean DEFAULT_DOM_IGNORING_COMMENTS
DocumentBuilderFactory is by default ignoring comments- See Also:
- Constant Field Values
-
DEFAULT_DOM_COALESCING
public static final boolean DEFAULT_DOM_COALESCING
DocumentBuilderFactory is by default coalescing- See Also:
- Constant Field Values
-
DEFAULT_DOM_XINCLUDE_AWARE
public static final boolean DEFAULT_DOM_XINCLUDE_AWARE
DocumentBuilderFactory is by default not XInclude aware- See Also:
- Constant Field Values
-
-
Method Detail
-
reinitialize
public static void reinitialize()
Reinitialize the document builder factory. This may be necessary if the system properties change!
-
createDefaultDocumentBuilderFactory
@Nonnull public static DocumentBuilderFactory createDefaultDocumentBuilderFactory()
Create a newDocumentBuilderFactoryusing the defaults defined in this class (DEFAULT_DOM_NAMESPACE_AWARE,DEFAULT_DOM_VALIDATINGetc.).- Returns:
- Never
null.
-
createDocumentBuilderFactory
@Nonnull public static DocumentBuilderFactory createDocumentBuilderFactory(@Nonnull Schema aSchema)
Create a newDocumentBuilderFactoryfor the specified schema, with the following settings: coalescing, comment ignoring and namespace aware.- Parameters:
aSchema- The schema to use. May not benull.- Returns:
- Never
null.
-
getDocumentBuilderFactory
@Nonnull public static DocumentBuilderFactory getDocumentBuilderFactory()
- Returns:
- The default document builder factory that is not schema specific.
Never
null.
-
getDocumentBuilder
@Nonnull public static DocumentBuilder getDocumentBuilder()
- Returns:
- The default document builder that is not schema specific. Never
null.
-
getDOMImplementation
@Nonnull public static DOMImplementation getDOMImplementation()
- Returns:
- The DOM implementation of the default document builder. Never
null.
-
createDocumentBuilder
@Nonnull public static DocumentBuilder createDocumentBuilder()
Create a document builder without a certain schema, using the defaultDocumentBuilderFactory.- Returns:
- The created document builder. Never
null.
-
createDocumentBuilder
@Nonnull public static DocumentBuilder createDocumentBuilder(@Nonnull Schema aSchema)
Create a document builder for a certain schema.- Parameters:
aSchema- The schema to use. May not benull.- Returns:
- The created document builder. Never
null.
-
createDocumentBuilder
@Nonnull public static DocumentBuilder createDocumentBuilder(@Nonnull DocumentBuilderFactory aDocBuilderFactory)
Create a document builder without a certain schema, using the passedDocumentBuilderFactory.- Parameters:
aDocBuilderFactory- The document builder factory to be used. May not benull.- Returns:
- The created document builder. Never
null. - Throws:
com.helger.commons.exception.InitializationException- In case some DOM initialization goes wrong
-
newDocument
@Nonnull public static Document newDocument()
Create a new XML document without document type using versionEXMLVersion.XML_10. The default document builder is used.- Returns:
- The created document. Never
null.
-
newDocument
@Nonnull public static Document newDocument(@Nonnull DocumentBuilder aDocBuilder)
Create a new XML document without document type using versionEXMLVersion.XML_10. A custom document builder is used.- Parameters:
aDocBuilder- The document builder to use. May not benull.- Returns:
- The created document. Never
null.
-
newDocument
@Nonnull public static Document newDocument(@Nullable EXMLVersion eVersion)
Create a new XML document without document type using the default document builder.- Parameters:
eVersion- The XML version to use. Ifnullis passed,EXMLVersion.XML_10will be used.- Returns:
- The created document. Never
null.
-
newDocument
@Nonnull public static Document newDocument(@Nonnull DocumentBuilder aDocBuilder, @Nullable EXMLVersion eVersion)
Create a new XML document without document type using a custom document builder.- Parameters:
aDocBuilder- The document builder to use. May not benull.eVersion- The XML version to use. Ifnullis passed,EXMLVersion.XML_10will be used.- Returns:
- The created document. Never
null.
-
newDocument
@Nonnull public static Document newDocument(@Nonnull String sQualifiedName, @Nullable String sPublicId, @Nullable String sSystemId)
Create a new document with a document type using versionEXMLVersion.XML_10.- Parameters:
sQualifiedName- The qualified name to use.sPublicId- The public ID of the document type.sSystemId- The system ID of the document type.- Returns:
- The created document. Never
null.
-
newDocument
@Nonnull public static Document newDocument(@Nullable EXMLVersion eVersion, @Nonnull String sQualifiedName, @Nullable String sPublicId, @Nullable String sSystemId)
Create a new document with a document type using the default document builder.- Parameters:
eVersion- The XML version to use. Ifnullis passed,EXMLVersion.XML_10will be used.sQualifiedName- The qualified name to use.sPublicId- The public ID of the document type.sSystemId- The system ID of the document type.- Returns:
- The created document. Never
null.
-
newDocument
@Nonnull public static Document newDocument(@Nonnull DocumentBuilder aDocBuilder, @Nullable EXMLVersion eVersion, @Nonnull String sQualifiedName, @Nullable String sPublicId, @Nullable String sSystemId)
Create a new document with a document type using a custom document builder.- Parameters:
aDocBuilder- the document builder to be used. May not benull.eVersion- The XML version to use. Ifnullis passed,EXMLVersion.XML_10will be used.sQualifiedName- The qualified name to use.sPublicId- The public ID of the document type.sSystemId- The system ID of the document type.- Returns:
- The created document. Never
null.
-
-