我有一个要使用 XSLT 1.0 呈现的 XML 文件。
我的案例如下:
longName
如果值为“Oui_Combi”
$Publication
=prodDate
价值 ( 21.11.2018 )别的
$Publication
=productionDates
价值 ( 17.11.2018, 21.11.2018 )
我不确定我的语法在 for-each 和/或 xsl-if 上是否正确
XML 文件:
<?xml version="1.0" encoding="UTF-8"?>
<Manuscript dateAndTime="2018-11-16T10:20:59.177+01:00" renderEPS="" forMediation="false">
<Order>
<OrderHeader productionDates="17.11.2018, 21.11.2018">
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
<Criterion name="TypePublicity" ordering="1">
TypePubOccasionnel <ValueParameter longName="Occasionnel"/>
</Criterion>
<Criterion name="JuraCombi" ordering="2">
Oui_Combi <ValueParameter longName="Oui_Combi"/>
^^^^^^^^^^^^^^^^^^^^
</Criterion>
</OrderHeader>
<FirstIssueData prodDate="21.11.2018"></FirstIssueData>
</Order> ^^^^^^^^^^^^^^^^^^^^^
</Manuscript>
我创建变量的 XSL 部分:
<xsl:for-each select="Order/OrderHeader/Criterion">
<xsl:if test="@name = 'JuraCombi'">
<xsl:if test="ValueParameter/@longName = 'Oui_Combi'">
<xsl:variable name="JuraCombi">
OUI
</xsl:variable>
<xsl:variable name="Publication">
<xsl:value-of select="/Order/FirstIssueData/@prodDate" />
</xsl:variable>
</xsl:if>
<xsl:if test="ValueParameter/@longName != 'Oui_Combi'">
<xsl:variable name="JuraCombi">
NON
</xsl:variable>
<xsl:variable name="Publication">
<xsl:value-of select="/Order/OrderHeader/@productionDates" />
</xsl:variable>
</xsl:if>
</xsl:if>
</xsl:for-each>
...
我要打印变量的 XSL 部分$Publication
:
<xsl:template match="OrderHeader">
<fo:table
table-layout="fixed"
width="18cm"
font-size="10pt"
padding="1.0pt">
<fo:table-column column-width="30mm"/>
<fo:table-column column-width="60mm"/>
<fo:table-column column-width="30mm"/>
<fo:table-column column-width="60mm"/>
<fo:table-body>
...
<fo:table-row>
<fo:table-cell>
<fo:block padding="0.5cm">
Parutions
</fo:block>
</fo:table-cell>
<fo:table-cell number-columns-spanned="3">
<fo:block padding="0.5cm">
<xsl:copy-of select="$Publication" />
</fo:block> ^^^^^^^^^^^^
</fo:table-cell>
</fo:table-row>
...
</fo:table-body>
</fo:table>
</xsl:template>
也许我们可以在没有 for-each 的情况下实现它?
没有任何在线 XSLT 工具/检查器可以让我得到详细的错误,但渲染停止!
感谢帮助