[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Grouping problem - Duplicates

Subject: Re: Grouping problem - Duplicates
From: Mukul Gandhi <mukul_gandhi@xxxxxxxxx>
Date: Sat, 1 May 2004 02:14:22 -0700 (PDT)
xsl duplicates
Hi Sarah,
  Surprisingly, I am getting the complete output with
the XML you had posted in your first mail regarding
this question. Please post the XML test case, with
which my stylesheet is not working and I will try to
correct the XSL.

I tested the XSL with Xalan, so I used Xalan's nodeset
function. Nearly every XSLT processor supports the
nodeset extension function, so it should'nt be a
problem using it.

As for now, to make the XSL product independent seems
a bit tough to me. I could'nt avoid using the nodeset
function, as I had to process the result tree
fragment(rtf's) variables.

Regards,
Mukul

--- Sarah <sarah10@xxxxxxxxxxx> wrote:
> Hi Mukul,
> 
> Thanks so much for this solution. I am still trying
> to understand its' 
> details. As I said, I am new, and your xslt is
> complicated for me.
> But, I have two concerns, that maybe you can help me
> with. The first is 
> that when I run your xslt, I only get content (that
> is: sales people per 
> area) for the first sorted area (Center). the other
> two are empty, though I 
> would expect them to have their sales people.
> The second is, that this solution is
> product-dependent. By using the 
> xalan:nodeset function, it limits the solution to a
> certain product.
> Is there no other way that would be generic? (This
> is for me a requirement).
> 
> Thanks again,
> Sarah
> 
> 
> At 19:48 30/4/2004, you wrote:
> >Hi Sarah,
> >   I rewrote the XSL. I have not used HTML tags in
> my
> >stylesheet. Hope you can adapt it for yourself.
> >
> ><?xml version="1.0" encoding="UTF-8"?>
> ><xsl:stylesheet version="1.0"
> >xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> >xmlns:xalan="http://xml.apache.org/xalan"
> >exclude-result-prefixes="xalan">
> ><xsl:output method="text" version="1.0"
> >encoding="UTF-8" indent="yes"/>
> >
> ><xsl:key name="by-area1"
> >match="/Company/Suppliers/Area/*" use="name()"/>
> ><xsl:key name="by-area2" match="area" use="@name"/>
> ><xsl:key name="by-name" match="Name"
> >use="concat(FirstName,':',LastName)"/>
> >
> ><xsl:template match="/Company/Suppliers">
> >   <xsl:variable name="rtf1">
> >     <xsl:for-each select="Area/*">
> >       <xsl:if test="generate-id(.) =
> >generate-id(key('by-area1', name())[1])">
> >         <xsl:for-each select="key('by-area1',
> name())">
> >           <area name="{name()}">
> >             <xsl:value-of select="."/>
> >           </area>
> >         </xsl:for-each>
> >       </xsl:if>
> >     </xsl:for-each>
> >   </xsl:variable>
> >
> >   <xsl:variable name="rtf3">
> >     <xsl:for-each
> select="SalesPeople/SalesPerson">
> >       <xsl:variable name="rtf2">
> >         <Name>
> >           <LastName>
> >              <xsl:value-of
> select="Name/LastName"/>
> >           </LastName>
> >           <FirstName>
> >              <xsl:value-of
> select="Name/FirstName"/>
> ></FirstName>
> >         </Name>
> >       </xsl:variable>
> >
> >       <xsl:for-each select="Supplier">
> >         <xsl:variable name="supplier" select="."/>
> >           <xsl:for-each
> select="xalan:nodeset($rtf1)/area">
> >             <xsl:if test="text() = $supplier">
> >               <area name="{@name}">
> >                 <Name>
> >                   <LastName>
> >                     <xsl:value-of
> >select="xalan:nodeset($rtf2)/Name/LastName"/>
> >                   </LastName>
> >                   <FirstName>
> >                     <xsl:value-of
> >select="xalan:nodeset($rtf2)/Name/FirstName"/>
> >                   </FirstName>
> >                 </Name>
> >               </area>
> >             </xsl:if>
> >          </xsl:for-each>
> >        </xsl:for-each>
> >      </xsl:for-each>
> >    </xsl:variable>
> >
> >    <xsl:variable name="rtf4">
> >      <xsl:for-each
> select="xalan:nodeset($rtf3)/area">
> >         <xsl:if test="generate-id(.) =
> >generate-id(key('by-area2', @name)[1])">
> >            <area name="{@name}">
> >               <xsl:for-each
> select="key('by-area2', @name)">
> >                                       <Name>
> >                 <LastName>
> >                    <xsl:value-of
> select="Name/LastName"/>
> >                 </LastName>
> >                 <FirstName>
> >                    <xsl:value-of
> select="Name/FirstName"/>
> >                   </FirstName>
> >               </Name>
> >              </xsl:for-each>
> >         </area>
> >       </xsl:if>
> >     </xsl:for-each>
> >   </xsl:variable>
> >
> >   <xsl:for-each
> select="xalan:nodeset($rtf4)/area">
> >      <xsl:sort select="@name"/>
> >         <xsl:value-of select="@name"/><xsl:text>
> >         </xsl:text>
> >         <xsl:variable name="rtf5">
> >            <xsl:copy-of select="."/>
> >         </xsl:variable>
> >         <xsl:for-each
> >select="xalan:nodeset($rtf5)/area/Name">
> >            <xsl:if test="generate-id(.) =
> >generate-id(key('by-name',
> >concat(FirstName,':',LastName))[1])">
> >               <xsl:value-of
> select="FirstName"/><xsl:text>
> ></xsl:text>
> >                 <xsl:value-of
> select="LastName"/><xsl:text>
> >                 </xsl:text>
> >             </xsl:if>
> >         </xsl:for-each>
> >      </xsl:for-each>
> ></xsl:template>
> >
> ></xsl:stylesheet>
> >
> >Regards,
> >Mukul
> >
> >--- Sarah <sarah10@xxxxxxxxxxx> wrote:
> >
> > > Here is a copy of my XML file called
> Company.xml:
> > >
> > > <Company>
> > >          <Suppliers>
> > >                  <Area>
> > >                          <North>Supp 1
> Nor</North>
> > >                          <South>Supp 1
> Sou</South>
> > >                          <Center>Supp 1
> > > Cntr</Center>
> > >                          <North>Supp 2
> Nor</North>
> > >                          <North>Supp 3
> Nor</North>
> > >                          <South>Supp 2
> Sou</South>
> > >                          <South>Supp 3
> Sou</South>
> > >                          <Center>Supp 2
> > > Cntr</Center>
> > >                          <Center>Supp 3
> > > Cntr</Center>
> > >                          <North>Smith Suppliers
> > > LTD.</North>
> > >                          <South>Smith Suppliers
> > > LTD.</South>
> > >                          <Center>Sundance
> suppliers
> > > Cntr</Center>
> > >                  </Area>
> > >                  <SalesPeople>
> > >                          <SalesPerson>
> > >                                  <Name>
> > >
> > > <LastName>lName Supp 1</LastName>
> > >
> > > <FirstName>John</FirstName>
> > >                                  </Name>
> > >
> > > <Title>Manager</Title>
> > >                                  <Supplier>Supp
> 1
> > > Nor</Supplier>
> > >                                  <Supplier>Supp
> 1
> > > Sou</Supplier>
> > >                                  <Supplier>Supp
> 1
> > > Cntr</Supplier>
> > >                                  <Supplier>Supp
> 2
> > > Cntr</Supplier>
> > >                                  <Supplier>Supp
> 3
> > > Cntr</Supplier>
> > >                                  <Supplier>Smith
> > > Suppliers LTD.</Supplier>
> > >                                  <Supplier>Smith
> > > Suppliers LTD.</Supplier>
> > >                                 
> <Supplier>Sundance
> > > suppliers Cntr</Supplier>
> > >                          </SalesPerson>
> > >                          <SalesPerson>
> > >                                  <Name>
> > >
> > > <LastName>lName Supp 2</LastName>
> > >
> > > <FirstName>Kathy</FirstName>
> > >                                  </Name>
> > >                                 
> <Title>CEO</Title>
> > >                                  <Supplier>Supp
> 2
> > > Nor</Supplier>
> > >                                  <Supplier>Supp
> 2
> > > Sou</Supplier>
> > >                                  <Supplier>Supp
> 2
> > > Cntr</Supplier>
> > >                                  <Supplier>Supp
> 1
> > > Cntr</Supplier>
> > >                                  <Supplier>Supp
> 2
> > > Cntr</Supplier>
> > >                                  <Supplier>Supp
> 3
> > > Cntr</Supplier>
> > >                                  <Supplier>Smith
> > > Suppliers LTD.</Supplier>
> > >                          </SalesPerson>
> > >                          <SalesPerson>
> > >                                  <Name>
> > >
> > > <LastName>lName Supp 3</LastName>
> > >
> > > <FirstName>Dan</FirstName>
> > >                                  </Name>
> > >                                 
> <Title>Dr.</Title>
> > >                                  <Supplier>Supp
> 3
> > > Nor</Supplier>
> > >                                  <Supplier>Supp
> 3
> > > Sou</Supplier>
> > >                                  <Supplier>Supp
> 3
> > > Cntr</Supplier>
> > >                                  <Supplier>Supp
> 1
> > > Cntr</Supplier>
> > >                                  <Supplier>Supp
> 2
> > > Cntr</Supplier>
> > >                                  <Supplier>Supp
> 3
> > > Cntr</Supplier>
> > >                                  <Supplier>Smith
> > > Suppliers LTD.</Supplier>
> > >                                  <Supplier>Smith
> > > Suppliers LTD.</Supplier>
> > >                                 
> <Supplier>Sundance
> > > suppliers Cntr</Supplier>
> > >                          </SalesPerson>
> > >                          <SalesPerson>
> > >                                  <Name>
> > >
> > > <LastName>lName Apprentice</LastName>
> > >
> > > <FirstName>George</FirstName>
> > >                                  </Name>
> > >
> > > <Title>Apprentice</Title>
> > >                                  <Supplier>Supp
> 3
> > > Nor</Supplier>
> > >                          </SalesPerson>
> > >                          <SalesPerson>
> > >                                  <Name>
> > >
> > > <LastName>lName Samuel</LastName>
> > >
> > > <FirstName>Dave</FirstName>
> > >                                  </Name>
> > >
> > > <Title>Developer</Title>
> > >                                  <Supplier>Supp
> 3
> > > Nor</Supplier>
> > >                                  <Supplier>Supp
> 3
> > > Sou</Supplier>
> > >                                  <Supplier>Supp
> 3
> > > Cntr</Supplier>
> > >                                  <Supplier>Supp
> 1
> > > Cntr</Supplier>
> > >                                  <Supplier>Supp
> 2
> > > Cntr</Supplier>
> > >                          </SalesPerson>
> > >                  </SalesPeople>
> > >          </Suppliers>
> > > </Company>
> > >
> > >
> > > I would like to see the following output:
> > >
> > >
> > >
> > >
> > > Sales People by Areas
> > >
> > >
> > > Center
> > >
> > > Dave lName Samuel
> > > John lName Supp 1
> > > Kathy lName Supp 2
> > > Dan lName Supp 3
> > >
> > > North
> > >
> > > John lName Supp 1
> > > Kathy lName Supp 2
> > > George lName Apprentice
> > > Dave lName Samuel
> > > Dan lName Supp 3
> > >
> > > South
> > >
> > > John lName Supp 1
> > > Kathy lName Supp 2
> > > Dave lName Samuel
> > > Dan lName Supp 3
> 



	
		
__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs  
http://hotjobs.sweepstakes.yahoo.com/careermakeover 

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.