[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: Tue, 13 Jun 2023 16:17:42 -0000
Re:  Making a lookup structure from multiple documents
On 6/13/2023 6:05 PM, rick@xxxxxxxxxxxxxx wrote:
>
> Now that I have collected my data from the entire ditamap hierarchy, I
> need to make a second pass through the map and any referenced topics
> and use the summary data in a particular element in one of the topics.
> I am not sure how to go back to the beginning and process the map with
> the collected data from the first pass. Here is my stylesheet:
>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
> xmlns:math="http://www.w3.org/2005/xpath-functions/math"
>
> 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 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')]]">
>
> B B B B B B B B B B B  <xsl:sequence select="$value"/>
>
> B B B B B B B B B B B  <xsl:variable name="ref-path"
> select="resolve-uri(@href,base-uri(.))"/>
>
> B B B B B B B B B B B  <xsl:if test="doc-available($ref-path)=true()">
>
> B B B B B B B B B B B B B B B  <xsl:apply-templates select="doc($ref-path)"
> mode="collect"/>
>
> B B B B B B B B B B B  </xsl:if>
>
> 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 B <xsl:mode name="collect" on-no-match="shallow-skip"
> use-accumulators="summary-data"/>
>
> B B B B <xsl:template match="/" mode="collect">
>
> B B  B B B B B <xsl:apply-templates mode="#current"/>
>
> B B B B B B B  <xsl:sequence select="accumulator-after('summary-data')"/>
>
> B B B  </xsl:template>
>
> B B B B <xsl:template match="/">
>
> <!--<xsl:apply-templates/>-->
>
> B B B B B B B  <map-data>
>
> B B B B B B B B B B B  <summary>
>
> B B B B B B B B B B B B B B B  <xsl:for-each-group
> select="accumulator-after('summary-data')" group-by="normalize-space(.)">
>
> B B B B B B B B B B B B B B B B B B B  <xsl:sort select="local-name(.)"/>
>
> B B B B B B B B B B B B B B B B B B B  <xsl:sort
select="normalize-space(.)"/>
>
> B B B B B B B B  B B B B B B B B B B B <xsl:element
name="{local-name(.)}"><xsl:attribute
> name="quantity"
> select="sum(current-group()/@quantity)"/>{normalize-space(.)}</xsl:element>
>
> B B B B B B B B B B B B B B B  </xsl:for-each-group>
>
> B B B B B B B B B B B  </summary>
>
> B B B B B B B  </map-data>
>

You might want to use a further mode e.g.

 B  <xsl:template match="/">

 B B B  <xsl:apply-templates/>

 B B B  <xsl:variable name="collected-data"
select="accumulator-after('summary-data')"/>

 B B  ...

 B B  <!-- now push your nodes through a further mode and pass the
collected-data as a tunnel parameter e.g. -->

 B B  <xsl:apply-templates mode="analyis">

 B B B B  <xsl:with-param name="collected-data" select="$collected-data"
tunnel="yes"/>

 B B  </xsl:apply-templates>

 B  </xsl:template>


 B B  <xsl:mode name="analyis" on-no-match="shallow-skip"/>

 B B  <xsl:template mode="analysis" match="foo">

 B B B B B  <xsl:param name="collected-data" tunnel="yes"/>

 B B B B  ...

 B B  </xsl:template>

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.