This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Product and Other Certifications and the fly likes How do i obtain unique value thru this code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Product and Other Certifications
Bookmark "How do i obtain unique value thru this code" Watch "How do i obtain unique value thru this code" New topic
Author

How do i obtain unique value thru this code

clyde mel
Greenhorn

Joined: Mar 05, 2002
Posts: 22
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>


Just believe in yourself...
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
With DOM, SAX, XSL ?


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
clyde mel
Greenhorn

Joined: Mar 05, 2002
Posts: 22
with xsl or sax
Vasudha Deepak
Ranch Hand

Joined: Mar 15, 2002
Posts: 86
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


IBM Certified Developer -XML and Related Technologies(141)<br />SCJP2 SCWCD
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How do i obtain unique value thru this code
 
Similar Threads
newbie:Data retrieval from xml files
How to know if a parsed character using SAX parser is a new line character ?
Disney
Hibernate - can't get the collection (List) when create criteria
dynamic xml output based on user input