tr:dynamic-transformation-pipeline dtp

cascade/xpl/dynamic-transformation-pipeline.xpl

Import URI: http://transpect.io/cascade/xpl/dynamic-transformation-pipeline.xpl

This encapsulates the dynamic loading of an XSLT stylesheet and an XPL pipeline and execution of the pipeline. Dynamic loading means that the most specific (specificity tr: work, series, publisher, common) XSL and XPL files will be loaded. The pipeline usually consists of transformations with the same dynamically loaded stylesheet in different modes, according to the dynamically loaded pipeline (that consists of tr:xslt-mode steps). The pipeline may have multiple documents on the source and result ports. The transformation will be applied to each document in turn. Additional input files that will be passed to each transformation may be sent to the additional-input port. They must be wrapped in cx:document with the appropriate port name of the dynamically executed pipeline. Even if you don’t have additional inputs, make sure to always include the additional-inputs port when invoking tr:dynamic-transformation-pipeline. Connect it to p:empty by default. Please note the difference between a sequence of source documents (will be transformed one by one) and a sequence of additional files (will be available to the dynamically loaded pipeline and will typically be used as additional input documents for some of the tr:xslt-mode steps therein, thus making it available via the default collection in each transformation). There is a limitation that additional inputs are limited to single documents per port. If you have a sequence, you’ll have to wrap it into a custom element before wrapping it in the cx:document. There is also an options port. You may submit options in a cx:options document with cx:option entries (with name and value attributes). These options will be merged with the debug and debug-dir-uri options and passed on to the dynamically loaded pipeline. Before preparing a cx:options document, check whether the options can be read in the dynamically invoked pipeline from the primary parameter port.

Input Ports

NameDocumentationConnections

source

additional-inputs

Additional cx:document(s) whose port attribute(s) designate(s) the input port(s) of the dynamically evaluated XProc step

options

Options that will be passed to the pipeline, in a cx:options document

paths

Output Ports

NameDocumentationConnections

result

A sequence of documents

Options

NameDocumentationDefault

load

The base name of the .xsl and .xpl files to load, e.g., foo2bar/foo2bar, where foo2bar is the name of directories in the customization folders for publisher, series, etc.

fallback-xsl

Fallback URI to 'default' stylesheet file. Will be loaded when no customization is available in the customization folders for publisher, series, etc. You have to use the URI located in [code repo]/xmlcatalog/catalog.xml together wie the path to the stylesheet. Example (evolve-hub): http://transpect.io/evolve-hub/xsl/evolve-hub.xsl

''

fallback-xpl

Fallback URI to 'default' pipeline file. Leave it empty when no .xpl exists.

''

debug

'no'

debug-dir-uri

'debug'

Subpipeline

StepInputsOutputsOptions

p:parameters consolidate-params

parameters

paths on dtp

result

p:wrap d101e50

source

result on consolidate-params

result

wrapper = 'cx:document'

match = '/'

p:add-attribute parameters

source

result on d101e50

result

attribute-name = 'port'

attribute-value = 'parameters'

match = '/*'

p:sink d101e58

source

result on parameters

tr:load-cascaded load-stylesheet

paths

result on consolidate-params

result

filename = concat($load, '.xsl')

fallback = $fallback-xsl

debug = $debug

debug-dir-uri = $debug-dir-uri

p:sink d101e74

source

result on load-stylesheet

p:wrap d101e75

source

result on load-stylesheet

result

wrapper = 'cx:document'

match = '/'

p:add-attribute stylesheet

source

result on d101e75

result

attribute-name = 'port'

attribute-value = 'stylesheet'

match = '/*'

p:sink d101e85

source

result on stylesheet

tr:load-cascaded pipeline

paths

result

filename = concat($load, '.xpl')

fallback = $fallback-xpl

debug = $debug

debug-dir-uri = $debug-dir-uri

p:try validate-pipeline

p:group d101e99

p:validate-with-relax-ng d101e101

schema

p:documenthttp://www.w3.org/TR/xproc/schema/1.0/xproc.rng

source

result on pipeline

result

assert-valid = 'true'

p:sink d101e114

source

result on d101e101

p:catch failed

error

cx:message d101e119

source

result on pipeline

result

message = concat('Invalid dynamic transformation pipeline (or no pipeline present): ', base-uri(/*), ' Please look for error messages in ', resolve-uri('dynamic-transformation-pipeline.error.xml', $debug-dir-uri))

p:store d101e127

source

error on failed

result

href = resolve-uri('dynamic-transformation-pipeline.error.xml', $debug-dir-uri)

p:store d101e137

source

result on pipeline

result

href = resolve-uri(concat('dynamic-transformation-pipeline.error_', replace(base-uri(/*), '^.+/', '')), $debug-dir-uri)

p:xslt options

parameters

p:empty

source

options on dtp

stylesheet

 <xsl:stylesheet version="2.0">
   <xsl:param name="debug" as="xs:string"/>
   <xsl:param name="debug-dir-uri" as="xs:string"/>
   <xsl:template name="main">
     <cx:options>
       <cx:option name="debug" value="{$debug}"/>
       <cx:option name="debug-dir-uri" value="{$debug-dir-uri}"/>
       <xsl:sequence select="collection()/cx:options/cx:option"/>
     </cx:options>
   </xsl:template>
 </xsl:stylesheet>

result

template-name = 'main'

p:sink d101e190

source

result on options

p:for-each iteration

source on dtp

p:wrap d101e198

source

current on iteration

result

wrapper = 'cx:document'

match = '/'

p:add-attribute source

source

result on d101e198

result

attribute-name = 'port'

attribute-value = 'source'

match = '/*'

p:sink d101e208

source

result on source

cx:eval eval

pipeline

result on pipeline

source

result on stylesheet

result on source

result on parameters

additional-inputs on dtp

options

result on options

detailed = 'true'

p:unwrap d101e235

source

result

match = '/cx:document[@port eq 'result']'

Used by