try/catch with messages

Hi,

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'
parameter).

Thanks for any advice

Graham



<?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:input>
    <p:output port="result" primary="true" sequence="false"/>

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

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

</p:declare-step>

-------------------

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

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

-----------------------

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

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

    <xsl:template match="phrase">
        <xsl:if test="text() = 'and it''s goodbye from me'">
            <xsl:message terminate="yes">test.xml matched
phrase</xsl:message>
        </xsl:if>
        <xsl:copy-of select="."/>
    </xsl:template>
</xsl:stylesheet>

Received on Tuesday, 15 April 2014 20:45:38 UTC