Frage

I'm trying to handle exceptions while processing XSLT stylesheet. The exceptions are due to messy data. I have a following piece of code:

<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>

When this code runs on the server I get the following error:

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

Which doesn't make sense since the xdmp:catch child is clearly there. However, this code doesn't cause any errors, but clearly it doesn't actually do anything.

        <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>
War es hilfreich?

Lösung

It is a bug in the parser. The workaround is to have exactly one child element before the xdmp:try, e.g.

<span class="ReceiptCell Date">
            <xsl:variable name="node" />
            <xsl:value-of select="_1:Date"/>
    <xdmp:try>
            <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>
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top