2
我想在处理XSLT样式表时处理异常。例外是由于数据混乱。我有下面这段代码:Marklogic XSLT异常处理
<span class="ReceiptCell Date">
<xdmp:try>
<xsl:variable name="node" />
<xsl:value-of select="_1:Date"/>
<xsl:value-of select="if (empty($node)) then '(A)' else xdmp:strftime('%d %b %Y',//_1:Date)"/>
<xdmp:catch name="e">
ERROR Rendering Date
<xsl:copy-of select="$e"/>
</xdmp:catch>
</xdmp:try>
</span>
此代码时我得到以下错误在服务器上运行:
2014-03-26 10:40:09.900 Notice: TaxesTime-Search: XSLT-ELTREQ: (err:XTSE0010)
Missing required element child: xdmp:catch required at
fn:doc("/lib/transform-abstract-metadata.xsl")/*:stylesheet/*:template[3]/*:span/*:try
这是没有意义的,因为xdmp:抓孩子显然是有。但是,这段代码不会导致任何错误,但显然它并没有做任何事情。
<span class="ReceiptCell Date">
<xdmp:try>
<xdmp:catch name="e">
<xsl:variable name="node" />
<xsl:value-of select="_1:Date"/>
<xsl:value-of select="if (empty($node)) then '(A)' else xdmp:strftime('%d %b %Y',//_1:Date)"/>
ERROR Rendering Date
<xsl:copy-of select="$e"/>
</xdmp:catch>
</xdmp:try>
</span>
谢谢你是我的英雄! – Vlad
这可能在xslt 1.0中吗?或者它只是xslt 2.0 –