Name
cx:unique-id — Generates unique identifiers.
Synopsis
Input port | Primary | Sequence | Content types |
---|---|---|---|
source | ✔ | xml html |
Output port | Primary | Sequence | Content types |
---|---|---|---|
result | ✔ | text xml html |
Option name | Type | Values | Default value |
---|---|---|---|
flavor | xs:string | ('uuid','ulid','typeid') | 'uuid' |
match | xs:string | /* | |
parameters | map(xs:QName,item()*)? | () | |
sequential | xs:boolean | false() |
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="match" as="xs:string" select="/*"/>
5 | <!-- XSLTSelectionPattern -->
| <p:option name="flavor"
| as="xs:string"
| select="'uuid'"
| values="('uuid','ulid','typeid')"/>
10 | <p:option name="sequential" as="xs:boolean" select="false()"/>
| <p:option name="parameters" as="map(xs:QName,item()*)?"/>
|</p:declare-step>
Description
The cx:unique-id
step generates a unique identifier and injects
it into the source document. UUID, ULID, and TypeID identifiers are supported.
Options
There are four options. The parameters
vary by
flavor
.
match
The value of the
match
option must be an XSLTSelectionPattern.The matched nodes are specified with the selection pattern in the
match
option. For each matching node, the generated identifier is used in the output. Nodes that do not match are copied without change.If the expression given in the match option matches an attribute, the identifier is used as the new value of the attribute in the output. If the attribute is named
xml:base
, the base URI of the element must also be amended accordingly.If the document node is matched, the entire document is replaced by a text node with the identifier. What appears on port result is a text document with the text node wrapped in a document node.
If the expression matches any other kind of node, the entire node (and not just its contents) is replaced by the identifier.
flavor
The
flavor
option determines the flavor of identifier.uuid
If the UUID flavor is selected, the
parameters
map may contain aversion
parameter determines the version of the UUID that must be computed. It is a dynamic error (err:XC0060
) if the processor does not support the specified version of the UUID algorithm. If the version is not specified, version 4 UUIDs are computed.Seven UUID versions are supported.
- Version 1
Version 1 UUIDs are time based, no other parameters are used.
- Version 2
Version 2 UUIDs have two parameters:
domain
andvalue
. The (integer)value
is encoded using thedomain
. Thedomain
value is either a byte or one of the special valuesuser
,group
ororg
(ororganization
).The
sequential
option has no effect.- Version 3
Version 3 UUIDs have two parameters, a
namespace
UUID and avalue
. Thevalue
is encoded using thenamespace
and hashed with MD5. Thenamespace
value is either a UUID or one of the special valuesurl
(oruri
),dns
,oid
(oriso-oid
), orx500
.The
sequential
option has no effect.- Version 4
Version 4 UUIDs are random, no other parameters are used.
- Version 5
Version 5 UUIDs are just like version 3 UUIDs, except that they’re hashed using SHA1 instead of MD5.
- Version 6
Version 6 UUIDs are time based, no other parameters are used.
- Version 7
Version 7 UUIDs are time based, no other parameters are used.
ulid
ULIDs have no parameters.
typeid
TypeID identifiers have a
type
parameter which must be a string.
sequential
If
sequential
is true, a different unique identifier will be generated for each match. Otherwise, the same identifier is used in each match.
Document properties
If the resulting document contains exactly one text node, the
content-type
property is changed to text/plain
and the
serialization property is removed, while all other document properties are
preserved. For other document types, all document properties are preserved.
References
- UUID
- ULID
- TypeID