Name

p:json-merge — The standard p:json-merge step.

Synopsis

The p:json-merge step merges the sequence of appearing on port source into a single JSON object appearing on port result. If the sequence on port source is empty, the empty sequence is returned on port result.

Input portPrimarySequenceContent types
source✔ ✔ any 
Output portPrimarySequenceContent types
result✔  application/json 
Option nameTypeValuesDefault value
duplicatesxs:string('reject', 'use-first', 'use-last', 'use-any', 'combine') 'use-first'
keyXPathExpression 'concat("_",$p:index)'
Declaration
 1 |<p:declare-step xmlns:p="http://www.w3.org/ns/xproc">
   |   <p:input port="source" sequence="true" content-types="any"/>
   |   <p:output port="result" content-types="application/json"/>
   |   <p:option name="duplicates"
 5 |             values="('reject', 'use-first', 'use-last', 'use-any', 'combine')"
   |             select="'use-first'"/>
   |   <p:option xmlns:e="http://www.w3.org/1999/XSL/Spec/ElementSyntax"
   |             name="key"
   |             as="xs:string"
10 |             select="'concat(&#34;_&#34;,$p:index)'"
   |             e:type="XPathExpression"/>
   |</p:declare-step>
Errors
CodeDescription
err:XC0106It is a dynamic error (err:XC0106) if duplicate keys are encountered and option duplicates has value “reject”.
err:XC0107 It is a dynamic error (err:XC0107) if a document of a not supported document type appears on port source of p:json-merge.
err:XC0110It is a dynamic error (err:XC0110) if the evaluation of the XPath expression in option key for a given item returns either a sequence, an array, a map, or a function.
Implementation defined features
  • It is implementation-defined if p:json-merge is able to process document types not mentioned yet, i.e. types of binary documents.

Description

The p:json-merge step is defined in the XProc 3.0: Standard Step Library. It is also described on XProcRef.org.