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

Re: p:wrap's group-adjacent

From: Jeni Tennison <jeni@jenitennison.com>
Date: Sat, 20 Sep 2008 20:00:20 +0100
Cc: XProc Dev <xproc-dev@w3.org>
Message-Id: <566EAB0A-30F8-4922-90FD-96D6E012E0B9@jenitennison.com>
To: James Garriss <james@garriss.org>


On 19 Sep 2008, at 23:04, James Garriss wrote:
> Suppose I wanted to wrap the two <Book> elements with a <Books>  
> element, so it would look like this:
> <BookStore>
>   <Books>
>     <Book>...
>     <Book>...
>   </Books>
>   <Invoice>
>      <Cost>...
>   </Invoice>
> </BookStore>
> I should have thought one of these would have worked:
> <p:wrap wrapper="Books" match="//Book" group- 
> adjacent="boolean(self::Book)"/>
> <p:wrap wrapper="Books" match="//Book" group-adjacent=". instance of  
> element(Book)"/>

Actually, given the way p:wrap is written, I think that:

<p:wrap wrapper="Books" match="Book" group-adjacent="true()" />

should work. The only things you want to wrap are <Book> elements, and  
whenever there are any of them in a sequence, you want to wrap them  
together; the XPath expression "true()" always returns true.

The expression boolean(self::Book) would work as well, but would be  
better for a situation such as:


where you could do:

<p:wrap wrapper="Para" match="Section/*" group- 
adjacent="boolean(self::Item)" />

which would wrap all the elements within <Section> in <Para> elements,  
and wrap the <Item> elements together, like so:


(You'd then want a step that turned the Para elements that held Item  
elements into List elements, like: <p:rename match="Para[Item]" new- 
name="List" />.)

Jeni Tennison
Received on Saturday, 20 September 2008 19:00:55 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:03:03 UTC