Subject: Re: [xsl] Handling Duplicate Lines in XSL From: "M. David Peterson" <m.david@xxxxxxxxxx> Date: Wed, 29 Oct 2003 15:50:25 -0700 |
Heres a quick fix to your grouping problem... If the XML was in the following format... <foo> <bar>Cust1 443 West</bar> <bar>Cust1 443 West</bar> <bar>Cust1 443 West</bar> <bar>Cust1 443 East</bar> </foo> the following XSL will test to see if the current node is equal to any of the preceding elements and if it is it will not include it in the resulting node-set. It then prints the value of each node. So this... <xsl:for-each select="foo/bar[not(. = preceding-sibling::bar)]"> <xsl:value-of select="."/><br/> </xsl:for-each> Will produce this... Cust1 443 West Cust1 443 East Best of luck, M. ----- Original Message ----- From: "Jens Serna" <jserna@xxxxxxxxxxxxxxxxxxx> To: <XSL-List@xxxxxxxxxxxxxxxxxxxxxx> Sent: Wednesday, October 29, 2003 3:00 PM Subject: [xsl] Handling Duplicate Lines in XSL > I have an XML file with multiple rows which are the same: > > Cust1 443 West > Cust1 443 West > Cust1 443 West > > Is there any way to suppress the second or third row if it is the same as the previous one? > > At first I tried using variables, but then I found that you can't change variable values. > > <xsl:variable name="newcust" select="CUST"/> > <xsl:variable name="cust"/> > <xsl:if test="$cust!=$newcust"> > > Is there another way? > > Thanks, > > Jens > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Handling Duplicate Lines , J.Pietschmann | Thread | Re: [xsl] Handling Duplicate Lines , Murali Korrapati |
Re: [xsl] retaining "xml:" prefix o, David Carlisle | Date | [xsl] XML to HTML: How to make deci, constantin . vasiliu |
Month |