W3C home > Mailing lists > Public > xproc-dev@w3.org > May 2012

Re: Multiple XSLT transformations with intermediate files

From: mozer <xmlizer@gmail.com>
Date: Sun, 20 May 2012 13:20:34 +0200
Message-ID: <CAKdwC_N0ZiS5SEwoSLtrSCtiWOiqVMDAAK3MBdRiHZ2Qz3Zm2w@mail.gmail.com>
To: Patrick Gundlach <patrick@gundla.ch>
Cc: xproc-dev@w3.org
Patrick,

In XProc, it's not a good strategy to rely on the order of execution
Here follow an excerpt of the XProc 1.0 Specification

[[
The pattern of connections between steps will not always completely
determine their order of evaluation. The evaluation order of steps not
connected to one another is
*implementation-dependent<http://www.w3.org/TR/xproc/#dt-implementation-dependent>
*.
]]

My advice here is to make the pipeline as if you don't need to serialize
(so you just connect the result of the previous step to the source of the
next step) and then add the serialization at the end of XProc pipeline
using p:store with inputs connected at the right place

My two cents

Xmlizer



2012/5/17 Patrick Gundlach <patrick@gundla.ch>

> Hello all,
>
> I am a newbee and not sure if this is the right place to ask.
>
> ( This is also a duplicate of
> http://stackoverflow.com/questions/10636613/xproc-multiple-xslt-tranformation-with-intermediate-files- but I think I get better answers here )
>
> Why do I get the errors mentioned below? What is the right way to connect
> the pipelines?
>
>
> I need to do several XSLT transformations with intermediate XML files.
>
>    first.xml ------------>   intermediate.xml ------------> final.xml
>               first.xsl                         final.xsl
>
> I'd like to create an XProc pipleline. I have tried to write the following
> code, but this gives me an error:
>
>
>    SCHWERWIEGEND: runxslt.xpl:26:44:err:XD0011:Could not read:
> intermediate.xml
>    17.05.2012 15:15:35 com.xmlcalabash.drivers.Main error
>    SCHWERWIEGEND: It is a dynamic error if the resource referenced by a
> p:document element does not exist, cannot be accessed, or is not a
> well-formed XML document.
>    17.05.2012 15:15:35 com.xmlcalabash.drivers.Main error
>    SCHWERWIEGEND: Underlying exception:
> net.sf.saxon.s9api.SaxonApiException: I/O error reported by XML parser
> processing file:/<somepath>/intermediate.xml:
>    /<somepath>/intermediate.xml (No such file or directory)
>
> (where SCHWERWIEGEND means something like FATAL) So obviously the file
> `intermediate.xml` has not been written.
>
> This is the `xpl`-document that I have used:
>
>    <?xml version="1.0" encoding="UTF-8"?>
>    <p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
>      xmlns:c="http://www.w3.org/ns/xproc-step" version="1.0">
>
>      <p:input port="source">
>        <p:document href="first.xml"/>
>      </p:input>
>
>      <p:output port="result" sequence="true">
>        <p:empty/>
>      </p:output>
>
>      <p:xslt name="first-to-intermediate">
>        <p:input port="stylesheet">
>          <p:document href="first.xsl"/>
>        </p:input>
>        <p:input port="parameters">
>          <p:empty/>
>        </p:input>
>      </p:xslt>
>
>      <p:store href="intermediate.xml" />
>
>      <p:xslt>
>        <p:input port="source">
>          <p:document href="intermediate.xml"/>
>        </p:input>
>        <p:input port="stylesheet">
>          <p:document href="final.xsl"/>
>        </p:input>
>        <p:input port="parameters">
>          <p:empty/>
>        </p:input>
>      </p:xslt>
>
>      <p:store href="final.xml"/>
>
>    </p:declare-step>
>
> Just for the sake of completeness: these are the transformation files:
>
> source.xml:
>
>    <root>
>      <element name="A" />
>    </root>
>
> first.xsl:
>
>    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>      version="2.0">
>      <xsl:output indent="yes"/>
>
>      <xsl:template match="root">
>        <root>
>          <xsl:apply-templates/>
>        </root>
>      </xsl:template>
>      <xsl:template match="element">
>        <intermediate name="A" />
>      </xsl:template>
>
>    </xsl:stylesheet>
>
> final.xsl:
>
>    <?xml version="1.0" encoding="UTF-8"?>
>    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>      version="2.0">
>      <xsl:output indent="yes"/>
>
>      <xsl:template match="root">
>        <root>
>          <xsl:apply-templates/>
>        </root>
>      </xsl:template>
>      <xsl:template match="intermediate">
>        <final name="A" />
>      </xsl:template>
>
>    </xsl:stylesheet>
>
>
>
> Thanks
>
> Patrick
>
>
>
>
Received on Sunday, 20 May 2012 11:21:04 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Sunday, 20 May 2012 11:21:04 GMT