Subject: [xsl] Grouping problem From: "rick@xxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Tue, 29 Mar 2022 21:01:31 -0000 |
Hi All, I am missing something obvious with grouping but I am not sure what. Here is my input: <?xml version='1.0' encoding='UTF-8'?> <doc> <pgf href="control-panel.dita" level="1" topictype="concept"/> <pgf href="r_zt230-printer-control-panel.dita" level="2" topictype="reference"/> <pgf href="r_zt220-printer-control-panel.dita" level="2" topictype="reference"/> <pgf href="r_zt210-printer-control-panel.dita" level="2" topictype="reference"/> <pgf href="c_navigating-through-screens-in-the-zt230-printer-display.dita" level="2" topictype="concept"/> <pgf href="t_idle-display.dita" level="3" topictype="task"/> <pgf href="t_home-menu.dita" level="3" topictype="task"/> <pgf href="t_user-menus.dita" level="3" topictype="task"/> <pgf href="c_idle-display-home-menu-and-user-menus.dita" level="2" topictype="concept"/> </doc> I want to produce this output: <map> <topicref href="control-panel.dita" type="concept"> <topicref href="r-zt230-printer-control-panel.dita" type="reference"/> <topicref href="r-zt220-printer-control-panel.dita" type="reference "/> <topicref href="r-zt210-printer-control-panel.dita" type="reference"/> <topicref href="c-navigating-through-screens-in-the-zt230-printer-display.dita" type="concept"> <topicref href="t-idle-display" type="task"/> <topicref href="t-home-menu.dita" type="task"/> <topicref href="t-user-menus.dita" type="task"/> </topicref> <topicref href="c-idle-display-home-menu-and-user-menus.dita" type="concept"/> </topicref> </map> This is my stylesheet: <?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" exclude-result-prefixes="xs math" version="3.0" expand-text="yes"> <xsl:output indent="yes"/> <xsl:template match="/doc"> <map> <xsl:for-each-group select="pgf" group-starting-with="@level[.='1']"> <xsl:apply-templates select="." mode="group"/> </xsl:for-each-group> </map> </xsl:template> <xsl:template match="pgf[@level='1']" mode="group"> <topicref href="{./@href}"> <xsl:for-each-group select="current-group() except ." group-starting-with="@level[.='2']"> <xsl:apply-templates select="." mode="group"/> </xsl:for-each-group> </topicref> </xsl:template> <xsl:template match="pgf[@level='2']" mode="group"> <topicref href="{./@href}"> <xsl:for-each-group select="current-group() except ." group-starting-with="@level[.='3']"> <xsl:apply-templates select="." mode="group"/> </xsl:for-each-group> </topicref> </xsl:template> <xsl:template match="pgf" mode="group"> <topicref href="{@href}"/> </xsl:template> <xsl:mode on-no-match="shallow-skip"/> </xsl:stylesheet> Thanks in advance for any pointers. Rick
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] How to force the XSLT pro, Roger L Costello cos | Thread | Re: [xsl] Grouping problem, Martin Honnen martin |
Re: [xsl] How to force the XSLT pro, Michael Kay mike@xxx | Date | [xsl] Unable to get Firefox to appl, Michele R Combs mrro |
Month |