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

Re: Collect data from a whole map hierarchy, then use

Subject: Re: Collect data from a whole map hierarchy, then use it in a topic
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 16 Jun 2023 09:57:57 -0000
Re:  Collect data from a whole map hierarchy
Am 6/15/2023 um 11:06 PM schrieb rick@xxxxxxxxxxxxxx:
>
> Thank you Martin. Here is my working stylesheet. I just have to add
> the second stage to insert the summary data into one of the topics. I
> appreciate your generous help.
>
> Rick
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <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:rq="http://www.frameexpert.com/functions"
>
> B B B  exclude-result-prefixes="xs math rq"
>
> B B B  version="3.0" expand-text="yes">
>
> B B B B <xsl:output indent="yes"/>
>
> B B B B <!-- Variables to get required summary data from all documents. -->
>
> B B B  <xsl:variable name="referenced-topic-docs"
> select="rq:collect-docs(.)"/>
>
> B B B  <xsl:variable name="summary-data" select="$referenced-topic-docs !
> (.//tool | .//spare | .//supply)"/>
>
> B B B B <xsl:template match="/">
>
> B B B B B B B  <!-- Test call to see the data: -->
>
> B B B B B B B  <xsl:call-template name="write-summary-data"/>
>
> B B B B B B B  <!-- Further processing here. -->
>
> B B B  </xsl:template>
>
> B B B B <xsl:template name="write-summary-data">
>
> 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="$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>
>
> B B B  </xsl:template>
>
Instead of delegating that to a named template, you could of course have
another global variable e.g.

<xsl:variable name="summary-map">

 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="$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>

</xsl:variable>

and then, where you need that "summay-map", you don't need call-template
but just use <xsl:sequence select="$summary-map"/> or <xsl:copy-of
select="$summary-map"/>.

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.