|
next
|
 Subject: Multiple key grouping Author: Ivan Pedruzzi Date: 30 May 2007 05:34 PM
|
Hi Jan,
You should use xsl:key; I am not sure I have understood the desired output, it seems like you would like to generate unique pairs of category/group
See if the following helps
Ivan Pedruzzi
Stylus Studio Team
http://www.stylusstudio.com/xml_download.html
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:key name="CategoryGroup" match="products/product" use="concat(Category,Group)"/>
<xsl:template match="/">
<xsl:for-each select="products/product[generate-id(.) = generate-id(key('CategoryGroup',concat(Category,Group))[1])]">
<xsl:value-of select="concat('[', Category,',',Group,']')"/>
<xsl:if test="position() != last()">,</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
|
next
|
 Subject: Multiple key grouping Author: Jan Verhoek Date: 30 May 2007 05:44 PM
|
Thanks! That's the only method I haven't tried yet.... but reading Michael Kay's book I thought there was not much different in the approach. I will let you know the result as soon as I get back on this issue.
Jan
>Hi Jan,
>
>You should use xsl:key; I am
>not sure I have understood the
>desired output, it seems like
>you would like to generate
>unique pairs of category/group
>
>See if the following helps
>
>Ivan Pedruzzi
>Stylus Studio Team
>http://www.stylusstudio.com/xm
>l_download.html
>
><?xml version="1.0"?>
><xsl:stylesheet
>version="1.0"
>xmlns:xsl="http://www.w3.org/1
>999/XSL/Transform">
><xsl:output
>method="text"/>
><xsl:key
>name="CategoryGroup"
>match="products/product"
>use="concat(Category,Group)"/&
>gt;
><xsl:template match="/">
><xsl:for-each
>select="products/product[gener
>ate-id(.) =
>generate-id(key('CategoryGroup
>',concat(Category,Group))[1])]
>">
><xsl:value-of
>select="concat('[',
>Category,',',Group,']')"/>
><xsl:if test="position() !=
>last()">,</xsl:if>
> </xsl:for-each>
> </xsl:template>
></xsl:stylesheet>
>
>
|
top
|
 Subject: Multiple key grouping Author: Jan Verhoek Date: 30 May 2007 06:25 PM
|
Ivan Thanks!!! This really works! I couldn't wait actually to try it. Thanks again.
Jan
>Thanks! That's the only method
>I haven't tried yet.... but
>reading Michael Kay's book I
>thought there was not much
>different in the approach. I
>will let you know the result
>as soon as I get back on this
>issue.
>Jan
>
>>Hi Jan,
>>
>>You should use xsl:key; I
>am
>>not sure I have understood
>the
>>desired output, it seems
>like
>>you would like to generate
>>unique pairs of
>category/group
>>
>>See if the following helps
>>
>>Ivan Pedruzzi
>>Stylus Studio Team
>>http://www.stylusstudio.co
>m/xm
>>l_download.html
>>
>><?xml
>version="1.0"?>
>><xsl:stylesheet
>>version="1.0"
>>xmlns:xsl="http://www.w3.o
>rg/1
>>999/XSL/Transform">
>><xsl:output
>>method="text"/>
>><xsl:key
>>name="CategoryGroup"
>>match="products/product"
>>use="concat(Category,Group
>)"/&
>>gt;
>><xsl:template
>match="/">
>><xsl:for-each
>>select="products/product[g
>ener
>>ate-id(.) =
>>generate-id(key('CategoryG
>roup
>>',concat(Category,Group))[
>1])]
>>">
>><xsl:value-of
>>select="concat('[',
>>Category,',',Group,']')"/&
>gt;
>><xsl:if
>test="position() !=
>>last()">,</xsl:if>
>;
>> </xsl:for-each>
>> </xsl:template>
>></xsl:stylesheet>
>>
>>
|
|
|
|