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

RE: Grouping and Unique Lists

Subject: RE: Grouping and Unique Lists
From: Bill Martschenko <billmartschenko@xxxxxxxxx>
Date: Tue, 28 Sep 1999 15:21:22 -0700 (PDT)
bill martschenko
Ah, I can't keep up with you, Michael. :-)  I was
going to try at home tonight...

Just a tidbit to enhance:

The line
       <xsl:for-each select="/ITEMLIST/ITEM">
should read
       <xsl:for-each select="/ITEMLIST/ITEM"
order-by="CATEGORY">

This way, the input <ITEM>'s can be any order.

Note to IE5 users:  IE5 does not support xsl:sort.  I
recall that "order-by" has been depracated.  Know that
IE5's XSLT is based on the Dec 98 working draft.  The
latest draft is Aug 99.

I was also surprised to learn about case sensitivity. 
Micheal's script did not work at all for me until I
changed all the element names to lower case to match
my XML.

I didn't think XML tags were case sensitive.

What's the story here?

Bill



--- "Michael J. Dyer" <michael.dyer@xxxxxxxxxx> wrote:
> Bill,
> 
> You're absolutely right - IE doesn't support the
> "preceding-sibling"
> construct and the XSL script won't work.  However, I
> was able to do a
> workaround using JavaScript.
> 
> There are three JavaScript functions -
> SetCurrentGroup, GetCurrentGroup and
> IsNewGroup.  I'm not really using GetCurrentGroup ,
> but it's there just to
> be complete.  You'll node that when I call the
> IsNewGroup and
> SetCurrentGroup, I pass 'this' along with a text
> string that represents the
> node I want (relative to this).
> 
> Hope this helps...
> 
> Regards,
> 
> Michael
> 
> 
> <?xml version='1.0'?>
> <xsl:stylesheet
> xmlns:xsl="http://www.w3.org/TR/WD-xsl">
> 
>   <xsl:template match="/">
> 
>       <xsl:for-each select="/ITEMLIST/ITEM">
> 
>         <xsl:if expr="IsNewGroup(this, 'CATEGORY')">
> 	    <xsl:eval>
>             SetCurrentGroup(this, 'CATEGORY')
>           </xsl:eval>
>           <xsl:value-of select="CATEGORY"/>
> 	  </xsl:if>
> 
>         <xsl:value-of select="NUMBER"/>
> 	  <xsl:value-of select="DESCRIPTION"/>
> 
>       </xsl:for-each>
> 
>   </xsl:template>
> 
>   <xsl:script>
> 
>     cCurrentGroup = "_empty_" ;
> 
>     function SetCurrentGroup(cThis, cChar)
>       {
> 	cValue = cThis.selectSingleNode(cChar).text ;
> 	cCurrentGroup = cValue ;
> 	return "" ;
> 	}
> 
>     function IsNewGroup(cThis, cChar)
>       {
> 	cValue = cThis.selectSingleNode(cChar).text ;
> 	if (cValue == cCurrentGroup)
>         cReturn = false ;
> 	else
> 	  cReturn = true ;
> 	return cReturn ;
> 	}
> 
>     function GetCurrentGroup()
> 	{
> 	return cCurrentGroup ;
> 	}
> 
>   </xsl:script>
> 
> </xsl:stylesheet>
> 
> 
> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxx]On Behalf Of
> Bill Martschenko
> Sent: Tuesday, September 28, 1999 3:20 PM
> To: xsl-list@xxxxxxxxxxxxxxxx
> Subject: RE: Grouping and Unique Lists
> 
> 
> Excellent.
> 
> I'd like to add that IE5 can't handle it.  IE5
> doesn't
> support all of the XSLT constructs.
> "preceding-sibling" is one of them.
> 
> I have an IE5 solution in the works that uses
> xsl:script to get past some of the limitations.
> 
> The basic ideas are the same:  start with a sorted
> list and then as you process them in order check
> your
> predecessor to see if you are first one in a group.
> 
> More later--if I succeed :-)--for any IE5
> audience...
> 
> Bill
> 
> 
> 
> --- "Sargeant, Richard (GEIS)"
> <Richard.Sargeant@xxxxxxxxxxx> wrote:
> > Hi,
> >
> >    I have not tried this with IE5 but this works
> for
> > me and produces exactly
> > the output you specified... FYI I created and
> > previewed this using the
> > Stylus beta editor and then tested it with
> Oracle's
> > XMLparser.
> >
> >
> >
> > <xsl:stylesheet
> > xmlns:xsl="http://www.w3.org/XSL/Transform/1.0">
> >
> > <xsl:template
> > match="*|/"><xsl:apply-templates/></xsl:template>
> >
> > <xsl:template match="text()|@*"><xsl:value-of
> > select="."/></xsl:template>
> >
> > <xsl:template match="ITEMLIST">
> >         <xsl:apply-templates select="ITEM"/>
> > </xsl:template>
> >
> > <xsl:template match="ITEM">
> >         <xsl:if test =
> >
>
"not(CATEGORY=preceding-sibling::ITEM[position()=1]/CATEGORY)">
> >                 <xsl:value-of
> > select="CATEGORY"/><br/>
> >         </xsl:if>
> >         <xsl:value-of select="NUMBER"/>
> >         <xsl:text> </xsl:text>
> >         <xsl:value-of select="DESCRIPTION"/><br/>
> > </xsl:template>
> >
> > </xsl:stylesheet>
> >
> >
> > regards
> >    Richard Sargeant
> >
> >
> > -----Original Message-----
> > From: Michael J. Dyer
> > [mailto:michael.dyer@xxxxxxxxxx]
> > Sent: Monday, September 27, 1999 19:04
> > To: xsl-list@xxxxxxxxxxxxxxxx
> > Subject: Grouping and Unique Lists
> >
> >
> > I've searched the archives and found a few posts
> in
> > this area, but nothing
> > that seems to directly address the problem.  I'm
> > working with the Microsoft
> > IE5 XMLDom.  Given the following XML:
> > <?XML version='1.0'?>
> > <ITEMLIST>
> > <ITEM>
> > <CATEGORY>Category A</CATEGORY>
> > <NUMBER>00001</NUMBER>
> > <DESCRIPTION>Item 1</DESCRIPTION>
> > </ITEM>
> > <ITEM>
> > <CATEGORY>Category B</CATEGORY>
> > <NUMBER>00002</NUMBER>
> > <DESCRIPTION>Item 2</DESCRIPTION>
> > </ITEM>
> > <ITEM>
> > <CATEGORY>Category B</CATEGORY>
> > <NUMBER>00003</NUMBER>
> > <DESCRIPTION>Item 3</DESCRIPTION>
> > </ITEM>
> > <ITEM>
> > <CATEGORY>Category C</CATEGORY>
> > <NUMBER>00004</NUMBER>
> > <DESCRIPTION>Item 4</DESCRIPTION>
> > </ITEM>
> > </ITEMLIST>
> > 1.  Using XSL, convert to the following output
> > (without using the actual
> > category name as part of the XSL)
> > Category A
> > 00001 Item 1
> > Category B
> > 00002 Item 2
> > 00003 Item 3
> 
=== message truncated ===

__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.