[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: "rick@xxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 15 Jun 2023 21:06:15 -0000
Re:  Collect data from a whole map hierarchy
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"

    exclude-result-prefixes="xs math rq"

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



    <xsl:output indent="yes"/>



    <!-- Variables to get required summary data from all documents. -->

    <xsl:variable name="referenced-topic-docs" select="rq:collect-docs(.)"/>

    <xsl:variable name="summary-data" select="$referenced-topic-docs !
(.//tool | .//spare | .//supply)"/>



    <xsl:template match="/">

        <!-- Test call to see the data: -->

        <xsl:call-template name="write-summary-data"/>

        <!-- Further processing here. -->

    </xsl:template>



    <xsl:template name="write-summary-data">

        <map-data>

            <summary>

                <xsl:for-each-group select="$summary-data"
group-by="normalize-space(.)">

                    <xsl:sort select="local-name(.)"/>

                    <xsl:sort select="normalize-space(.)"/>

                    <xsl:element name="{local-name(.)}"><xsl:attribute
name="quantity"
select="sum(current-group()/@quantity)"/>{normalize-space(.)}</xsl:element>

                </xsl:for-each-group>

            </summary>

        </map-data>

    </xsl:template>



     <xsl:function name="rq:collect-docs" as="document-node()*">

        <xsl:param name="input-doc" as="document-node()"/>

        <xsl:variable name="topic-uri-collection"

            select="$input-doc//*/@href[matches(.,'(dita(map)?|xml)$','i')]/r
esolve-uri(. ,base-uri(.))[doc-available(.)]"/>

        <xsl:variable name="topic-docs" select="$topic-uri-collection !
doc(.)"/>

        <xsl:sequence select="$topic-docs, $topic-docs !
rq:collect-docs(.)"/>

    </xsl:function>



</xsl:stylesheet>

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.