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 January 14th, 2008, 11:36 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default Grouping with XSLT 1.0

Hi All,
I am trying to arrange grouping using the Muenchian Method described at http://www.jenitennison.com/xslt/gro...muenchian.html

I am new to XSLT and can not seem to find out why my template seems to report all the fields in the XML, plus the grouped fields in the correct format.

How can I get the template to ignor all the records except those in the IncludedProducts node.
Any attempt I have made seems to stop everything working

I wish to do further grouping but would be really happy to get any grouping happening at this stage.

My XSLT is
[code]
<xsl:key name="products-by-account" match="IncludedProduct" use="AccountNumber" />

<xsl:template match="IncludedProducts">
    <xsl:for-each select="IncludedProduct[count(. | key('products-by-account', AccountNumber)[1]) = 1]">
        <xsl:sort select="AccountNumber" />
        <xsl:value-of select="AccountNumber" />,<br />
        <xsl:for-each select="key('products-by-account', AccountNumber)">
            <xsl:sort select="AccountNumber" />
            <xsl:value-of select="ProductName" /> (<xsl:value-of select="VariantName" />)<br />
        </xsl:for-each>
    </xsl:for-each>
</xsl:template>[code]

Teh XML is
Code:
<root>
  <System>
    <IsAdminSite>False</IsAdminSite>
    <IsAdminSiteInt>0</IsAdminSiteInt>
    <CustomerID>58639</CustomerID>
    <DefaultVATSetting>MoreFields than this</DefaultVATSetting>   
  </System>
  <QueryString />
  <Form />
  <Session />
  <Cookies>
    <ac7.aspxanonymous>ygmYIQhzyAEkAAAAM2YwOGQ1MWQtNjY1Mi00M2ZkLTlmNzQtN2Q5ODZiNTYyY2Jj5jiijKDA_jbSKEGPBGXZvND8DwM1</ac7.aspxanonymous>
    <username>[email protected]</username>
    <skinid>1</skinid>
  </Cookies>
  <ServerVariables>
    <HTTP_HOST>Morefields than this.</HTTP_HOST>
   </ServerVariables>
  <Runtime>
    <IPAddress>127.0.0.1</IPAddress>
    <IsAdminSite>False</IsAdminSite>
    <StoreUrl>http://localhost/aspdotnetstorefront70/</StoreUrl>
    <CurrencySetting>MoreFields than this</CurrencySetting>
  </Runtime>  
  <IncludedProducts>
    <IncludedProduct>
      <AccountNumber>Testing2</AccountNumber>
      <EquipmentNumber>EQ1</EquipmentNumber>
      <ProductName>Product 5 With Variants</ProductName>
      <VariantName>DVD Version</VariantName>
    </IncludedProduct>
    <IncludedProduct>
      <AccountNumber>Testing2</AccountNumber>
      <EquipmentNumber>EQ1</EquipmentNumber>
      <ProductName>Product 5 With Variants</ProductName>
      <VariantName>VHS Version</VariantName>
    </IncludedProduct>
    <IncludedProduct>
      <AccountNumber>Testing2</AccountNumber>
      <EquipmentNumber>EQ1</EquipmentNumber>
      <ProductName>Product 8 With Sizes That Change Price</ProductName>
      <VariantName>
      </VariantName>
    </IncludedProduct>
    <IncludedProduct>
      <AccountNumber>Testing2</AccountNumber>
      <EquipmentNumber>EQ4</EquipmentNumber>
      <ProductName>Product 5 With Variants</ProductName>
      <VariantName>DVD Version</VariantName>
    </IncludedProduct>
    <IncludedProduct>
      <AccountNumber>Testing2</AccountNumber>
      <EquipmentNumber>EQ4</EquipmentNumber>
      <ProductName>Product 5 With Variants</ProductName>
      <VariantName>VHS Version</VariantName>
    </IncludedProduct>
    <IncludedProduct>
      <AccountNumber>Testing2</AccountNumber>
      <EquipmentNumber>EQ4</EquipmentNumber>
      <ProductName>Product 8 With Sizes That Change Price</ProductName>
      <VariantName>
      </VariantName>
    </IncludedProduct>
    <IncludedProduct>
      <AccountNumber>Testing2</AccountNumber>
      <EquipmentNumber>EQ2</EquipmentNumber>
      <ProductName>Product 5 With Variants</ProductName>
      <VariantName>DVD Version</VariantName>
    </IncludedProduct>
    <IncludedProduct>
      <AccountNumber>Testing2</AccountNumber>
      <EquipmentNumber>EQ2</EquipmentNumber>
      <ProductName>Product 5 With Variants</ProductName>
      <VariantName>VHS Version</VariantName>
    </IncludedProduct>
    <IncludedProduct>
      <AccountNumber>Testing2</AccountNumber>
      <EquipmentNumber>EQ2</EquipmentNumber>
      <ProductName>Product 8 With Sizes That Change Price</ProductName>
      <VariantName>
      </VariantName>
    </IncludedProduct>
    <IncludedProduct>
      <AccountNumber>Testing2</AccountNumber>
      <EquipmentNumber>EQ3</EquipmentNumber>
      <ProductName>Product 5 With Variants</ProductName>
      <VariantName>DVD Version</VariantName>
    </IncludedProduct>
    <IncludedProduct>
      <AccountNumber>Testing2</AccountNumber>
      <EquipmentNumber>EQ3</EquipmentNumber>
      <ProductName>Product 5 With Variants</ProductName>
      <VariantName>VHS Version</VariantName>
    </IncludedProduct>
    <IncludedProduct>
      <AccountNumber>Testing2</AccountNumber>
      <EquipmentNumber>EQ3</EquipmentNumber>
      <ProductName>Product 8 With Sizes That Change Price</ProductName>
      <VariantName>
      </VariantName>
    </IncludedProduct>
  </IncludedProducts>
</root>


======================================
"They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad."
--Shakespeare
======================================
__________________
======================================
"They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad."
--Shakespeare
======================================
 
Old January 14th, 2008, 11:42 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Typically, just as I post the message, it all becomes clear.
Code:
<xsl:template match="/">
<xsl:apply-templates select="/root/IncludedProducts"/>
</xsl:template>
:D

======================================
"They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad."
--Shakespeare
======================================





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem of grouping in XSLT LeoMathew XSLT 2 September 11th, 2008 09:38 AM
XSLT Grouping vernc XSLT 2 October 2nd, 2007 03:59 AM
XSLT 1.0 Grouping kwilliams XSLT 0 January 11th, 2006 06:30 PM
XSLT Grouping Help Missy XSLT 0 December 14th, 2005 10:28 PM
Grouping Elements using XSLT mathuranuj XSLT 2 June 21st, 2005 02:56 AM





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