W3C home > Mailing lists > Public > xproc-dev@w3.org > April 2009

Here are two simple pipelines that use p:http-request

From: Costello, Roger L. <costello@mitre.org>
Date: Sat, 25 Apr 2009 14:06:46 -0400
To: "'xproc-dev@w3.org'" <xproc-dev@w3.org>
Message-ID: <9E51F88D5247B648908850C35A3BBB5003F245AA5A@IMCMBX3.MITRE.ORG>

Hi Folks,

I succeeded in using p:http-request. The hardest part wasn't using p:http-request, it was ensuring that I downloaded all the jar files that Calabash needs for p:http-request. After showing you my two simple pipelines I'll show you what jar files you need and where to get them.


Here's a simple pipeline file that uses p:http-request to get an RSS feed:
---------------------------------------------------------------
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
                xmlns:c="http://www.w3.org/ns/xproc-step">
    <p:input port="source">
        <p:inline>
            <c:request method="GET"
                       href="http://rss.cnn.com/rss/cnn_topstories.rss" />
        </p:inline>
    </p:input>
    <p:output port="result">
    </p:output>
    
    <p:http-request />

</p:declare-step>
---------------------------------------------------------------


Here is a pipeline that gets the RSS feed and then styles the feed:
---------------------------------------------------------------
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
                xmlns:c="http://www.w3.org/ns/xproc-step">
    <p:input port="source">
        <p:inline>
            <c:request method="GET"
                       href="http://rss.cnn.com/rss/cnn_topstories.rss" />
        </p:inline>
    </p:input>
    <p:output port="result">
    </p:output>
    
    <p:http-request />

    <p:xslt>
        <p:input port="source"/>
        <p:input port="stylesheet">
            <p:document href="RSS.xsl"/>
        </p:input>
        <p:input port="parameters">
            <p:empty/>
        </p:input>
    </p:xslt>

</p:declare-step>
---------------------------------------------------------------

Notice RSS.xsl. Here is a stylesheet for RSS feeds:

http://www.dotnetjunkies.ddj.com/Tutorial/9FB56D07-4052-458C-B247-37C9E4B6D719.dcik

I made a few tweaks to it, to get it to properly display the CNN RSS feed.


In order for the above pipelines to work, you need to make sure that you've downloaded all the jar files that Calabash needs. Here's how I describe it in my XProc tutorial's README.txt file:

[In my tutorial's folder] There is a lib folder. It has five subfolders:

   calabash

   saxon

   apache-commons-http-client

   apache-commons-codec

   apache-commons-logging

You need to download the XProc processor, Calabash, and install its
.jar file in the calabash folder. You can obtain Calabash here:

   http://xmlcalabash.com/download/

Calabash uses SAXON, so you need to download SAXON-SA and install its
.jar files in the saxon folder. You can obtain SAXON-SA here:

   http://www.saxonica.com/

For interacting with web services (using the p:http-request step) you
need to obtain the Apache Commons HTTP Client:

   http://hc.apache.org/downloads.cgi (download Commons HttpClient 3.1)

And you need to obtain the Apache Commons Codec:

   http://commons.apache.org/downloads/download_codec.cgi

And you need to obtain the Apache Commons Logging:

   http://commons.apache.org/downloads/download_logging.cgi
    

Here's what the folders should contain after you've downloaded and
installed the .jar files:

   lib
      calabash
         calabash.jar
      saxon
          saxon9.jar
          saxon9-dom4j.jar
          saxon9-dom4j.jar
          saxon9-jdom.jar
          saxon9-s9api.jar
          saxon9sa.jar
          saxon9sa-jaxp.jar
          saxon9sa-qc.jar
          saxon9-sql.jar
          saxon9-xom.jar
          saxon9-xpath.jar
          saxon9-xqj.jar
      apache-commons-http-client
          commons-httpclient-3.1.jar
      apache-commons-codec
          commons-codec-1.3.jar
      apache-commons-logging
          commons-logging-1.1.1.jar
          commons-logging-1.1.1-javadoc.jar
          commons-logging-1.1.1-javadoc.jar
          commons-logging-adapters-1.1.1.jar
          commons-logging-api-1.1.1.jar
          commons-logging-tests.jar

Be sure your CLASSPATH points to each of these jar files.

/Roger
Received on Saturday, 25 April 2009 18:07:23 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Saturday, 25 April 2009 18:07:24 GMT