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

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

From: <vojtech.toman@emc.com>
Date: Tue, 21 Sep 2010 06:16:49 -0400
Message-ID: <997C307BEB90984EBE935699389EC41C024E051D@CORPUSMX70C.corp.emc.com>
To: <xproc-dev@w3.org>
> 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'"/>


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:variable name="query" select="'version.xml'"/>
  <p:variable name="uri" select="//uri"/>
  <p:variable name="username" select="//username"/>
  <p:variable name="password" select="//password"/>


> 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

<p:add-attribute match="c:request" attribute-name="href">
  <p:input port="source">
      <c:request method="get" detailed="true" auth-method="basic"/>
  <p:with-option name="attribute-value" select="concat($uri, $query)"/>

<p:add-attribute match="c:request" attribute-name="username">
  <p:with-option name="attribute-value" select="$username"/>

<p:add-attribute match="c:request" attribute-name="password">
  <p:with-option name="attribute-value" select="$password"/>

Hope this helps.


Vojtech Toman
Consultant Software Engineer
EMC | Information Intelligence Group
Received on Tuesday, 21 September 2010 10:18:51 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:16:54 UTC