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

Re: Newbie: config file import, and http-request

From: David Priest <docs@davidpriest.ca>
Date: Tue, 21 Sep 2010 13:11:58 -0700
Message-Id: <58072D29-440C-4233-AE63-E3F1A3D6514F@davidpriest.ca>
To: xproc-dev@w3.org
I'm working toward a solution based on list responses. It appears to almost work: there is an error caused by the loaded config file; after I'm done with extracting its auth elements, I need to dump it (but can't figure out how to do that).

Other than that, Calabash's output seems to indicate that it has successfully populated the variables, created attributes, and built the c:request.

The reason for using auth.xml: this is going into an automated build process.  The process that will call this is unknown to me; could be Ant, could be command line, could be a Windows batch script.  The more it can stand alone, the better. A one-time config file edit is more trustworthy, IMO.

command:
calabash fetch.xpl query="version.xml"

auth.xml:
<?xml version="1.0"?>
<config name="server">
  <uri>https://192.168.56.101/</uri>
  <username>admin</username>
  <password>password</password>
</config>

fetch.xpl:
<?xml version="1.0"?>
<!--
 - log into server
 - issue query
 - return document -->
<p:declare-step xmlns:c="http://www.w3.org/ns/xproc-step" xmlns:p="http://www.w3.org/ns/xproc" name="fetch" version="1.0">
  <p:output port="result"/>
  <p:input port="parameters" kind="parameter"/>
  <p:option name="query" required="true"/>
  <!-- load login details  -->
  <p:load href="auth.xml"/>
  <!-- create a request template -->
  <p:group name="request">
    <p:variable name="uri" select="//uri"/>
    <p:variable name="username" select="//username"/>
    <p:variable name="password" select="//password"/>
    <p:wrap wrapper="c:request" match="/"/>
    <p:add-attribute match="c:request" attribute-name="href">
      <p:with-option name="attribute-value" select="concat($uri, $query)"/>
    </p:add-attribute>
    <p:add-attribute match="c:request" attribute-name="username">
      <p:with-option name="attribute-value" select="$username"/>
    </p:add-attribute>
    <p:add-attribute match="c:request" attribute-name="password">
      <p:with-option name="attribute-value" select="$password"/>
    </p:add-attribute>
  </p:group>
  <p:set-attributes match="/c:request">
    <p:input port="attributes">
      <p:inline>
        <c:request method="put" auth-method="Basic" send-authorization="true"/>
      </p:inline>
    </p:input>
  </p:set-attributes>
  <!-- send it via http-request -->
  <p:http-request/>
</p:declare-step>
Received on Tuesday, 21 September 2010 20:12:28 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 21 September 2010 20:12:28 GMT