|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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="()"
as="element()*">
B B B B B B B <xsl:accumulator-rule
match="*[@href[matches(.,'(dita(map)?|xml)$','i')][doc-available(.)]]">
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)"
mode="collect"/>
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"
use-accumulators="summary-data"/>
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"
use-accumulators="summary-data"/>
</xsl:stylesheet>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








