Class CommentLessSource

  • All Implemented Interfaces:
    javax.xml.transform.Source

    public final class CommentLessSource
    extends javax.xml.transform.dom.DOMSource
    A source that is obtained from a different source by stripping all comments.

    As of XMLUnit 2.5.0 it is possible to select the XSLT version to use for the stylesheet. The default now is 2.0, it used to be 1.0 and you may need to change the value if your transformer doesn't support XSLT 2.0.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.String DEFAULT_VERSION  
      static java.lang.String STYLE
      Stylesheet used to strip all comments from an XML document.
      private static java.lang.String STYLE_TEMPLATE  
      • Fields inherited from class javax.xml.transform.dom.DOMSource

        FEATURE
    • Constructor Summary

      Constructors 
      Constructor Description
      CommentLessSource​(javax.xml.transform.Source originalSource)
      Creates a new source that consists of the given source with all comments removed using an XSLT stylesheet of version 2.0.
      CommentLessSource​(javax.xml.transform.Source originalSource, java.lang.String xsltVersion)
      Creates a new source that consists of the given source with all comments removed.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static javax.xml.transform.Source getStylesheet​(java.lang.String xsltVersion)  
      private static java.lang.String getStylesheetContent​(java.lang.String xsltVersion)  
      private static java.lang.String getStylesheetContentCached​(java.lang.String xsltVersion)  
      • Methods inherited from class javax.xml.transform.dom.DOMSource

        getNode, getSystemId, isEmpty, setNode, setSystemId
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • STYLE

        public static final java.lang.String STYLE
        Stylesheet used to strip all comments from an XML document.
    • Constructor Detail

      • CommentLessSource

        public CommentLessSource​(javax.xml.transform.Source originalSource)
        Creates a new source that consists of the given source with all comments removed using an XSLT stylesheet of version 2.0.
        Parameters:
        originalSource - the original source
      • CommentLessSource

        public CommentLessSource​(javax.xml.transform.Source originalSource,
                                 java.lang.String xsltVersion)
        Creates a new source that consists of the given source with all comments removed.
        Parameters:
        originalSource - the original source
        xsltVersion - use this version for the stylesheet
        Since:
        XMLUnit 2.5.0
    • Method Detail

      • getStylesheet

        private static javax.xml.transform.Source getStylesheet​(java.lang.String xsltVersion)
      • getStylesheetContentCached

        private static java.lang.String getStylesheetContentCached​(java.lang.String xsltVersion)
      • getStylesheetContent

        private static java.lang.String getStylesheetContent​(java.lang.String xsltVersion)