[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
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>
|
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
|