• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do i obtain unique value thru this code

 
clyde mel
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The xml file is given below.How do I retrieve the name value(unique).
so the output should be
Minnie
Donald duck
Pluto

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="mock2test.xsl"?>
<HumanResources>
<Employee department="Personal">
<Name>Minnie</Name>
<Age>20</Age>
<Sex>Female</Sex>
<Salary>3500USD</Salary>
</Employee>
<Employee department="Finance">
<Name>Donald Duck</Name>
<Age>45</Age>
<Sex>Male</Sex>
<Salary>6000USD</Salary>
</Employee>
<Employee department="IT">
<Name>Pluto</Name>
<Age>22</Age>
<Sex>Male</Sex>
<Salary>4500USD</Salary>
</Employee>
<Employee department="IT">
<Name>Donald Duck</Name>
<Age>25</Age>
<Sex>Male</Sex>
<Salary>4000USD</Salary>
</Employee>
</HumanResources>
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With DOM, SAX, XSL ?
 
clyde mel
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
with xsl or sax
 
Vasudha Deepak
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This works well with the XML file and retreives unique values.
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl utput method="xml" />
<xsl:template match="/">
<EmployeeName>
<xsl:for-each select="/HumanResources/Employee/Name[not(.=preceding::Name)]">
<Name><xsl:value-of select="."/></Name>
</xsl:for-each>
</EmployeeName>
</xsl:template>
</xsl:stylesheet>
Refer http://www.eggheadcafe.com/articles/20010508.asp for details.
Hope this helps.
Vasudha
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic