Sinking(?) unwanted ports

I think that's what I want to do, but I can't figure out how to do it.  Given the scripts below, fetch.xpl craps out because the auth.xml file is part of the process stream, and isn't legitimate XProc.

Once I've got the auth information into variables, how do I get rid of the imported config document?  I've tried placing <p:delete match="//config"/> in a few places, <p:sink> in a few, etcetera.  None of it's working.

Come to think of it, if there are *any* improvements to this, I'd love to hear them!

(This needs to be done using an auth file, because I have no control over the code that calls XProc.  I can't trust it to supply name/pw/uri info; it's much easier to have someone edit the auth file once, than to create working code.)

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>


-- 
David Priest • docs@davidpriest.ca
http://davidpriest.ca
http://twitter.com/davidpriest_ca

Received on Wednesday, 22 September 2010 17:05:21 UTC