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


Thanks too, but my ideal scenario is to encapsulate the entire
description of the pipeline into a single document of one format (XML)
that can be executed with as few dependencies as possible. The reason
that I'm so adamant about XProc being able to do this is that I think
the inability of XProc to either allow an expression in p:data/@href or
use p:data/p:with-option is somewhat of an omission.

There are potentially other use-cases beyond HTML Tidy. Taking URIs from
source documents that point to non-XML files (CSS), retrieving them so
that they can be processed using XSLT + Regular Expressions is not so
much of an edge-case that it can't/shouldn't be easily supported.


Philip Fennell

-----Original Message-----
From: Henry S. Thompson [] 
Sent: 01 May 2009 13:16
To: Philip Fennell
Cc: XProc Dev
Subject: Re: How do you pass step options to p:data/@href???

Hash: SHA1

Philip Fennell writes:

> Thanks Norm, but I don't hink that helps.
>> If you're reading a document flowing through a pipeline, then it is
> XML.
> That's exactly what I'm not trying to do. I'm wanting to invoke Tidy 
> on an HTML document that is not well-formed XML so that I can do 
> further processing on it. Therefore I need to use p:data to get hold 
> of a non-XML document.

An alternative for this, and as you point out other similar
up-translation/input coversion pipelines, is to define a script which
calls wget/curl/your-choice and pipes the result to tidy, along the
lines of
  wget --output-document - "$uri" 2>/dev/null | tidy "$@"

  @echo off
  set file=%1
  wget --output-document - %file% 2>NUL: | tidy %1 %2 %3 %4 %5 %6 %7 %8

  <p:pipeline xmlns:p=""
   <p:declare-step name="fetch-and-tidy" type="my:tidy">  
     <p:option name="href"/> 
     <p:output port="result" primary="true"/>

     <p:exec command="fetch-and-tidy.bat" source-is-xml="false"
             result-is-xml="true" wrap-result-lines="false" name="ft"> 
        <p:with-option name="args" select="concat('&quot;',$href,'&quot;
-asxml --quiet yes --show-warnings no --doctype omit --numeric-entities
yes --output-xml yes')">
        <p:input port="source">
      <p:unwrap match="c:result"/>
   <my:tidy href=""/>

The above works in Calabash 0.9.9

Note that in any case you need to tweak your pipeline a bit from where
you and Norm left it, to get the xmlness of things accurately reflected.
The following works in Calabash 0.9.9:

 <p:pipeline xmlns:p=""
  <p:declare-step type="my:tidy">
    <p:input port="source"/>
    <p:output port="result"/>

    <p:exec command="tidy"
      <p:with-option name="args" select="'-asxml --quiet yes
--show-warnings no --doctype omit --numeric-entities yes --output-xml
    <p:unwrap match="c:result"/>

    <p:input port="source">
     <p:data href=""/>

- -- 
       Henry S. Thompson, School of Informatics, University of Edinburgh
                         Half-time member of W3C Team
      10 Crichton Street, Edinburgh EH8 9AB, SCOTLAND -- (44) 131
                Fax: (44) 131 651-1426, e-mail:
                       URL: [mail really
from me _always_ has this .sig -- mail without it is forged spam]
Version: GnuPG v1.2.6 (GNU/Linux)

This e-mail (and any attachments) is confidential and may contain personal views which are not the views of the BBC unless specifically stated.
If you have received it in error, please delete it from your system.
Do not use, copy or disclose the information in any way nor act in reliance on it and notify the sender immediately.
Please note that the BBC monitors e-mails sent or received.
Further communication will signify your consent to this.

Received on Friday, 1 May 2009 12:52:57 UTC