Re: Calabash error with p:unwrap? Unwrapping the input's root element doesn't generate an error

Hi Roger,

the way I interpret what you quoted is this:

    This step produces a single document; 
--> This is a definition: p:unwrap accepts a single document and returns this single document after removing the elements matched by the match pattern (retaining the children of the elements removed, by making them children of the respective parent elements of the removed elements).

    if the document element is unwrapped, 
    the result might not be well-formed XML.
--> The *single* document returned (by definition) may not be well-formed (though it will be well-balanced).

While Calabash will return an error when you pass a not well-formed document on the command line, the individual steps (at least some of them I tested) will process a not well-formed document without error, as can be seen by extending your pipeline by further steps:

<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" name="myPipeline">
    <p:input port="source">
        <p:document href="Bookstore.xml"/>
    </p:input>
    <p:output port="result" />
    
    <p:unwrap match="/BookStore" />
    <p:rename match="/Book" new-name="Buch" />
    <p:delete match="Date"/>

</p:declare-step>

At the same time p:unwrap, p:rename and p:delete would all reject an input of a sequence of documents as an error. So 
1) Calabash (and I guess the spec) distinguish between a sequence of documents and a single, not well-formed, but well-balanced document.
2) (Some) steps will process not well-formed, but well-balanced documents without error.

I can't say, whether this was really intended, but I don't think it conflicts with the spec. I do find it slightly confusing.

Tobias


Costello, Roger L. wrote:
> Hi Folks,
>
> This p:unwrap step unwraps the root element (BookStore) and thus outputs a sequence:
>
> <p:declare-step xmlns:p="http://www.w3.org/ns/xproc" name="myPipeline">
>     <p:input port="source">
>         <p:document href="Bookstore.xml"/>
>     </p:input>
>     <p:output port="result" />
>     
>     <p:unwrap match="/BookStore" />
>     
> </p:declare-step>
>
> When I run this using Calabash 0.9.9 I don't get an error message. I believe that I should get an error, right?  Here's what the specification says:
>
>     This step produces a single document; 
>     if the document element is unwrapped, 
>     the result might not be well-formed XML.
>
> /Roger
>
>
> Here's Bookstore.xml
>
> <?xml version="1.0"?>
> <BookStore>
>     <Book>
>         <Title>My Life and Times</Title>
>         <Author>Paul McCartney</Author>
>         <Date>1998</Date>
>         <ISBN>1-56592-235-2</ISBN>
>         <Publisher>McMillin Publishing</Publisher>
>     </Book>
>     <Book>
>         <Title>Illusions The Adventures of a Reluctant Messiah</Title>
>         <Author>Richard Bach</Author>
>         <Date>1977</Date>
>         <ISBN>0-440-34319-4</ISBN>
>         <Publisher>Dell Publishing Co.</Publisher>
>     </Book>
>     <Book>
>         <Title>The First and Last Freedom</Title>
>         <Author>J. Krishnamurti</Author>
>         <Date>1954</Date>
>         <ISBN>0-06-064831-7</ISBN>
>         <Publisher>Harper &amp; Row</Publisher>
>     </Book>
> </BookStore>
>
>   

Received on Sunday, 10 May 2009 11:55:31 UTC