Class XMLUnit
- java.lang.Object
-
- org.custommonkey.xmlunit.XMLUnit
-
public final class XMLUnit extends java.lang.ObjectAllows access to project control parameters such as which Parser to use and provides some convenience methods for building Documents from Strings etc.
-
-
Field Summary
Fields Modifier and Type Field Description private static booleancompareUnmatchedprivate static javax.xml.parsers.DocumentBuilderFactorycontrolBuilderFactoryprivate static org.xml.sax.EntityResolvercontrolEntityResolverprivate static booleanenableXXEProtectionprivate static booleanexpandEntitiesprivate static booleanignoreAttributeOrderprivate static booleanignoreCommentsprivate static booleanignoreDiffBetweenTextAndCDATAprivate static booleanignoreWhitespaceprivate static NamespaceContextnamespaceContextprivate static booleannormalizeprivate static booleannormalizeWhitespaceprivate static javax.xml.parsers.SAXParserFactorysaxParserFactoryprivate static java.lang.StringSTRIP_COMMENTS_STYLESHEET_ENDprivate static java.lang.StringSTRIP_COMMENTS_STYLESHEET_STARTprivate static java.lang.StringSTRIP_WHITESPACE_STYLESHEET_ENDprivate static java.lang.StringSTRIP_WHITESPACE_STYLESHEET_STARTprivate static javax.xml.parsers.DocumentBuilderFactorytestBuilderFactoryprivate static org.xml.sax.EntityResolvertestEntityResolverprivate static javax.xml.transform.TransformerFactorytransformerFactoryprivate static javax.xml.transform.URIResolveruriResolverprivate static java.lang.StringxpathFactoryNameprivate static java.lang.StringXSLT_VERSION_ENDprivate static java.lang.StringXSLT_VERSION_STARTprivate static java.lang.StringxsltVersion
-
Constructor Summary
Constructors Modifier Constructor Description privateXMLUnit()Private constructor.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.w3c.dom.DocumentbuildControlDocument(java.lang.String fromXML)Utility method to build a Document using the control DocumentBuilder to parse the specified String.static org.w3c.dom.DocumentbuildControlDocument(org.xml.sax.InputSource fromSource)Utility method to build a Document using the control DocumentBuilder and the specified InputSourcestatic org.w3c.dom.DocumentbuildDocument(javax.xml.parsers.DocumentBuilder withBuilder, java.io.Reader fromReader)Utility method to build a Document using a specific DocumentBuilder and reading characters from a specific Reader.static org.w3c.dom.DocumentbuildDocument(javax.xml.parsers.DocumentBuilder withBuilder, org.xml.sax.InputSource fromSource)Utility method to build a Document using a specific DocumentBuilder and a specific InputSourcestatic org.w3c.dom.DocumentbuildTestDocument(java.lang.String fromXML)Utility method to build a Document using the test DocumentBuilder to parse the specified String.static org.w3c.dom.DocumentbuildTestDocument(org.xml.sax.InputSource fromSource)Utility method to build a Document using the test DocumentBuilder and the specified InputSourcestatic DiffcompareXML(java.io.Reader control, java.io.Reader test)Compare XML documents provided by two Reader classesstatic DiffcompareXML(java.io.Reader control, java.lang.String test)Compare XML documents provided by two Reader classesstatic DiffcompareXML(java.lang.String control, java.io.Reader test)Compare XML documents provided by two Reader classesstatic DiffcompareXML(java.lang.String control, java.lang.String test)Compare two XML documents provided as stringsstatic DiffcompareXML(org.w3c.dom.Document control, org.w3c.dom.Document test)Compare two XML documents provided as stringsstatic DiffcompareXML(org.xml.sax.InputSource control, org.xml.sax.InputSource test)Compare XML documents provided by two InputSource classesstatic booleangetCompareUnmatched()Whether unmatched control nodes should be compared to unmatched test nodes.static javax.xml.parsers.DocumentBuilderFactorygetControlDocumentBuilderFactory()Get theDocumentBuilderFactoryinstance used to instantiate parsers for the control XML in an XMLTestCase.static org.xml.sax.EntityResolvergetControlEntityResolver()Obtains the EntityResolver to be added to all new control parsers.static booleangetEnableXXEProtection()Whether XXE protection is enabled on the factories used by this class.static booleangetExpandEntityReferences()Whether the parser shall be instructed to expand entity references.static booleangetIgnoreAttributeOrder()Whether to ignore the order of attributes on an element.static booleangetIgnoreComments()Whether comments should be ignored.static booleangetIgnoreDiffBetweenTextAndCDATA()Whether CDATA sections and Text nodes should be considered the same.static booleangetIgnoreWhitespace()Whether to ignore whitespace when comparing node values.static booleangetNormalize()Whether Text nodes should be normalized.static booleangetNormalizeWhitespace()Whether whitespace characters inside text nodes or attributes should be "normalized".static javax.xml.parsers.SAXParserFactorygetSAXParserFactory()Get the SAX parser to use in tests.private static java.lang.StringgetStripCommentsStylesheet()static TransformgetStripCommentsTransform(org.w3c.dom.Document forDocument)Obtain the transformation that will strip comments from a DOM.private static java.lang.StringgetStripWhitespaceStylesheet()static TransformgetStripWhitespaceTransform(org.w3c.dom.Document forDocument)Obtain the transformation that will strip whitespace from a DOM containing empty Text nodesstatic javax.xml.parsers.DocumentBuilderFactorygetTestDocumentBuilderFactory()Get theDocumentBuilderFactoryinstance used to instantiate parsers for the test XML in an XMLTestCase.static org.xml.sax.EntityResolvergetTestEntityResolver()Obtains the EntityResolver to be added to all new test parsers.static javax.xml.transform.TransformerFactorygetTransformerFactory()Get the transformer to use for XSLT transformations (and by implication serialization and XPaths).static javax.xml.transform.URIResolvergetURIResolver()Gets the URIResolver used during Transformations.static java.lang.StringgetVersion()Place holder for current version info.static org.w3c.dom.DocumentgetWhitespaceStrippedDocument(org.w3c.dom.Document forDoc)Returns a new Document instance that is identical to the one passed in with element content whitespace removed.static java.lang.StringgetXPathFactory()Gets the class to use as XPathFactory when using JAXP 1.3.static NamespaceContextgetXpathNamespaceContext()Get the NamespaceContext to use in XPath tests.(package private) static java.lang.StringgetXSLTStart()XSLT stylesheet element using the configured XSLT version.static java.lang.StringgetXSLTVersion()The XSLT version set on stylesheets used internally.static javax.xml.parsers.DocumentBuildernewControlParser()Get theDocumentBuilderinstance used to parse the control XML in an XMLTestCase.static javax.xml.parsers.DocumentBuildernewTestParser()Get theDocumentBuilderinstance used to parse the test XML in an XMLTestCase.(package private) static javax.xml.transform.TransformerFactorynewTransformerFactory()Get a fresh transformer to use for XSLT transformations (and by implication serialization and XPaths).static XpathEnginenewXpathEngine()Obtains an XpathEngine to use in XPath tests.static voidsetCompareUnmatched(boolean b)Whether to compare unmatched control nodes to unmatched test nodes.static voidsetControlDocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory factory)Override theDocumentBuilderFactoryused to instantiate parsers for the control XML in an XMLTestCase.static voidsetControlEntityResolver(org.xml.sax.EntityResolver resolver)Sets an EntityResolver to be added to all new control parsers.static voidsetControlParser(java.lang.String className)Overide the DocumentBuilder to use to parse control documents.static voidsetEnableXXEProtection(boolean b)Whether to enable XXE protection on the factories used by this class.static voidsetExpandEntityReferences(boolean b)Whether the parser shall be instructed to expand entity references.static voidsetIgnoreAttributeOrder(boolean b)Whether to ignore the order of attributes on an element.static voidsetIgnoreComments(boolean b)Whether comments should be ignored.static voidsetIgnoreDiffBetweenTextAndCDATA(boolean b)Whether CDATA sections and Text nodes should be considered the same.static voidsetIgnoreWhitespace(boolean ignore)Whether to ignore whitespace when comparing node values.static voidsetNormalize(boolean b)Whether Text nodes should be normalized.static voidsetNormalizeWhitespace(boolean b)Whether whitespace characters inside text nodes or attributes should be "normalized".static voidsetSAXParserFactory(java.lang.String className)Override the SAX parser to use in tests.static voidsetSAXParserFactory(javax.xml.parsers.SAXParserFactory factory)Override the SAX parser to use in tests.static voidsetTestDocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory factory)Override theDocumentBuilderFactoryused to instantiate parsers for the test XML in an XMLTestCase.static voidsetTestEntityResolver(org.xml.sax.EntityResolver resolver)Sets an EntityResolver to be added to all new test parsers.static voidsetTestParser(java.lang.String className)Overide the DocumentBuilder to use to parser test documents.static voidsetTransformerFactory(java.lang.String className)Overide the transformer to use for XSLT transformations (and by implication serialization and XPaths).static voidsetURIResolver(javax.xml.transform.URIResolver resolver)Sets the URIResolver to use during transformations.static voidsetXPathFactory(java.lang.String className)Sets the class to use as XPathFactory when using JAXP 1.3.static voidsetXpathNamespaceContext(NamespaceContext ctx)Set the NamespaceContext to use in XPath tests.static voidsetXSLTVersion(java.lang.String s)Sets the XSLT version to set on stylesheets used internally.private static voidstripEmptyTextNodes(org.w3c.dom.Node n)private static org.w3c.dom.DocumentstripWhiteSpaceUsingXSLT(org.w3c.dom.Document forDoc)private static org.w3c.dom.DocumentstripWhiteSpaceWithoutXSLT(org.w3c.dom.Document forDoc)
-
-
-
Field Detail
-
controlBuilderFactory
private static javax.xml.parsers.DocumentBuilderFactory controlBuilderFactory
-
testBuilderFactory
private static javax.xml.parsers.DocumentBuilderFactory testBuilderFactory
-
transformerFactory
private static javax.xml.transform.TransformerFactory transformerFactory
-
saxParserFactory
private static javax.xml.parsers.SAXParserFactory saxParserFactory
-
ignoreWhitespace
private static boolean ignoreWhitespace
-
uriResolver
private static javax.xml.transform.URIResolver uriResolver
-
testEntityResolver
private static org.xml.sax.EntityResolver testEntityResolver
-
controlEntityResolver
private static org.xml.sax.EntityResolver controlEntityResolver
-
namespaceContext
private static NamespaceContext namespaceContext
-
ignoreDiffBetweenTextAndCDATA
private static boolean ignoreDiffBetweenTextAndCDATA
-
ignoreComments
private static boolean ignoreComments
-
normalize
private static boolean normalize
-
normalizeWhitespace
private static boolean normalizeWhitespace
-
ignoreAttributeOrder
private static boolean ignoreAttributeOrder
-
xsltVersion
private static java.lang.String xsltVersion
-
xpathFactoryName
private static java.lang.String xpathFactoryName
-
expandEntities
private static boolean expandEntities
-
compareUnmatched
private static boolean compareUnmatched
-
enableXXEProtection
private static boolean enableXXEProtection
-
XSLT_VERSION_START
private static final java.lang.String XSLT_VERSION_START
- See Also:
- Constant Field Values
-
XSLT_VERSION_END
private static final java.lang.String XSLT_VERSION_END
- See Also:
- Constant Field Values
-
STRIP_WHITESPACE_STYLESHEET_START
private static final java.lang.String STRIP_WHITESPACE_STYLESHEET_START
-
STRIP_WHITESPACE_STYLESHEET_END
private static final java.lang.String STRIP_WHITESPACE_STYLESHEET_END
-
STRIP_COMMENTS_STYLESHEET_START
private static final java.lang.String STRIP_COMMENTS_STYLESHEET_START
-
STRIP_COMMENTS_STYLESHEET_END
private static final java.lang.String STRIP_COMMENTS_STYLESHEET_END
-
-
Method Detail
-
setControlParser
public static void setControlParser(java.lang.String className)
Overide the DocumentBuilder to use to parse control documents. This is useful when comparing the output of two different parsers. Note: setting the control parser before any test cases are run will affect the test parser as well.
-
newControlParser
public static javax.xml.parsers.DocumentBuilder newControlParser() throws ConfigurationExceptionGet theDocumentBuilderinstance used to parse the control XML in an XMLTestCase.- Returns:
- parser for control values
- Throws:
ConfigurationException
-
setTestEntityResolver
public static void setTestEntityResolver(org.xml.sax.EntityResolver resolver)
Sets an EntityResolver to be added to all new test parsers. Setting to null will reset to the default EntityResolver
-
setControlEntityResolver
public static void setControlEntityResolver(org.xml.sax.EntityResolver resolver)
Sets an EntityResolver to be added to all new control parsers. Setting to null will reset to the default EntityResolver
-
getControlEntityResolver
public static org.xml.sax.EntityResolver getControlEntityResolver()
Obtains the EntityResolver to be added to all new control parsers.
-
getTestEntityResolver
public static org.xml.sax.EntityResolver getTestEntityResolver()
Obtains the EntityResolver to be added to all new test parsers.
-
getControlDocumentBuilderFactory
public static javax.xml.parsers.DocumentBuilderFactory getControlDocumentBuilderFactory()
Get theDocumentBuilderFactoryinstance used to instantiate parsers for the control XML in an XMLTestCase.- Returns:
- factory for control parsers
-
setControlDocumentBuilderFactory
public static void setControlDocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory factory)
Override theDocumentBuilderFactoryused to instantiate parsers for the control XML in an XMLTestCase.
-
setTestParser
public static void setTestParser(java.lang.String className)
Overide the DocumentBuilder to use to parser test documents. This is useful when comparing the output of two different parsers. Note: setting the test parser before any test cases are run will affect the control parser as well.
-
newTestParser
public static javax.xml.parsers.DocumentBuilder newTestParser() throws ConfigurationExceptionGet theDocumentBuilderinstance used to parse the test XML in an XMLTestCase.- Returns:
- parser for test values
- Throws:
ConfigurationException
-
getTestDocumentBuilderFactory
public static javax.xml.parsers.DocumentBuilderFactory getTestDocumentBuilderFactory()
Get theDocumentBuilderFactoryinstance used to instantiate parsers for the test XML in an XMLTestCase.- Returns:
- factory for test parsers
-
setTestDocumentBuilderFactory
public static void setTestDocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory factory)
Override theDocumentBuilderFactoryused to instantiate parsers for the test XML in an XMLTestCase.
-
setIgnoreWhitespace
public static void setIgnoreWhitespace(boolean ignore)
Whether to ignore whitespace when comparing node values.This method also invokes
setIgnoringElementContentWhitespace()on the underlying control AND test document builder factories.Setting this parameter has no effect on
whitespace inside texts.
-
getIgnoreWhitespace
public static boolean getIgnoreWhitespace()
Whether to ignore whitespace when comparing node values.- Returns:
- true if whitespace should be ignored when comparing nodes, false otherwise
-
buildControlDocument
public static org.w3c.dom.Document buildControlDocument(java.lang.String fromXML) throws org.xml.sax.SAXException, java.io.IOExceptionUtility method to build a Document using the control DocumentBuilder to parse the specified String.- Parameters:
fromXML-- Returns:
- Document representation of the String content
- Throws:
org.xml.sax.SAXExceptionjava.io.IOException
-
buildControlDocument
public static org.w3c.dom.Document buildControlDocument(org.xml.sax.InputSource fromSource) throws java.io.IOException, org.xml.sax.SAXExceptionUtility method to build a Document using the control DocumentBuilder and the specified InputSource- Parameters:
fromSource-- Returns:
- Document representation of the String content
- Throws:
org.xml.sax.SAXExceptionjava.io.IOException
-
buildTestDocument
public static org.w3c.dom.Document buildTestDocument(java.lang.String fromXML) throws org.xml.sax.SAXException, java.io.IOExceptionUtility method to build a Document using the test DocumentBuilder to parse the specified String.- Parameters:
fromXML-- Returns:
- Document representation of the String content
- Throws:
org.xml.sax.SAXExceptionjava.io.IOException
-
buildTestDocument
public static org.w3c.dom.Document buildTestDocument(org.xml.sax.InputSource fromSource) throws java.io.IOException, org.xml.sax.SAXExceptionUtility method to build a Document using the test DocumentBuilder and the specified InputSource- Parameters:
fromSource-- Returns:
- Document representation of the String content
- Throws:
org.xml.sax.SAXExceptionjava.io.IOException
-
buildDocument
public static org.w3c.dom.Document buildDocument(javax.xml.parsers.DocumentBuilder withBuilder, java.io.Reader fromReader) throws org.xml.sax.SAXException, java.io.IOExceptionUtility method to build a Document using a specific DocumentBuilder and reading characters from a specific Reader.- Parameters:
withBuilder-fromReader-- Returns:
- Document built
- Throws:
org.xml.sax.SAXExceptionjava.io.IOException
-
buildDocument
public static org.w3c.dom.Document buildDocument(javax.xml.parsers.DocumentBuilder withBuilder, org.xml.sax.InputSource fromSource) throws java.io.IOException, org.xml.sax.SAXExceptionUtility method to build a Document using a specific DocumentBuilder and a specific InputSource- Parameters:
withBuilder-fromSource-- Returns:
- Document built
- Throws:
org.xml.sax.SAXExceptionjava.io.IOException
-
setTransformerFactory
public static void setTransformerFactory(java.lang.String className)
Overide the transformer to use for XSLT transformations (and by implication serialization and XPaths). This is useful when comparing transformer implementations.
-
getTransformerFactory
public static javax.xml.transform.TransformerFactory getTransformerFactory()
Get the transformer to use for XSLT transformations (and by implication serialization and XPaths).- Returns:
- the current transformer factory in use a new instance of the default transformer factory
-
newTransformerFactory
static javax.xml.transform.TransformerFactory newTransformerFactory()
Get a fresh transformer to use for XSLT transformations (and by implication serialization and XPaths).- Returns:
- a new instance of the default transformer factory
-
setURIResolver
public static void setURIResolver(javax.xml.transform.URIResolver resolver)
Sets the URIResolver to use during transformations.
-
getURIResolver
public static javax.xml.transform.URIResolver getURIResolver()
Gets the URIResolver used during Transformations.
-
setSAXParserFactory
public static void setSAXParserFactory(java.lang.String className)
Override the SAX parser to use in tests. Currently only used byValidator class- Parameters:
className-
-
setSAXParserFactory
public static void setSAXParserFactory(javax.xml.parsers.SAXParserFactory factory)
Override the SAX parser to use in tests. Currently only used byValidator class- Parameters:
factory-
-
getSAXParserFactory
public static javax.xml.parsers.SAXParserFactory getSAXParserFactory()
Get the SAX parser to use in tests.Unless an instance has been given via
setSAXParserFactoryexplicitly, the returned factory will be namespace aware.- Returns:
- the SAXParserFactory instance used by the
Validatorto perform DTD validation
-
getStripWhitespaceStylesheet
private static java.lang.String getStripWhitespaceStylesheet()
-
getStripWhitespaceTransform
public static Transform getStripWhitespaceTransform(org.w3c.dom.Document forDocument)
Obtain the transformation that will strip whitespace from a DOM containing empty Text nodes- Parameters:
forDocument-- Returns:
- a
Transformto do the whitespace stripping
-
getWhitespaceStrippedDocument
public static org.w3c.dom.Document getWhitespaceStrippedDocument(org.w3c.dom.Document forDoc)
Returns a new Document instance that is identical to the one passed in with element content whitespace removed.Will use
getStripWhitespaceTransformunless we are operating under the severly broken XSLTC Transformer shipping with JDK 1.5.
-
stripWhiteSpaceUsingXSLT
private static org.w3c.dom.Document stripWhiteSpaceUsingXSLT(org.w3c.dom.Document forDoc)
-
stripWhiteSpaceWithoutXSLT
private static org.w3c.dom.Document stripWhiteSpaceWithoutXSLT(org.w3c.dom.Document forDoc)
-
stripEmptyTextNodes
private static void stripEmptyTextNodes(org.w3c.dom.Node n)
-
getStripCommentsStylesheet
private static java.lang.String getStripCommentsStylesheet()
-
getStripCommentsTransform
public static Transform getStripCommentsTransform(org.w3c.dom.Document forDocument)
Obtain the transformation that will strip comments from a DOM.- Parameters:
forDocument-- Returns:
- a
Transformto do the whitespace stripping
-
getVersion
public static java.lang.String getVersion()
Place holder for current version info.- Returns:
- current version
-
compareXML
public static Diff compareXML(org.xml.sax.InputSource control, org.xml.sax.InputSource test) throws org.xml.sax.SAXException, java.io.IOException
Compare XML documents provided by two InputSource classes- Parameters:
control- Control documenttest- Document to test- Returns:
- Diff object describing differences in documents
- Throws:
org.xml.sax.SAXExceptionjava.io.IOException
-
compareXML
public static Diff compareXML(java.io.Reader control, java.io.Reader test) throws org.xml.sax.SAXException, java.io.IOException
Compare XML documents provided by two Reader classes- Parameters:
control- Control documenttest- Document to test- Returns:
- Diff object describing differences in documents
- Throws:
org.xml.sax.SAXExceptionjava.io.IOException
-
compareXML
public static Diff compareXML(java.lang.String control, java.io.Reader test) throws org.xml.sax.SAXException, java.io.IOException
Compare XML documents provided by two Reader classes- Parameters:
control- Control documenttest- Document to test- Returns:
- Diff object describing differences in documents
- Throws:
org.xml.sax.SAXExceptionjava.io.IOException
-
compareXML
public static Diff compareXML(java.io.Reader control, java.lang.String test) throws org.xml.sax.SAXException, java.io.IOException
Compare XML documents provided by two Reader classes- Parameters:
control- Control documenttest- Document to test- Returns:
- Diff object describing differences in documents
- Throws:
org.xml.sax.SAXExceptionjava.io.IOException
-
compareXML
public static Diff compareXML(java.lang.String control, java.lang.String test) throws org.xml.sax.SAXException, java.io.IOException
Compare two XML documents provided as strings- Parameters:
control- Control documenttest- Document to test- Returns:
- Diff object describing differences in documents
- Throws:
org.xml.sax.SAXExceptionjava.io.IOException
-
compareXML
public static Diff compareXML(org.w3c.dom.Document control, org.w3c.dom.Document test)
Compare two XML documents provided as strings- Parameters:
control- Control documenttest- Document to test- Returns:
- Diff object describing differences in documents
-
getXpathNamespaceContext
public static NamespaceContext getXpathNamespaceContext()
Get the NamespaceContext to use in XPath tests.
-
setXpathNamespaceContext
public static void setXpathNamespaceContext(NamespaceContext ctx)
Set the NamespaceContext to use in XPath tests.
-
newXpathEngine
public static XpathEngine newXpathEngine()
Obtains an XpathEngine to use in XPath tests.
-
setIgnoreDiffBetweenTextAndCDATA
public static void setIgnoreDiffBetweenTextAndCDATA(boolean b)
Whether CDATA sections and Text nodes should be considered the same.The default is false.
This also set the DocumentBuilderFactory's
coalescingflag on the factories for the control and test document.
-
getIgnoreDiffBetweenTextAndCDATA
public static boolean getIgnoreDiffBetweenTextAndCDATA()
Whether CDATA sections and Text nodes should be considered the same.- Returns:
- false by default
-
setIgnoreComments
public static void setIgnoreComments(boolean b)
Whether comments should be ignored.The default value is false
-
getIgnoreComments
public static boolean getIgnoreComments()
Whether comments should be ignored.The default value is false
-
setNormalize
public static void setNormalize(boolean b)
Whether Text nodes should be normalized.The default value is false
Note: if you are only working with documents read from streams (like files or network connections) or working with strings, there is no reason to change the default since the XML parser is required to normalize the documents. If you are testing
Documentinstances you've created in code, you may want to alter the default behavior.Note2: depending on the XML parser or XSLT transformer you use, setting
ignoreWhitespaceorignoreCommentsto true may have already normalized your document and this setting doesn't have any effect anymore.
-
getNormalize
public static boolean getNormalize()
Whether Text nodes should be normalized.The default value is false
-
setNormalizeWhitespace
public static void setNormalizeWhitespace(boolean b)
Whether whitespace characters inside text nodes or attributes should be "normalized".Normalized in this context means that all whitespace is replaced by the space character and adjacent whitespace characters are collapsed to a single space character. It will also trim the resulting character content on both ends.
The default value is false.
Setting this parameter has no effect on
ignorable whitespace.
-
getNormalizeWhitespace
public static boolean getNormalizeWhitespace()
Whether whitespace characters inside text nodes or attributes should be "normalized".Normalized in this context means that all whitespace is replaced by the space character and adjacent whitespace characters are collapsed to a single space character.
The default value is false.
-
setIgnoreAttributeOrder
public static void setIgnoreAttributeOrder(boolean b)
Whether to ignore the order of attributes on an element.The order of attributes has never been relevant for XML documents, still XMLUnit can consider two pieces of XML not-identical (but similar) if they differ in order of attributes. Set this option to true to compare the order.
The default value is true
-
getIgnoreAttributeOrder
public static boolean getIgnoreAttributeOrder()
Whether to ignore the order of attributes on an element.The order of attributes has never been relevant for XML documents, still XMLUnit can consider two pieces of XML not-identical (but similar) if they differ in order of attributes. Set this option to true to compare the order.
The default value is true
-
setXSLTVersion
public static void setXSLTVersion(java.lang.String s)
Sets the XSLT version to set on stylesheets used internally.Defaults to "1.0".
- Throws:
ConfigurationException- if the argument cannot be parsed as a positive number.
-
getXSLTVersion
public static java.lang.String getXSLTVersion()
The XSLT version set on stylesheets used internally.Defaults to "1.0".
-
setXPathFactory
public static void setXPathFactory(java.lang.String className)
Sets the class to use as XPathFactory when using JAXP 1.3.
-
getXPathFactory
public static java.lang.String getXPathFactory()
Gets the class to use as XPathFactory when using JAXP 1.3.
-
getXSLTStart
static java.lang.String getXSLTStart()
XSLT stylesheet element using the configured XSLT version.
-
setExpandEntityReferences
public static void setExpandEntityReferences(boolean b)
Whether the parser shall be instructed to expand entity references.Defaults to false.
- See Also:
DocumentBuilderFactory.setExpandEntityReferences(boolean)
-
getExpandEntityReferences
public static boolean getExpandEntityReferences()
Whether the parser shall be instructed to expand entity references.
-
setCompareUnmatched
public static void setCompareUnmatched(boolean b)
Whether to compare unmatched control nodes to unmatched test nodes.Defaults to true.
-
getCompareUnmatched
public static boolean getCompareUnmatched()
Whether unmatched control nodes should be compared to unmatched test nodes.- Returns:
- true by default
-
setEnableXXEProtection
public static void setEnableXXEProtection(boolean b)
Whether to enable XXE protection on the factories used by this class.- Since:
- XMLUnit 2.6.0
- See Also:
- "https://www.owasp.org/index.php/XML_External_Entity_(XXE)_Prevention_Cheat_Sheet"
-
getEnableXXEProtection
public static boolean getEnableXXEProtection()
Whether XXE protection is enabled on the factories used by this class.- Since:
- XMLUnit 2.6.0
- See Also:
- "https://www.owasp.org/index.php/XML_External_Entity_(XXE)_Prevention_Cheat_Sheet"
-
-