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

Re: How do you pass step options to p:data/@href???

From: Norman Walsh <ndw@nwalsh.com>
Date: Thu, 30 Apr 2009 12:50:41 -0400
To: XProc Dev <xproc-dev@w3.org>
Message-ID: <m2preujdb2.fsf@nwalsh.com>
Philip Fennell <Philip.Fennell@bbc.co.uk> writes:
[...]
> It works fine as it is, but, I'd like to use the 'href' option I've
> declared for the step to pass in the location of the source HTML file.
> However, the value of: p:data/@href won't take an expression e.g. $href
> and p:data doesn't allow <p:with-option name="href" select="$href"/>
>
> How do I pass the HTML source document URI to p:data as there is no
> other mechanism to get hold of unparsed character data?

Use p:pipe to connect the source port of the exec command to the source
port on your declared step, like this:

  <p:declare-step name="main" type="tidy:html">
    <p:input port="source"/>
    <p:output port="result"/>
    <p:option name="href"/>

    <p:exec command="tidy"
        source-is-xml="true"
        result-is-xml="false"
        wrap-result-lines="false"
        method="xml">
      <p:input port="source">
        <p:pipe step="main" port="source"/>
      </p:input>
      <p:with-option name="args" select="'--quiet yes --show-warnings no
  --doctype omit --numeric-entities yes --output-xml yes'"/>
    </p:exec>

    <p:unescape-markup/>
    <p:unwrap match="c:result"/> 
  </p:declare-step>

Note that I added a name to your declare step and changed
source-is-xml to true. If you're reading a document flowing through a
pipeline, then it is XML.

Since the source is the default readable port, you could also do this:

  <p:declare-step type="tidy:html">
    <p:input port="source"/>
    <p:output port="result"/>
    <p:option name="href"/>

    <p:exec command="tidy"
        source-is-xml="true"
        result-is-xml="false"
        wrap-result-lines="false"
        method="xml">
      <p:with-option name="args" select="'--quiet yes --show-warnings no
  --doctype omit --numeric-entities yes --output-xml yes'"/>
    </p:exec>

By default, the source port on p:exec will be connected to the default
readable port, which is the source port on your declare step in this
case.

                                        Be seeing you,
                                          norm

-- 
Norman Walsh <ndw@nwalsh.com> | It is well to remember that the entire
http://nwalsh.com/            | universe, with one trifling exception,
                              | is composed of others.--John Andrew
                              | Holmes

Received on Thursday, 30 April 2009 16:51:25 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 30 April 2009 16:51:27 GMT