Name
p:hash — The standard p:hash step.
Synopsis
The p:hash step generates a hash, or digital “fingerprint”,
for some value and injects it into the source document.
| Input port | Primary | Sequence | Content types |
|---|---|---|---|
| source | ✔ | xml html |
| Output port | Primary | Sequence | Content types |
|---|---|---|---|
| result | ✔ | text xml html |
| Option name | Type | Default value | Required |
|---|---|---|---|
| algorithm | xs:QName | ✔ | |
| value | xs:string | ✔ | |
| match | XSLTSelectionPattern | '/*/node()' | |
| parameters | map(xs:QName,item()*)? | () | |
| version | xs:string? | () |
Declaration
1 |<p:declare-step xmlns:p="http://www.w3.org/ns/xproc">
| <p:input port="source" primary="true" content-types="xml html"/>
| <p:output port="result" content-types="text xml html"/>
| <p:option name="parameters" as="map(xs:QName,item()*)?"/>
5 | <p:option name="value" required="true" as="xs:string"/>
| <p:option name="algorithm" required="true" as="xs:QName"/>
| <p:option xmlns:e="http://www.w3.org/1999/XSL/Spec/ElementSyntax"
| name="match"
| as="xs:string"
10 | select="'/*/node()'"
| e:type="XSLTSelectionPattern"/>
| <p:option name="version" as="xs:string?"/>
|</p:declare-step>Errors
| Code | Description |
|---|---|
err:XC0036 | It is a
dynamic error (err:XC0036) if the requested hash algorithm is not
one that the processor understands or if the value or parameters are
not appropriate for that algorithm. |
Implementation defined features
- It is implementation-defined what other algorithms are supported.
Description
The p:hash step is a
standard XProc 3.0 step.
It is also described on XProcRef.org.
Supported algorithms
The crc, md, and sha algorithms are supported
as well as cx:hmac and cx:blake3.
crc
Generates a CRC-32 checksum.
The default, and only accepted, version for the crc algorithm
is “32”.
md
Generates an MD2 or MD5 digest.
The default version for the md algorithm is “5”.
XML Calabash defers implementation to the JVM MessageDigest class.
The MD2 digest algorithm is defined in RFC 1319. The MD5 digest algorithm is defined in RFC 1321.
sha
Generates a SHA-1, SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/224, or SHA-512/256
digest.
The default version for the sha algorithm is “1”.
XML Calabash defers implementation to the JVM MessageDigest class.
The digest algorithms are defined in FIPS 180-4.
cx:hmac
Generates an HMAC signature with the HMAC SHA1 algorithm. The version
option is ignored. The algorithm requires an access key which must be provided in
the access-key property of the parameters option.
cx:blake3
Generates a Blake3 digest. The version
option is ignored. XML Calabash defers implementation to the
Apache Commons Codec
project.
If no
parametersare provided, a Blake3 hash is generated.If a
keyproperty is provided in theparametersoption, a Blake3 keyed hash is generated.If a
keyis provided, no other properties may be provided.If a
shared-secret,sender-id, andrecipient-idare all provided in theparametersoption, a Blake3 key derivation digest is generated.If any of
shared-secret,sender-id, orrecipient-idare provided, they must all be provided. No other properties may be provided.
No other algorithms are supported at this time.