cx:hash-document — Compute the hash of a document.


<p:declare-step type="cx:hash-document" xmlns:cx="">
     <p:input port="source"/>
     <p:output port="result"/>
     <p:input port="parameters" kind="parameter"/>
     <p:option name="algorithm" required="true"/>                  <!-- QName -->
     <p:option name="hash-version"/>                               <!-- string -->
     <p:option name="byte-order-mark"/>                            <!-- boolean -->
     <p:option name="cdata-section-elements" select="''"/>         <!-- ListOfQNames -->
     <p:option name="doctype-public"/>                             <!-- string -->
     <p:option name="doctype-system"/>                             <!-- anyURI -->
     <p:option name="encoding"/>                                   <!-- string -->
     <p:option name="escape-uri-attributes" select="'false'"/>     <!-- boolean -->
     <p:option name="include-content-type" select="'true'"/>       <!-- boolean -->
     <p:option name="indent" select="'false'"/>                    <!-- boolean -->
     <p:option name="media-type"/>                                 <!-- string -->
     <p:option name="method" select="'xml'"/>                      <!-- QName -->
     <p:option name="normalization-form" select="'none'"/>         <!-- NormalizationForm -->
     <p:option name="omit-xml-declaration" select="'true'"/>       <!-- boolean -->
     <p:option name="standalone" select="'omit'"/>                 <!-- "true" | "false" | "omit" -->
     <p:option name="undeclare-prefixes"/>                         <!-- boolean -->
     <p:option name="version" select="'1.0'"/>                     <!-- string -->


The p:hash-document step is, operationally, a bit like a combination of the p:store and p:hash steps. It begins by serializing the document that appears on the source port using the serialization parameters specified. Like p:store, it accepts an extension option to decode binary documents.

Next, a hash is computed for the serialized document. The hash options accepted are the same as those for p:hash.


Both the p:store and p:hash steps have a version option. In p:hash-document, the version option is used exclusively for serialization. To specify the version of the hashing algorithm, you must use the hash-version option.


If an XML (or JSON) document is passed to p:hash-document, the step does not produce a canonical serialization before computing the hash. This step is therefore not reliable for hashes of XML documents. (Canonicalization will be added in the future.)

The computed hash is returned in a c:result element on the output port.