Class Canonicalize


  • public class Canonicalize
    extends java.lang.Object
    A service class to canonicalize XML DOM nodes into their standard representations as defined by the Canonical XML and the Exclusive XML Canonicalization specifications.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int CANONICALWITH
      Canonicalization type: generic canonicalization.
      static int CANONICALWITHOUT
      Canonicalization type: generic canonicalization with all comments removed.
      static int EXCLUSIVEWITH
      Canonicalization type: exclusive canonicalization.
      static int EXCLUSIVEWITHOUT
      Canonicalization type: exclusive canonicalization with all comments removed.
      static int SAVEWITH
      Canonicalization type: generic canonicalization without the use of context namespaces.
      static int SAVEWITHOUT
      Canonicalization type: generic canonicalization without the use of context namespaces and with all comments removed.
    • Constructor Summary

      Constructors 
      Constructor Description
      Canonicalize()
      Instantiates a canonicalization service.
      Canonicalize​(boolean bLegacy_V32_Canonicalization)
      Instantiates a canonicalization service.
      Canonicalize​(Node node, boolean bInPlace, boolean bLegacy_V32_Canonicalization)
      Instantiates a canonicalization service.
      Canonicalize​(java.util.List<? extends Node> store, boolean bWithDescendants, boolean bLegacy_V32_Canonicalization)
      Instantiates a canonicalization service.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] canonicalize​(int eCanonicalType, java.util.List<java.lang.String> inclusiveNSPrefixList)
      Performs text normalization of a set of nodes.
      void canonicalize​(java.io.OutputStream out, int eCanonicalType, java.util.List<java.lang.String> inclusiveNSPrefixList)
      Performs text normalization of a set of nodes.
      Document canonicalize​(java.util.List<? super Node> retList, int eCanonicalType, java.util.List<java.lang.String> inclusiveNSPrefixList)
      Performs text normalization of a set of nodes.
      DOMSaveOptions getSaveOptions()
      Gets the save options for canonicalized data.
      void setData​(java.lang.Object node)
      Set the data for this canonicalize to work on.
      • Methods inherited from class java.lang.Object

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

      • CANONICALWITH

        public static final int CANONICALWITH
        Canonicalization type: generic canonicalization.
        See Also:
        Constant Field Values
      • CANONICALWITHOUT

        public static final int CANONICALWITHOUT
        Canonicalization type: generic canonicalization with all comments removed.
        See Also:
        Constant Field Values
      • EXCLUSIVEWITH

        public static final int EXCLUSIVEWITH
        Canonicalization type: exclusive canonicalization.
        See Also:
        Constant Field Values
      • EXCLUSIVEWITHOUT

        public static final int EXCLUSIVEWITHOUT
        Canonicalization type: exclusive canonicalization with all comments removed.
        See Also:
        Constant Field Values
      • SAVEWITH

        public static final int SAVEWITH
        Canonicalization type: generic canonicalization without the use of context namespaces.
        See Also:
        Constant Field Values
      • SAVEWITHOUT

        public static final int SAVEWITHOUT
        Canonicalization type: generic canonicalization without the use of context namespaces and with all comments removed.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Canonicalize

        public Canonicalize()
        Instantiates a canonicalization service.
      • Canonicalize

        public Canonicalize​(boolean bLegacy_V32_Canonicalization)
        Instantiates a canonicalization service.
        Parameters:
        bLegacy_V32_Canonicalization - legacy protected canonicalization flag
      • Canonicalize

        public Canonicalize​(Node node,
                            boolean bInPlace,
                            boolean bLegacy_V32_Canonicalization)
        Instantiates a canonicalization service.
        Parameters:
        node - a node to be canonicalized along with its children.
        bInPlace - whether to perform canonicalization on the node specified
        bLegacy_V32_Canonicalization - legacy protected canonicalization flag * or on a copy.
      • Canonicalize

        public Canonicalize​(java.util.List<? extends Node> store,
                            boolean bWithDescendants,
                            boolean bLegacy_V32_Canonicalization)
        Instantiates a canonicalization service.
        Parameters:
        store - a list of nodes to be canonicalized.
        bWithDescendants - when true, canonicalize the descendants and
        bLegacy_V32_Canonicalization - legacy protected canonicalization flag * attributes of each node in the list; otherwise, do not.
    • Method Detail

      • canonicalize

        public Document canonicalize​(java.util.List<? super Node> retList,
                                     int eCanonicalType,
                                     java.util.List<java.lang.String> inclusiveNSPrefixList)
        Performs text normalization of a set of nodes. This implies that:
        • CDATA sections are replaced with their character content.
        • XML declaration and document type declaration (DTD) are removed.
        • empty elements are converted to start-end tag pairs.
        • whitespace outside of the document element and within start and end tags is normalized.
        • all whitespace in character content is retained (excluding characters removed during line feed normalization).
        • special characters in attribute values and character content are replaced by character references.
        • encoding of special characters as character references in attribute values (&, <, ", CR, NL, TAB).
        • encoding of special characters as character references in text (&, <, >, CR).
        • superfluous namespace declarations are removed from each element.
        • default attributes are added to each element.
        • lexicographic order is imposed on the namespace declarations and attributes of each element.
        Parameters:
        retList - a list given by the caller to be populated with canonicalized nodes, by this method.
        eCanonicalType - the canonicalization type to use.
        inclusiveNSPrefixList - a list of namespace prefixes that are handled as though performing non-exclusive canonicalization, when exclusive canonicalization type is specified.
        Returns:
        the document.
      • canonicalize

        public byte[] canonicalize​(int eCanonicalType,
                                   java.util.List<java.lang.String> inclusiveNSPrefixList)
        Performs text normalization of a set of nodes. This implies that:
        • CDATA sections are replaced with their character content.
        • XML declaration and document type declaration (DTD) are removed.
        • empty elements are converted to start-end tag pairs.
        • whitespace outside of the document element and within start and end tags is normalized.
        • all whitespace in character content is retained (excluding characters removed during line feed normalization).
        • special characters in attribute values and character content are replaced by character references.
        • encoding of special characters as character references in attribute values (&, <, ", CR, NL, TAB).
        • encoding of special characters as character references in text (&, <, >, CR).
        • superfluous namespace declarations are removed from each element.
        • default attributes are added to each element.
        • lexicographic order is imposed on the namespace declarations and attributes of each element.
        Parameters:
        eCanonicalType - the canonicalization type to use: one of CANONICALWITH, CANONICALWITHOUT, EXCLUSIVEWITH or EXCLUSIVEWITHOUT.
        inclusiveNSPrefixList - a list of namespace prefixes that are handled as though performing non-exclusive canonicalization, when exclusive canonicalization type is specified.
        Returns:
        byte array containing the canonicalized, UTF-8 encoded, data.
      • canonicalize

        public void canonicalize​(java.io.OutputStream out,
                                 int eCanonicalType,
                                 java.util.List<java.lang.String> inclusiveNSPrefixList)
        Performs text normalization of a set of nodes. This implies that:
        • CDATA sections are replaced with their character content.
        • XML declaration and document type declaration (DTD) are removed.
        • empty elements are converted to start-end tag pairs.
        • whitespace outside of the document element and within start and end tags is normalized.
        • all whitespace in character content is retained (excluding characters removed during line feed normalization).
        • special characters in attribute values and character content are replaced by character references.
        • encoding of special characters as character references in attribute values (&, <, ", CR, NL, TAB).
        • encoding of special characters as character references in text (&, <, >, CR).
        • superfluous namespace declarations are removed from each element.
        • default attributes are added to each element.
        • lexicographic order is imposed on the namespace declarations and attributes of each element.
        Parameters:
        out - the stream to be populated with the the canonicalized data. The stream will be UTF-8 encoded.
        eCanonicalType - the canonicalization type to use: one of CANONICALWITH, CANONICALWITHOUT, EXCLUSIVEWITH or EXCLUSIVEWITHOUT.
        inclusiveNSPrefixList - a list of namespace prefixes that are handled as though performing non-exclusive canonicalization, when exclusive canonicalization type is specified.
      • getSaveOptions

        public DOMSaveOptions getSaveOptions()
        Gets the save options for canonicalized data.
        Returns:
        the save options for canonicalized data.
      • setData

        public void setData​(java.lang.Object node)
        Set the data for this canonicalize to work on.
        Parameters:
        node - a node to be canonicalized along with its children.