Re: About node references

"Vladimir Nesterovsky" <[email protected]> Mon, 15 Dec 2008 09:02:15 -0800
Newsgroups gmane.text.xml.xslt.extensions
Message-ID <533777f8$764e2705$143a5292$@com>
> > Probably I'm missing the nature of $function.
> > Can you please describe what is it?
> 
> It's a function which given a key returns the corresponding value.
> 
> So one could envisage defining keys something like this:
> 
> <xsl:variable name="productKey" select="map(//product/@id,
> xx:function('f:id-to-product'))"/>
> 
> <xsl:function name="f:id-to-product" as="element(product)">
>   <xsl:param name="id" select="xs:string"/>
>   <xsl:sequence select="//product[@id = $id]"/>
> </xsl:function>

> <xsl:sequence select="//product[@id = $id]"/>

Context is not defined.

> Perhaps we need to say that a map is constructed from a sequence of 
mapEntry
> objects, which can be constructed by a call on a mapEntry function like
> this:
> 
> <xsl:variable name="product-id-map" as="x:map"
>   select="x:map(for $p in //product return x:mapEntry($p/@id, $p))"/>
> 
> <xsl:value-of select="get-from-map($product-id-map, 'id214')"/>
> 
> Now there's no explicit reference object visible to the user here. It's
> merely something that the implementation might use internally, for 
example
> if the above functions were to be implemented in XSLT itself.

That is how I expected to see the map definition, or even without 
x:mapEntry at all:

<xsl:variable name="product-id-map" as="x:map"
  select="x:map(for $p in //product return ($p/@id, $p))"/>

--
Vladimir Nesterovsky
http://www.nesterovsky-bros.com