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

Thank you, that helps immensely!

-- 
davidpriest.ca
XML/XSLT Workflows
& Documentation

On 2010-09-21, at 3:16 AM, <vojtech.toman@emc.com> wrote:

>> 1. Surely there's a better way than the ugly variable assignments.
> 
> I am not sure that using parameters for this is the best/easiest
> approach in your case. I would use options instead:
> 
> <?xml version="1.0"?>
> <p:declare-step xmlns:c="http://www.w3.org/ns/xproc-step"
> xmlns:p="http://www.w3.org/ns/xproc" name="mir.fetch" version="1.0">
>  <p:output port="result"/>
>  <p:option name="uri" required="true"/>
>  <p:option name="username" required="true"/>
>  <p:option name="password" required="true"/>
>  <p:option name="query" select="'version.xml'"/>
> 
>  <p:http-request>...</p:http-request>
> </p:declare-step>
> 
> The trouble with parameters and parameter inputs is that you cannot
> guarantee that all parameters that you need are actually passed to the
> step. With options you have more control over what is required, what the
> defaults are etc.
> 
> If you really want to use a config file, I personally wouldn't represent
> it as a c:param document and process it using p:parameters. Instead, I
> would probably use my own simple syntax and load the document using
> p:load (you can also check if the config document is valid by using one
> of the validation steps) and then store the the relevant information in
> variables, in a similar way that you did:
> 
> <p:load href="auth.xml"/>
> <p:group>
>  <p:variable name="query" select="'version.xml'"/>
>  <p:variable name="uri" select="//uri"/>
>  <p:variable name="username" select="//username"/>
>  <p:variable name="password" select="//password"/>
> 
>  <p:http-request>...</p:http-request>
> </p:group>
> 
> 
>> 2. Much to my surprise, variable substitution doesn't work. One
> doesn't use
>> $variablename as in XSLT.  But I can't see that using concat() would
> work.  Do I end
>> up using a bunch of ugly with-params?
> 
> Indeed, variable substitution does not work in XProc 1.0, and it is a
> known limitation that is on the WG's TODO list for the next version of
> the language.
> 
> One way to build the c:request document dynamically is something like
> this:
> 
> <p:add-attribute match="c:request" attribute-name="href">
>  <p:input port="source">
>    <p:inline>
>      <c:request method="get" detailed="true" auth-method="basic"/>
>    </p:inline>
>  </p:input>
>  <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>
> 
> Hope this helps.
> 
> Vojtech
> 
> --
> Vojtech Toman
> Consultant Software Engineer
> EMC | Information Intelligence Group
> vojtech.toman@emc.com
> http://developer.emc.com/xmltech 
> 
> 
> 

Received on Tuesday, 21 September 2010 19:39:26 UTC