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

Re: Making a lookup structure from multiple documents

Subject: Re: Making a lookup structure from multiple documents
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 12 Jun 2023 19:20:47 -0000
Re:  Making a lookup structure from multiple documents
On 6/12/2023 8:49 PM, Martin Honnen martin.honnen@xxxxxx wrote:
> 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.
> 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.

I think the following might combine an accumulator on the map and on the
referenced documents:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

 B B B  xmlns:xs="http://www.w3.org/2001/XMLSchema"

 B B B  xmlns:math="http://www.w3.org/2005/xpath-functions/math"

 B B B  xmlns:map="http://www.w3.org/2005/xpath-functions/map"

 B B B  exclude-result-prefixes="xs math map"

 B B B  version="3.0" expand-text="yes">

 B B B  <xsl:output indent="yes"/>

 B B B  <xsl:accumulator name="summary-data" initial-value="()"

 B B B B B B B  <xsl:accumulator-rule
 B B B B B B B B B B  <xsl:sequence select="$value"/>
 B B B B B B B B B B  <xsl:apply-templates select="doc(@href)"
 B B B B B B B  </xsl:accumulator-rule>

 B B B B B B B  <xsl:accumulator-rule match="tool" select="$value, ." />

 B B B B B B B  <xsl:accumulator-rule match="spare" select="$value, ." />

 B B B B B B B  <xsl:accumulator-rule match="supply" select="$value, ." />

 B B B  </xsl:accumulator>

 B B B  <xsl:mode name="collect" on-no-match="shallow-skip"

 B B B  <xsl:template match="/" mode="collect">
 B B B B B  <xsl:apply-templates mode="#current"/>
 B B B B B  <xsl:sequence select="accumulator-after('summary-data')"/>
 B B B  </xsl:template>

 B B B  <xsl:template match="/">

 B B B  <doc>

 B B B B B B B  <xsl:apply-templates/>

 B B B B B B B  <xsl:for-each select="accumulator-after('summary-data')">

 B B B B B B B B B B B  <xsl:element name="{local-name(.)}"><xsl:attribute
name="quantity" select="./@quantity"/>{.}</xsl:element>

 B B B B B B B  </xsl:for-each>

 B B B  </doc>

 B B B  </xsl:template>

 B B B  <xsl:mode on-no-match="shallow-skip"


Current Thread


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.
First Name
Last Name
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.