Altova Mailing List Archives


Re: n level grouping

From: "B. Rubble" <rahkim@-------.--->
To: NULL
Date: 4/24/2005 7:21:00 AM
Thanks for the reply (I was hoping you would reply.)  I like this
solution much better than some of the Meunchian grouping Ive been doing
with keys and 'generate-id().'  Unfortunately, I now have to follow up
with an extremely stupid question.  Whenever I run the solution you
gave in xml spy, I get the following output:


<xsl:stylesheet version=3D"1.0"
xmlns:xsl=3D"http://www.w3.org/1999/XSL/Tra=ADnsform"
xmlns:params=3D"my:params" exclude-result-prefixes=3D"param=ADs">
<xsl:output method=3D"xml" indent=3D"yes" encoding=3D"utf-8"
omit-xml-declaration=3D"yes" />
<params:params>
<pname>Category</pname>
<pname>Concept</pname>
<pname>PDLevel</pname>
</params:params>
<xsl:variable name=3D"vList" select=3D"document('')/*/params:=AD*/*" />
<xsl:template match=3D"/DESCRIPTORS">
<categories>
<xsl:call-template name=3D"RecursiveGrouping">
<xsl:with-param name=3D"list" select=3D"V_PD" />
<xsl:with-param name=3D"grList" select=3D"$vList" />
</xsl:call-template>
</categories>
</xsl:template>
<xsl:template name=3D"RecursiveGrouping">
<xsl:param name=3D"list" />
<xsl:param name=3D"grList" />
<xsl:choose>
<xsl:when test=3D"$grList">
<xsl:variable name=3D"catName" select=3D"string($grList[1])" />
<xsl:variable name=3D"group-identifier" select=3D"$list[1]/*[name() =3D
$catName]" />
<xsl:variable name=3D"group"
select=3D"$list[*[name()=3D$catNam=ADe]=3D$group-identifier]" />
<xsl:element name=3D"{$catName}">
<xsl:attribute name=3D"value">
<xsl:value-of select=3D"$group-identifier" />
</xsl:attribute>
<xsl:call-template name=3D"RecursiveGrouping">
<xsl:with-param name=3D"list" select=3D"$group" />
<xsl:with-param name=3D"grList" select=3D"$grList[position() &gt; 1]" />
</xsl:call-template>
</xsl:element>
<xsl:if test=3D"count($list)&gt;count($grou=ADp)">
<xsl:call-template name=3D"RecursiveGrouping">
<xsl:with-param name=3D"list"
select=3D"$list[not(*[name()=3D$catName]=3D=AD$group-identifier)]" />
<xsl:with-param name=3D"grList" select=3D"$grList" />
</xsl:call-template>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select=3D"$list/Descriptor" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>


Im obviously missing something simple here but its beyond me.  As you
can see, its essentially the xsl you listed with some &gt; in place of
>=2E  Im assuming Im missing something in the declaration maybe.  What
should I do?

Thanks again for your help!



Dimitre Novatchev wrote:
> Here's the XSLT 1.0 solution for dynamic grouping.
>
> Dynamic grouping can have unknown number of grouping levels. The list
of
> names of each level to group is provided as a parameter,
>
> This code is a slight modification of the code I published last
December at:
>
>
http://www.xslt.com/html/xsl-list/2004-12/msg01030.html
>
>
> and is based on an initial work of Sergiu Ignat.
>
> When this transformation:
>
> <xsl:stylesheet version=3D"1.0"
>  xmlns:xsl=3D"http://www.w3.org/1999/XSL/Transform"
>  xmlns:params=3D"my:params"
>  exclude-result-prefixes=3D"params"

.=2E. message abbreviated ...

>=20
>=20
> Hope this helped.
>=20
>=20
> Cheers,
> Dimitre Novatchev

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.