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

XSLT 4: map serialization

Subject: XSLT 4: map serialization
From: "Graydon graydon@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 25 Nov 2020 02:03:39 -0000
 XSLT 4: map serialization
So if I have a sequence of maps, such as one gets from using collection() with the metadata flag set in Saxon, and I want to serialize the result just to see what is in there, I'd like to be able to use:

<xsl:sequence select="$fileArchive ! map:for-each(.,function($k,$v){element{$k}{$v}})" />

This isn't allowed, because map:for-each() takes an XPath function, rather than an XQuery function, so it hasn't got access to element constructors.

<xsl:for-each select="$fileArchive">
  <xsl:variable as="map(*)" name="currentEntry" select="." />
  <entry>
    <xsl:for-each select="map:keys($currentEntry)[not(. eq 'fetch')]">
      <xsl:element name="{.}">
        <xsl:sequence select="$currentEntry(.)" />
      </xsl:element>
    </xsl:for-each>
  </entry>
</xsl:for-each>

works fine, but I can't help but feel that it lacks elegance of
expression compared to the map:for-each() construction.

Allowing XQuery anonymous functions would be a large change, but at least in the map serialization case[1] I have trouble thinking of a better option.  XQuery functions are at least already well-defined.

[1] I cannot tell you how much I want to be able to pass parameters to a functioned returned from a map of function items and have that function return elements for applying-a-style purposes, e.g.

<xsl:sequence select="$stylesMap($styleTypeName)($stylePropertiesMap($styleName))" />

-- 
Graydon Saunders  | graydonish@xxxxxxxxx
^fs oferiode, pisses swa mfg.
-- Deor  ("That passed, so may this.")

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.