xsl-list
[Top] [All Lists]

Re: [xsl] constructing arrays in XSLT with templates

2021-06-19 08:50:08
I like the binding via the *for $book in books/book* expression .. it makes
the entire mapping block more readable.

Thanks again, very helpful.

-alan




On Sat, Jun 19, 2021 at 12:47 PM Martin Honnen 
martin(_dot_)honnen(_at_)gmx(_dot_)de <
xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:


Am 19.06.2021 um 12:37 schrieb Martin Honnen 
martin(_dot_)honnen(_at_)gmx(_dot_)de:

Or you would need to use a for expression to bind a "book" e.g.


    map {
      'books' : array {
        for $book in books/book return map:merge((
          map:entry('title',        $book!title         !string()   ),
          map:entry('authors',      array { $book!author!string() } ),
*          map:entry('out-of-print', true())[$book/@out-of-print eq
'true']*
        ))
      }
    }


Or perhaps a local let binding


    map {
      'books' : array {
        books/book ! map:merge((
          map:entry('title',        title         !string()   ),
          map:entry('authors',      array { author!string() } ),
          let $book := . return map:entry('out-of-print',
true())[$book/@out-of-print eq 'true']
        ))
      }
    }
XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/552232> (by
email <>)

--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>