|
Subject: [xsl] filtering maps by key characteristics? From: "Graydon graydon@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Mon, 24 Aug 2020 16:41:11 -0000 |
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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] DTD entities in XSLT, Martynas Jusevičius | Thread | Re: [xsl] filtering maps by key cha, Michael Kay mike@xxx |
| Re: [xsl] DTD entities in XSLT, Martynas Jusevičius | Date | Re: [xsl] filtering maps by key cha, Michael Kay mike@xxx |
| Month |