我正在使用XProc运行一个XSLT,它会产生大量的结果文档(使用xsl:result)。我不知道如何在步骤中为@href添加一个变量。我有下面的XProc:
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
xmlns:c="http://www.w3.org/ns/xproc-step" version="1.0">
<p:input port="source">
<p:empty/>
</p:input>
<p:xslt name="pagelist">
<p:input port="stylesheet">
<p:document href="file:/C:/page-list.xsl"/>
</p:input>
<p:input port="source">
<p:document href="file:/C:/toc.xml"/>
</p:input>
<p:input port="parameters">
<p:empty/>
</p:input>
</p:xslt>
<p:store name="pagelist" indent="true">
<p:with-option name="method" select="'xml'" />
<p:with-option name="href" select="" />
</p:store>
如何在XProc中添加一个变量,该变量将与xsl:中的输出文件名匹配?
XSLT片段,如果需要的话:
<xsl:result-document href="{xhtml:a[@class='ref-uri']/@id}_pagelist.xml" method="xml" include-content-type="no" indent="no">发布于 2020-02-25 09:52:25
通过使用命令行的Calabash1.1.30,我能够完成以下工作:
<?xml version="1.0" encoding="UTF-8"?>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" xpath-version="2.0"
xmlns:c="http://www.w3.org/ns/xproc-step" version="1.0">
<p:input port="source">
<p:empty/>
</p:input>
<p:output port="result" primary="true" sequence="true">
<p:pipe port="result" step="secondary-storage"/>
</p:output>
<p:xslt name="xslt-pagelist" version="2.0">
<p:input port="stylesheet">
<p:document href="page-list.xsl"/>
</p:input>
<p:input port="source">
<p:document href="toc.xml"/>
</p:input>
<p:input port="parameters">
<p:empty/>
</p:input>
</p:xslt>
<p:store href="toc-list.html"/>
<p:for-each name="secondary-storage">
<p:iteration-source select=".">
<p:pipe port="secondary" step="xslt-pagelist"/>
</p:iteration-source>
<p:output port="result">
<p:pipe port="result" step="store"/>
</p:output>
<p:store name="store">
<p:with-option name="href" select="document-uri(.)"/>
</p:store>
</p:for-each>
</p:declare-step>因此,基本上,一个p:for-each在p:iteration-source上使用来自p:xslt步骤的secondary结果输出端口,然后在其中简单地使用document-uri(.)来获得结果URI。所有这些都需要xpath-version="2.0"。
不知何故,oXygen 22没有运行代码,但给了我一个拒绝访问的错误,它似乎被设置为向oXygen安装目录写入辅助文档,该目录不允许使用常规的Windows安全设置,而且无论如何也不是您想要结果文件的地方;为了解决这个问题,我调整了XProc,将XProc输入作为整个XProc脚本的输入源,然后在p:xslt步骤中,我可以使用函数p:base-uri为XSLT设置output-base-uri:
<?xml version="1.0" encoding="UTF-8"?>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" xpath-version="2.0"
xmlns:c="http://www.w3.org/ns/xproc-step" version="1.0">
<p:input port="source">
<p:document href="toc.xml"/>
</p:input>
<p:output port="result" primary="true" sequence="true">
<p:pipe port="result" step="secondary-storage"/>
</p:output>
<p:xslt name="xslt-pagelist" version="2.0">
<p:with-option name="output-base-uri" select="p:base-uri()"/>
<p:input port="stylesheet">
<p:document href="page-list.xsl"/>
</p:input>
<p:input port="parameters">
<p:empty/>
</p:input>
</p:xslt>
<p:store href="toc-list.html"/>
<p:for-each name="secondary-storage">
<p:iteration-source select=".">
<p:pipe port="secondary" step="xslt-pagelist"/>
</p:iteration-source>
<p:output port="result">
<p:pipe port="result" step="store"/>
</p:output>
<p:store name="store">
<p:with-option name="href" select="document-uri(.)"/>
</p:store>
</p:for-each>
</p:declare-step>这样,命令行中的Calabash和oXygen中的Calabash行为相同,将结果写入输入源所来自的同一个目录。
https://stackoverflow.com/questions/60385269
复制相似问题