- From: Alex Muir <alex.g.muir@gmail.com>
- Date: Thu, 26 Nov 2009 12:00:48 +0000
- To: XProc Dev <xproc-dev@w3.org>
- Message-ID: <88b533b90911260400l366104fak7e188c50ac544385@mail.gmail.com>
Hi, In essence the following example, based on the result of some processing saves output to one folder or another. In doing so I repeat all the store and result code twice. I'm wondering if someone could show me how to take the store and result code and put it into one step that gets called from two places passing as parameters the output folder and file name. <p:declare-step xmlns:p="http://www.w3.org/ns/xproc" xmlns:c="http://www.w3.org/ns/xproc-step" xmlns:cx="http://xmlcalabash.com/ns/extensions" name="StoreDifferentLocations"> <p:import href="Library.xpl" /> <p:input port="source"> <p:document href="blank.xml"/> </p:input> <p:output port="result" sequence="true" /> <p:variable name="source-folder" select="'../HTML/'"/> <p:variable name="output-folder" select="'../OUT/'"/> <p:variable name="differentOutputFolder" select="'../OTHER/'"/> <p:directory-list> <p:with-option name="path" select="$source-folder"> <p:empty/> </p:with-option> </p:directory-list> <p:for-each name="forEachFile"> <p:iteration-source select="//c:file"/> <p:variable name="fileName" select="c:file/@name"/> <p:xslt name="DeterminePageBreaks"> <p:input port="source"/> <!-- not sure if this is required here --> <p:input port="stylesheet"> <p:document href="DeterminePageBreaks.xsl"/> </p:input> <p:with-param name="input_uri" select="concat($source-folder,$fileName)"/> <p:input port="parameters"> <p:empty/> </p:input> </p:xslt> <p:choose> <p:when test="/document[@hasPageBreaks = 'true']"> <p:output port="result"/> <p:xslt name="DoSomething"> <p:input port="stylesheet"> <p:document href="DoSomething.xsl"/> </p:input> <p:input port="parameters"> <p:empty/> </p:input> </p:xslt> <p:documentation> Store XML file Output </p:documentation> <p:identity name="out_file"/> <p:store name="store"> <p:with-option name="href" select="concat($differentOutputFolder, $fileName)"> <p:pipe step="out_file" port="result"/> </p:with-option> </p:store> <p:documentation> Create result XML </p:documentation> <p:identity> <p:input port="source"> <p:pipe step="store" port="result"/> </p:input> </p:identity> </p:when> <p:otherwise> <p:output port="result"/> <p:documentation> Store XML file Output </p:documentation> <p:identity name="out_file"/> <p:store name="store"> <p:with-option name="href" select="concat($differentOutputFolder, $fileName)"> <p:pipe step="out_file" port="result"/> </p:with-option> </p:store> <p:documentation> Create result XML </p:documentation> <p:identity> <p:input port="source"> <p:pipe step="store" port="result"/> </p:input> </p:identity> </p:otherwise> </p:choose> </p:for-each> <p:documentation>Wrap result XML </p:documentation> <p:wrap-sequence wrapper="forEachFile"/> <p:identity/> </p:declare-step> Thanks Much -- Alex https://sites.google.com/a/utg.edu.gm/alex
Received on Thursday, 26 November 2009 12:01:22 UTC