Class Convert

java.lang.Object
org.xmlunit.util.Convert

public final class Convert extends Object
Conversion methods.
  • Constructor Details

    • Convert

      private Convert()
  • Method Details

    • toInputSource

      public static InputSource toInputSource(Source s)
      Creates a SAX InputSource from a TraX Source.

      May use an XSLT identity transformation if SAXSource cannot convert it directly.

      Parameters:
      s - the source to convert
    • toInputSource

      public static InputSource toInputSource(Source s, TransformerFactory fac)
      Creates a SAX InputSource from a TraX Source.

      May use an XSLT identity transformation if SAXSource cannot convert it directly.

      Parameters:
      s - the source to convert
      fac - the TransformerFactory to use, will use the defaul factory if the value is null.
    • toDocument

      public static Document toDocument(Source s)
      Creates a DOM Document from a TraX Source.

      If the source is a DOMSource holding a Document Node, this one will be returned. Otherwise toInputSource(javax.xml.transform.Source) and a namespace aware DocumentBuilder (created by the default DocumentBuilderFactory) will be used to read the source. This may involve an XSLT identity transform in toInputSource.

    • toDocument

      public static Document toDocument(Source s, DocumentBuilderFactory factory)
      Creates a DOM Document from a TraX Source.

      If the source is a DOMSource holding a Document Node, this one will be returned. Otherwise toInputSource(javax.xml.transform.Source) and a namespace aware DocumentBuilder (created by given DocumentBuilderFactory) will be used to read the source. This may involve an XSLT identity transform in toInputSource.

    • tryExtractDocFromDOMSource

      private static Document tryExtractDocFromDOMSource(Source s)
    • toNode

      public static Node toNode(Source s)
      Creates a DOM Node from a TraX Source.

      If the source is a DOMSource its Node will be returned, otherwise this delegates to toDocument(javax.xml.transform.Source).

    • toNode

      public static Node toNode(Source s, DocumentBuilderFactory factory)
      Creates a DOM Node from a TraX Source.

      If the source is a DOMSource its Node will be returned, otherwise this delegates to toDocument(javax.xml.transform.Source).

    • tryExtractNodeFromDOMSource

      private static Node tryExtractNodeFromDOMSource(Source s)
    • toNamespaceContext

      public static NamespaceContext toNamespaceContext(Map<String,String> prefix2URI)
      Creates a JAXP NamespaceContext from a Map prefix => Namespace URI.