[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Please help me understand maps

Subject: Re: Please help me understand maps
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Wed, 14 Aug 2013 18:47:49 +0100
Re:  Please help me understand maps
Yes, you've worked out the spec by induction.

map:new() takes a collection of maps and concatenates them into a single map.
There are a number of usage patterns, one is to concatenate a set of singleton
maps representing individual map entries, another is to concatenate a ("real")
map and a singleton map, etc.

The design aimed to avoid introducing a "map entry" or "key value pair" as a
separate kind of object, since it can be adequately represented by a map
containing a single entry.

Michael Kay
Saxonica


On 14 Aug 2013, at 18:30, Costello, Roger L. wrote:

> Hi Folks,
>
> My understanding of a map is that it is an object containing a bunch of
key/value pairs.
>
> That seems pretty simple.
>
> In the XSLT 3.0 specification it has this example:
>
> <xsl:variable name="isbn-index" as="map(xs:string, element(book))"
>
> Okay, $isbn-index is that name of a map. The keys for that map must be
strings and the value associated to each key must be a <book> element.
>
> Got it.
>
> Then the example assigns $isbn-index a value:
>
>    select="map:new(for $b in //book return map{$b/isbn := $b})"/>
>
> Yikes!
>
> What is that?
>
> Let me try to parse it:
>
> Step 1. Create a new map. That's what "map:new(...)" does.
>
> Step 2. Loop through each <book> element. That's what "for $b in //book
return ..." does.
>
> Step 3. For each <book> element create a map. That's what "map{$b/isbn :=
$b}" does. Huh?
>
> Step 1 creates a new map, so it should be assigned a bunch of key/value
pairs, right? Step 3 is blasting it with a bunch of maps. Huh? Where are the
new map's key/value pairs? I don't get it. Please help.
>
> Oh! Perhaps since each "inner map" object contains just one key/value pair,
each inner map object gets "unwrapped" to yield its key/value pair to the
"outer map" object. Ha! How do you like that theory?
>
> /Roger

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.