W3C home > Mailing lists > Public > xproc-dev@w3.org > April 2014

try/catch with messages

From: Graham Seaman <graham@theseamans.net>
Date: Tue, 15 Apr 2014 11:48:13 +0100
Message-ID: <534D0E6D.7090403@theseamans.net>
To: xproc-dev@w3.org

I'm in the 'initial 5 minutes' stage of learning xproc, and floundering.
I have a series of xslt templates intended to validate files in
different ways. If validation fails at any point, the xslt terminates
with an error message (ie. using xsl;message with terminate='yes'). I'm
hoping to persuade xproc to catch and display the message produced in
the xslt, and would ideally like the xproc pipeline also to terminate at
that point. However, I haven't even been able to get try/catch working
yet. Below is a (clearly non-working) attempt with some toy xml/xslt. I
think in general the biggest problem I'm having is with the scope of the
various ports (for example, I don't understand why the global pipeline
source port is not visible to the p:xslt stage without adding a 'dummy'

Thanks for any advice


<?xml version="1.0" encoding="UTF-8"?>

<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="1.0">
    <p:input port="source" primary="true" sequence="false">
        <p:document href="test.xml"/>
    <p:output port="result" primary="true" sequence="false"/>

    <p:try name="try-test">
            <p:xslt name="tester">
                <p:input port="stylesheet">
                    <p:document href="test.xslt"/>
                <p:with-param name="dummy" select="''"/>
                <p:input port="source">
                    <p:pipe step="tester" port="error"/>

        <p:input port="source">
            <p:pipe step="try-test" port="result"/>



<?xml version="1.0" encoding="UTF-8"?>

    <phrase>Hallo world</phrase>
    <phrase>and it's goodbye from me</phrase>


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"

    <xsl:template match="@* | node()">
            <xsl:apply-templates select="@*, node()"/>

    <xsl:template match="phrase">
        <xsl:if test="text() = 'and it''s goodbye from me'">
            <xsl:message terminate="yes">test.xml matched
        <xsl:copy-of select="."/>
Received on Tuesday, 15 April 2014 20:45:38 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:17:19 UTC