问题
I've set up an XProc pipeline wherein I have a <p:xslt>
step. Amoung the parameters of this stylesheet, I have an parameter which is a document() node:
This is the km_to_dita.xsl stylesheet:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:dctm="http://www.documentum.com" xmlns:ale="http://www.amplexor.com/alcatel"
exclude-result-prefixes="xs dctm ale" version="2.0">
<xsl:param name="conf-base" select="'file:/D:/Temp/ALE_config/'" />
<xsl:param name="output-base" select="''"/>
<xsl:param name="lang" select="/element()[1]/@language"/>
<xsl:param name="graphics-reference-names" as="document-node()*" />
<!-- my templates stuff... -->
</xsl:stylesheet>
Thus I am calling this XSLT in my pipeline with the following step (for demonstration purpose it is set with a <p:inline>
but it is aimed to be bound to the result port of a step):
<p:xslt name="km-dm-to-dita">
<p:input port="source">
<p:pipe port="list-dm" step="list-csv"/>
</p:input>
<p:input port="stylesheet">
<p:document href="km_to_dita.xsl"/>
</p:input>
<p:with-param name="output-base" select="$dita.data-dir"/>
<p:with-param name="conf-base" select="$config-dir"/>
<!--<p:with-param name="graphics-reference-names">
<p:pipe port="result" step="get-figure-references"/>
</p:with-param>-->
<p:with-param name="graphics-reference-names">
<p:inline>
<graphic-ids>
<reference type="symbol" document="dm09011b0281121ef3.xml#G4" filename="g09011b0281d9c449.gif"/>
<reference type="symbol" document="dm09011b0281121ef3.xml#G3" filename="g09011b0281d9c449.gif"/>
<reference type="figure" document="dm09011b0281121ef3.xml#F33" filename="g09011b0281d9c44d.gif"/>
<reference type="symbol" document="dm09011b0281121ef3.xml#G5" filename="g09011b0281d9c451.gif"/>
<reference type="figure" document="dm09011b0281121ef5.xml#F116" filename="g09011b0281d9c458.gif"/>
</graphic-ids>
</p:inline>
</p:with-param>
<p:with-option name="output-base-uri" select="$dita.data-dir"/>
</p:xslt>
But it fails when running it with XML Calabash (in oXygenXML), the error being raised is (sorry folks it's all the information I have) however have determined that it's the <p:with-param name="graphics-reference-names">
that causes this error):
null
Any idea?
回答1:
I finally found what's going wrong with it... First of all, the <p:with-param>
is missing the required @select
attribute, as mentioned in the XProc, but strangely oXygen didn't raise any validating error for my pipeline.
Thus the pipeline may be fixed that way:
<p:with-param name="graphics-reference-names" select="/">
<p:inline>
<graphic-ids>
<reference type="symbol" document="dm09011b0281121ef3.xml#G4" filename="g09011b0281d9c449.gif"/>
<reference type="symbol" document="dm09011b0281121ef3.xml#G3" filename="g09011b0281d9c449.gif"/>
<reference type="figure" document="dm09011b0281121ef3.xml#F33" filename="g09011b0281d9c44d.gif"/>
<reference type="symbol" document="dm09011b0281121ef3.xml#G5" filename="g09011b0281d9c451.gif"/>
<reference type="figure" document="dm09011b0281121ef5.xml#F116" filename="g09011b0281d9c458.gif"/>
</graphic-ids>
</p:inline>
</p:with-param>
With the solution above, XSLT fails because the parameter is casted to a string:
Required item type of value of variable $graphics-reference-names is document-node(); supplied value has item type xs:string
This is the other issue that makes the problem unsolvable: XProc allows only parameters to be set as atomic values, as explained in XSLT with XProc - parameter binding in the required type.
来源:https://stackoverflow.com/questions/40512887/passing-document-parameter-to-an-xslt-in-xproc-pipeline