Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old November 13th, 2006, 06:37 AM
Authorized User
Join Date: Nov 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default Grouping by attribute

I am trying to create a key and group by attribute matching. The XML file is as follows;
    <sort order="0" col="col1" visible="1">asc</sort>
    <column name="col1">Column1</column>
    <column name="col2">Column2</column>
    <column name="col3">Column3</column>
    <column name="col4">Column4</column>
        <value name="Column1">dat1</value>
        <value name="Column2">dat2</value>
        <value name="Column3">dat3</value>
        <value name="Column4">dat4</value>
        <value name="Column1">dat1</value>
        <value name="Column2">dat2</value>
        <value name="Column3">dat3</value>
        <value name="Column4">dat4</value>


I am trying to use the key as :==

<xsl:key name="mkt" match="view" use="concat(value[name='Column1'], '~', value[name='Column2'])"/>

And, then I tried to display for each as below :-

xsl:for-each select="line[count(. | key('mkt', concat(value[name='Column1'], '~', value[name='Column2]))[1]) = 1]">
<td align="middle"><xsl:value-of select='value name="Column1"]'/></td>
<td align="middle"><xsl:value-of select='value name="Column2"]'/></td>
<td align="middle"><xsl:value-of select='value name="Column3"]'/></td>

I know the above is not correct but not sure if this is syntactically correct. Please advise.


Old November 13th, 2006, 06:47 AM
mhkay's Avatar
Wrox Author
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts

This isn't going to work because in the key definition, you are matching view elements, and the use expression selects value as a child of view, but view does not have a child called value.

I can't correct it for you as I don't actually know what you are trying to achieve.

Michael Kay
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference

Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace an attribute with another attribute georgemeng XSLT 8 June 10th, 2008 11:04 AM
XSLT - Grouping by Attribute but same elements vinaura XSLT 2 July 18th, 2007 10:34 PM
Protect cells and allow grouping/un-grouping sfreuden Excel VBA 4 December 14th, 2006 08:01 AM
grouping yes/no fields sburgess Access 6 August 24th, 2006 11:15 AM
Access to attribute values from class of attribute jacob C# 1 October 28th, 2005 01:11 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.