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

filtering maps by key characteristics?

Subject: filtering maps by key characteristics?
From: "Graydon graydon@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 24 Aug 2020 16:41:11 -0000
 filtering maps by key characteristics?
Hello --

I have a content set traversal that creates map entries when it finds id
attributes in the source tree; one map entry maps a generated GUID to
the node with the id attribute, and another map entry maps the value of
the id attribute to the same GUID.

The result is stored as a sequence of singleton maps:

<xsl:variable as="map(*)+" name="traversalMap">
  <xsl:apply-templates mode="traverse" select="$contentSet" />
</xsl:variable>

This sequence of ~map entries then get filtered into two merged maps, one with the GUID-to-element mapping, and one with the id-value-to-GUID mapping:

<xsl:variable as="map(xs:string,element())" name="GUID2nodeMap">
  <xsl:map>
    <xsl:sequence select="$traversalMap ! .[starts-with(map:keys(.), 'GUID-')]" />
  </xsl:map>
</xsl:variable>
<xsl:variable as="map(xs:string,xs:string)" name="DITA2GUIDmap">
  <xsl:map>
    <xsl:sequence select="$traversalMap ! .[not(starts-with(map:keys(.), 'GUID-'))]" />
  </xsl:map>
</xsl:variable>

(I thought it would be easier to split a sequence of ~map entries into
two maps than it would be to traverse the tree twice.)

And it works, but it wouldn't work if I was starting with a merged map,
rather than a sequence of ~map entries/singleton maps.

Is there a way to do this with a merged map, that is, filter a map with
multiple entries by testing characteristics of the keys without having
to reconsitute each entry?

$traverseMap[starts-with(map:key(.),'GUID-')]

doesn't work; the context is the WHOLE map, not a map entry.  And there
doesn't seem to be a way to treat a map as a sequence of map entries.

Is there one?  Am I missing something?

Thanks!

-- 
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.