Subject: Re: [xsl] 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 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Making a lookup structure, rick@xxxxxxxxxxxxxx | Thread | Re: [xsl] Making a lookup structure, Martin Honnen martin |
Re: [xsl] Making a lookup structure, rick@xxxxxxxxxxxxxx | Date | Re: [xsl] The entity was referenced, Wendell Piez wapiez@ |
Month |