Package com.helger.xml
Class XMLFactory
java.lang.Object
com.helger.xml.XMLFactory
Utility class for creating XML DOM documents.
- Author:
- Philip Helger
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleanDocumentBuilderFactory is by default coalescingstatic final booleanDocumentBuilderFactory is by default entity reference expandingstatic final booleanDocumentBuilderFactory is by default ignoring commentsstatic final booleanDocumentBuilderFactory is by default not ignoring element content whitespacestatic final booleanDocumentBuilderFactory is by default not namespace awarestatic final booleanDocumentBuilderFactory is by default not DTD validatingstatic final booleanDocumentBuilderFactory is by default not XInclude awarestatic final booleanSAXParserFactory is by default not namespace awarestatic final booleanSAXParserFactory is by default not DTD validatingstatic final booleanSAXParserFactory is by default not XInclude aware -
Method Summary
Modifier and TypeMethodDescriptionstatic DocumentBuilderFactoryCreate a newDocumentBuilderFactoryusing the defaults defined in this class (DEFAULT_DOM_NAMESPACE_AWARE,DEFAULT_DOM_VALIDATING,DEFAULT_DOM_IGNORING_ELEMENT_CONTENT_WHITESPACE,DEFAULT_DOM_EXPAND_ENTITY_REFERENCES,DEFAULT_DOM_IGNORING_COMMENTSandDEFAULT_DOM_COALESCING.).static SAXParserFactorystatic TransformerFactorystatic DocumentBuilderCreate 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 voidstatic voidstatic voidstatic DocumentBuilderstatic DocumentBuilderFactorystatic DOMImplementationstatic DocumentCreate 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 the document builder factory.static voidsetFeature(DocumentBuilderFactory aFactory, EXMLParserFeature eFeature, boolean bValue) static voidsetFeature(SAXParserFactory aFactory, EXMLParserFeature eFeature, boolean bValue) static voidsetFeature(TransformerFactory aFactory, EXMLParserFeature eFeature, boolean bValue, boolean bLogOnError)
-
Field Details
-
DEFAULT_DOM_NAMESPACE_AWARE
public static final boolean DEFAULT_DOM_NAMESPACE_AWAREDocumentBuilderFactory is by default not namespace aware- See Also:
-
DEFAULT_DOM_VALIDATING
public static final boolean DEFAULT_DOM_VALIDATINGDocumentBuilderFactory is by default not DTD validating- See Also:
-
DEFAULT_DOM_IGNORING_ELEMENT_CONTENT_WHITESPACE
public static final boolean DEFAULT_DOM_IGNORING_ELEMENT_CONTENT_WHITESPACEDocumentBuilderFactory is by default not ignoring element content whitespace- See Also:
-
DEFAULT_DOM_EXPAND_ENTITY_REFERENCES
public static final boolean DEFAULT_DOM_EXPAND_ENTITY_REFERENCESDocumentBuilderFactory is by default entity reference expanding- See Also:
-
DEFAULT_DOM_IGNORING_COMMENTS
public static final boolean DEFAULT_DOM_IGNORING_COMMENTSDocumentBuilderFactory is by default ignoring comments- See Also:
-
DEFAULT_DOM_COALESCING
public static final boolean DEFAULT_DOM_COALESCINGDocumentBuilderFactory is by default coalescing- See Also:
-
DEFAULT_DOM_XINCLUDE_AWARE
public static final boolean DEFAULT_DOM_XINCLUDE_AWAREDocumentBuilderFactory is by default not XInclude aware- See Also:
-
DEFAULT_SAX_NAMESPACE_AWARE
public static final boolean DEFAULT_SAX_NAMESPACE_AWARESAXParserFactory is by default not namespace aware- See Also:
-
DEFAULT_SAX_VALIDATING
public static final boolean DEFAULT_SAX_VALIDATINGSAXParserFactory is by default not DTD validating- See Also:
-
DEFAULT_SAX_XINCLUDE_AWARE
public static final boolean DEFAULT_SAX_XINCLUDE_AWARESAXParserFactory is by default not XInclude aware- See Also:
-
-
Method Details
-
reinitialize
public static void reinitialize()Reinitialize the document builder factory. This may be necessary if the system properties change! -
setFeature
public static void setFeature(@Nonnull DocumentBuilderFactory aFactory, @Nonnull EXMLParserFeature eFeature, boolean bValue) -
defaultCustomizeDocumentBuilderFactory
-
createDefaultDocumentBuilderFactory
Create a newDocumentBuilderFactoryusing the defaults defined in this class (DEFAULT_DOM_NAMESPACE_AWARE,DEFAULT_DOM_VALIDATING,DEFAULT_DOM_IGNORING_ELEMENT_CONTENT_WHITESPACE,DEFAULT_DOM_EXPAND_ENTITY_REFERENCES,DEFAULT_DOM_IGNORING_COMMENTSandDEFAULT_DOM_COALESCING.).- Returns:
- Never
null.
-
createDocumentBuilderFactory
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
- Returns:
- The default document builder factory that is not schema specific.
Never
null.
-
getDocumentBuilder
- Returns:
- The default document builder that is not schema specific. Never
null.
-
getDOMImplementation
- Returns:
- The DOM implementation of the default document builder. Never
null.
-
createDocumentBuilder
Create a document builder without a certain schema, using the defaultDocumentBuilderFactory.- Returns:
- The created document builder. Never
null.
-
createDocumentBuilder
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
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
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
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.
-
setFeature
public static void setFeature(@Nonnull SAXParserFactory aFactory, @Nonnull EXMLParserFeature eFeature, boolean bValue) -
defaultCustomizeSAXParserFactory
-
createDefaultSAXParserFactory
-
setFeature
public static void setFeature(@Nonnull TransformerFactory aFactory, @Nonnull EXMLParserFeature eFeature, boolean bValue, boolean bLogOnError) -
defaultCustomizeTransformerFactory
-
createDefaultTransformerFactory
-