RE: (p:data) / p:http-request in p:for-each

Toman, Phillip and Alex

Thanks for helping! Especially for pointing me to http:request.
Nevertheless I'm still struggling getting that part of the pipe to work
and currently managed to break it. I don't understand how to connect
http-request from within the loop. 

The suggested step "<p:make-absolute-uris match="c:request/@href"
name="request">" did not work for me, maybe because it is used in the
context of p:directory? 

I renamed c:file/@name to c:request/@href using 2 rename steps to get
the input that I understand http-request needs. The pipe runs until the
loop starts. There it breaks. I'm glad for help and pretty sure that
this is a newbie error.

I'm using calabash from within oxygenxml 11 without modifications on a
linux system. 

this is the output of the last step before the loop:

<c:request xmlns:c="http://www.w3.org/ns/xproc-step"
href="file:///home/stefanie/Magisterarbeit/quellcode/xproc/mini-test-db/gba/80tage/80tage.htm"/>
<c:request xmlns:c="http://www.w3.org/ns/xproc-step"
href="file:///home/stefanie/Magisterarbeit/quellcode/xproc/mini-test-db/gba/80tage/80pass.htm"/>

This is the current xproc:

<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="myPipeline">
  <p:input port="source" sequence="true"/>
  <p:output port="result" sequence="true">
    <p:pipe port="result" step="fileloop"/>
  </p:output>

  <!-- declare path -->
  <p:variable name="path"

select="'file:///home/stefanie/Magisterarbeit/quellcode/xproc/mini-test-db/gba/80tage'">
    <p:empty/>
  </p:variable>

  <!-- list directory -->
  <p:directory-list name="directories">
    <p:with-option name="path" select="$path">
      <p:empty/>
    </p:with-option>
  </p:directory-list>

  <!-- show complete path  -->

  <p:make-absolute-uris match="c:file/@name" name="uri">
    <p:with-option name="base-uri" select="p:resolve-uri(concat($path,
'/',
      c:file/@name))"/>
  </p:make-absolute-uris>

  <p:string-replace match="c:file/@name" replace="replace(., 'file:',
'file://')" name="replace">
    <p:documentation>Fixes the URI so that it can be used by the
http-request
      step.</p:documentation>
  </p:string-replace>

  <p:rename match="c:file" new-name="c:request"/>
  <p:rename match="@name" new-name="href"/>

  <!-- excluding other file types works great -->
  <p:filter select="//c:request[matches(@href, 'htm')]" name="filter"/>

  <!-- loop over files and do some html tidy.   -->

  <p:for-each name="fileloop">
   <!-- <p:iteration-source select="//c:request"/>-->
    <!-- This may be obsolete as a filter is defined -->
    <p:output port="result" sequence="true"/>

    <p:http-request method="get"/>

    <p:exec command="/usr/bin/tidy" source-is-xml="false"
result-is-xml="true"
      wrap-result-lines="false">

      <p:with-option name="args"
        select="'--quiet yes
        --show-warnings no --doctype omit --numeric-entities yes
--output-xml
        yes'"
      />
    </p:exec>

    <p:unwrap match="c:result"/>

    <p:identity/>
  </p:for-each>

</p:declare-step>


Kind regards,
Stefanie


-- 
Stefanie Haupt

Received on Wednesday, 2 December 2009 13:32:24 UTC