• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

removing duplicates

 
Ranch Hand
Posts: 309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have an xml as follows:
<root>
<index name="XYZ"/>
<index name="ABC"/>
<index name="XYZ"/>
</root>
I have to print XYZ and ABC i.e. i should ingore duplicates for 'name' attribute. Could anyone tell me how to do this using xsl??
Regards,
shankar
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use the following stylesheet to get rid of duplicate name entries.
It should work with any standards compliant XSLT processor, but I verified it only on Apache's Xalan.
Hope this helps . . .
Shashank

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="index[not(./@name = preceding::index/@name)]">
<xsl:value-of select="@name"/>
</xsl:template>
</xsl:stylesheet>
[ February 28, 2002: Message edited by: Shashank M Tanksali ]
 
shankar vembu
Ranch Hand
Posts: 309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thanx for the reply. It worked with xalan for me too. But I want to do a client side transformation. I am using IE 5.5 and it does not work over there.Any help ??
Regards,
shankar.
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried it using IE5.5, it worked.
To use IE5.5 for styling xml documents you must install Microsoft XSL plug-in (MSXML3.0). The following are the instructions to set up MSXML3.0
*********************************************
The following instructions are from Roger's xsl tutorial at xfront.com:
Download xmlinst.exe from http://msdn.microsoft.com/msdn-files/027/001/469/xmlinst.exe
Double click on the downloaded file. This will result in extracting some files.
Open a DOS window. Change directory to where you placed the extracted files. Set the path
environment variable to include the directory where regsvr32.exe is located (on Windows 98 it is
on c:\windows\system, on WIN2000 it is C:\WINNT\system32) Then type the following commands:
xmlinst
regsvr32 msxml3.dll
***********************************************
IE is ready to use for transforming XML documents

Note: There's a new version of XML parser MSXML4.0. I had problems setting it up, so I am using MSXML3.0. It'd be great if someone could tell me how to install and use MSXML4.0 for transforming XML docs.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic