Re: [xsl] Making a lookup structure from multiple documents

Subject: Re: [xsl] Making a lookup structure from multiple documents
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 12 Jun 2023 18:49:16 -0000
On 6/12/2023 8:33 PM, rick@xxxxxxxxxxxxxx wrote:
>
> I am missing something fundamental here I think. My accumulator is
> collecting the values from each topic separately, but I want it to
> accumulate the values from the entire hierarchy before I use them.
> Here is my output:
>
Accumulator, like keys, work on a per document basis. That is why in my
example I had some code doing e.g.


 B  <xsl:accumulator name="lookup" as="map(*)" initial-value="map{}">

 B B  <xsl:accumulator-rule
match="*[@href[matches(.,'(dita(map)?|xml)$','i')=true()][doc-available(.)]]"
>

 B B B  <xsl:variable name="collected" as="map(*)*">

 B B B B B  <xsl:apply-templates select="doc(@href)/*"/>

 B B B  </xsl:variable>

 B B B  <xsl:sequence select="map:merge(($value, $collected))"/>

 B B  </xsl:accumulator-rule>

</xsl:accumulator>

inside of the accumulator's rule body for the elements in the main
document and later made sure that for those nodes you want to lookup
there is a template outputting a value (which is then stored in the
accumulator of the original document, due to the above setup).

I will need to see whether you can combine an accumulator of the
original document with another on referenced documents; I think it is
easy with xsl:iterate or fold-left if you process a collection or uri
collection but if the processing is done lower in a template I don't
have a better suggestion currently than the above one.

Current Thread