- From: Alex Muir <alex.g.muir@gmail.com>
- Date: Thu, 3 Jun 2010 16:32:16 +0000
- To: XProc Dev <xproc-dev@w3.org>
- Message-ID: <AANLkTilZx1Ak_5fY_LxHgCUsko5bbvoJGWqd73eyYQD6@mail.gmail.com>
Hi,
I'm trying to read ~10000 files within a for-each loop, wrap a selection
from each set of 200 files and process them to output 1 html file, sink the
processed files and continue with the remaining files processing 200 at a
time.
Is that possible in xproc?
I've got something like the following which I can't get to work. I think
that wrapper cannot be used within a for-each, is that the case?
<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="wrapWithinForEach"
version="1.0">
<p:input port="source">
<p:inline>
<xml/>
</p:inline>
</p:input>
<p:output port="result" sequence="true"/>
<p:declare-step type="cx:message" version="1.0">
<p:input port="source"/>
<p:output port="result"/>
<p:option name="message" required="true"/>
</p:declare-step>
<!-- ***** Starting and Ending File Numbers ***** -->
<p:variable name="startingFileNumber" select="'1'"/>
<p:variable name="endingFileNumber" select="'10000'"/>
<p:variable name="numberPerFile" select="'200'"/>
<!-- source and output folder variables -->
<p:variable name="source-folder" select="'completed/XML/'"/>
<p:variable name="output-folder" select="'MDNA/'"/>
<p:variable name="error-folder" select="'MDNA/error/'"/>
<p:variable name="exception-folder" select="'MDNA/exception/'"/>
<p:directory-list>
<p:with-option name="path" select="$source-folder">
<p:empty/>
</p:with-option>
</p:directory-list>
<p:for-each name="MDNA">
<p:iteration-source
select="//c:file[position() ge number($startingFileNumber) and
position() le number($endingFileNumber)]"/>
<p:variable name="fileName" select="c:file/@name"/>
<p:variable name="startingIterationPosition"
select="number(p:iteration-position()) +
number($startingFileNumber)-1"/>
<cx:message>
<p:with-option name="message"
select="concat('-----------------------------',
'Iteration-position:',' ', $startingIterationPosition, ' File: ',
$fileName,'-----------------------------')"
/>
</cx:message>
<p:load>
<p:with-option name="href"
select="concat($source-folder,$fileName)"/>
</p:load>
<cx:message>
<p:with-option name="message" select="'######
ExtractContent'"/>
</cx:message>
<p:xslt name="ExtractContent">
<p:input port="source"/>
<p:input port="stylesheet">
<p:document href="ExtractContent.xsl"/>
</p:input>
<p:input port="parameters">
<p:empty/>
</p:input>
</p:xslt>
<p:identity name="wrap"/>
<p:choose>
<p:when test="position() mod $numberPerFile eq 0">
<p:wrap-sequence wrapper="WRAP" name="wrapper">
<p:input port="source">
<p:pipe port="result" step="wrap"/>
</p:input>
</p:wrap-sequence>
<p:xslt name="CreateHTML">
<p:input port="source"/>
<p:input port="stylesheet">
<p:document href="CreateHTML.xsl"/>
</p:input>
<p:input port="parameters">
<p:empty/>
</p:input>
</p:xslt>
<p:identity name="out_file"/>
<p:store name="OUT">
<p:with-option name="href"
select="concat($output-folder,
'MDNASections','-',$startingFileNumber,'-' ,$endingFileNumber,'.html')">
<p:pipe step="out_file" port="result"/>
</p:with-option>
</p:store>
<p:sink name="sinkIt"/>
</p:when>
</p:choose>
</p:for-each>
</p:declare-step>
Regards
--
Alex
An informal recording with one mic under a tree leads to some pretty sweet
acoustic sounds.
https://sites.google.com/site/greigconteh/albums/diabarte-and-sons
Received on Thursday, 3 June 2010 16:32:49 UTC