W3C home > Mailing lists > Public > xproc-dev@w3.org > January 2010

How does one specify for the cx:zip how to take the xml from the previous step and save that xml within a zip file?

From: Alex Muir <alex.g.muir@gmail.com>
Date: Fri, 15 Jan 2010 10:52:45 +0000
Message-ID: <88b533b91001150252w1a89390hd80aba43d2c13e@mail.gmail.com>
To: XProc Dev <xproc-dev@w3.org>
Hi,

I'm trying to write some xproc code that unzips a set series of zip files
which each have one xml file and then zips the xml file again in a new file.
Eventually I'll add some processing of the xml file within but for now just
needing to understand the zip functionality better,

In the following code the unzip works well but not the zip.

How does one specify for the cx:zip how to take the xml from the previous
step and save that xml within a zip file?

Thanks Much
Alex



<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" xmlns:xsd="
http://www.w3.org/2001/XMLSchema"  name="Standardization">

  <p:input port="source"/>

  <p:output port="result" sequence="true"/>
  <p:declare-step type="cx:message">
    <p:input port="source"/>
    <p:output port="result"/>
    <p:option name="message" required="true"/>
  </p:declare-step>


  <p:declare-step type="cx:unzip">
    <p:output port="result"/>
    <p:option name="href" required="true"/>
    <p:option name="file"/>
    <p:option name="content-type"/>
  </p:declare-step>

  <p:declare-step type="cx:zip">
    <p:input port="source" sequence="true" primary="true"/>
    <p:input port="manifest"/>
    <p:output port="result"/>
    <p:option name="href" required="true" cx:type="xsd:anyURI"/>
    <p:option name="compression-method" cx:type="stored|deflated"/>
    <p:option name="compression-level"
cx:type="smallest|fastest|default|huffman|none"/>
    <p:option name="command" select="'update'"
cx:type="update|freshen|create|delete"/>
    <p:option name="byte-order-mark" cx:type="xsd:boolean"/>
    <p:option name="cdata-section-elements" select="''"
cx:type="ListOfQNames"/>
    <p:option name="doctype-public" cx:type="xsd:string"/>
    <p:option name="doctype-system" cx:type="xsd:anyURI"/>
    <p:option name="encoding" cx:type="xsd:string"/>
    <p:option name="escape-uri-attributes" select="'false'"
cx:type="xsd:boolean"/>
    <p:option name="include-content-type" select="'true'"
cx:type="xsd:boolean"/>
    <p:option name="indent" select="'false'" cx:type="xsd:boolean"/>
    <p:option name="media-type" cx:type="xsd:string"/>
    <p:option name="method" select="'xml'" cx:type="xsd:QName"/>
    <p:option name="normalization-form" select="'none'"
cx:type="NormalizationForm"/>
    <p:option name="omit-xml-declaration" select="'true'"
cx:type="xsd:boolean"/>
    <p:option name="standalone" select="'omit'" cx:type="true|false|omit"/>
    <p:option name="undeclare-prefixes" cx:type="xsd:boolean"/>
    <p:option name="version" select="'1.0'" cx:type="xsd:string"/>
  </p:declare-step>




  <p:variable name="source-folder" select="'../zip/'"/>
  <p:variable name="output-folder" select="'../zipout/'"/>

  <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[position() gt 0 ]"/>
    <!-- <p:output port="result"/>-->

    <p:variable name="fileName" select="c:file/@name"/>

    <cx:message>
      <p:with-option name="message"
        select="concat(p:iteration-size(),'  ', p:iteration-position(), '
', $fileName)"/>
    </cx:message>


    <cx:unzip name="get-XML">
      <p:with-option name="href" select="concat($source-folder,$fileName)"/>
      <p:with-option name="file" select="replace($fileName,'.zip','.xml')"/>
    </cx:unzip>

    <cx:zip href="concat($output-folder,replace($fileName,'.zip','2.zip'))"
command="update">
      <p:input port="source"/>
      <p:input port="manifest">
        <p:inline>
          <c:zip-manifest>
            <c:entry name="new.xpl" comment="Hi mom"
compression-method="stored" compression-level="default"/>
          </c:zip-manifest>
        </p:inline>
      </p:input>
    </cx:zip>

  </p:for-each>

  <p:documentation>Wrap result XML </p:documentation>
  <p:wrap-sequence wrapper="forEachFile"/>
  <p:identity/>
</p:declare-step>

-- 

Alex
https://sites.google.com/a/utg.edu.gm/alex
Received on Friday, 15 January 2010 10:53:19 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 15 January 2010 10:53:19 GMT