
April 4th, 2011, 11:32 AM
|
|
Registered User
|
|
Join Date: Apr 2011
Posts: 2
Time spent in forums: 1 h 2 m 15 sec
Reputation Power: 0
|
|
|
XML will not display the way I want!!!
Hi all,
Anyway I'm learning XML and I have run into a problem that I can't get past. I have an XML file that will not display properly. All of the rows and columns are populated correctly except the 'Hire Date' column. I can only seem to get it to read the first hire date of the first employee for all employees or nothing at all...or I get the hire dates out but they are not in the correct column. I have tried everything I can think of but no joy
This is my XML data
Code:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="employees.xsl" type="text/xsl"?>
<employees xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="employees.xsd">
<head>
<title>Employee Data File</title>
<maintainer>Sam Williams</maintainer>
</head>
<employee eid="p98145" dept="programming">
<contact addInfo="c_98145.xml">
<name>
<firstName>Joe</firstName>
<middleName int="B">Brian</middleName>
<lastName>Smith</lastName>
</name>
<address>
<street>611 Ridgewood Drive,</street>
<city>Denver,</city>
<state>Colorado</state>
<zipcode>80210</zipcode>
</address>
<phone>
<tel type="wk">303-4667339</tel>
<tel type="hm">303-9842361</tel>
<fax>303-4667357</fax>
</phone>
<email>JSmith@earthlink.net</email>
</contact>
<hireDate>1998-10-14</hireDate>
</employee>
<employee eid="t00022" dept="training">
<contact addInfo="c_00022.xml">
<name>
<firstName>Sam</firstName>
<middleName int="S">Stephen</middleName>
<lastName>Williams</lastName>
</name>
<address>
<street>2103 Steck Drive,</street>
<city>Austin,</city>
<state>Texas</state>
<zipcode>78731</zipcode>
</address>
<phone>
<tel type="wk">512-3467899</tel>
<tel type="hm">512-4623356</tel>
<fax>512-3465655</fax>
</phone>
<email>swilliams@verizon.net</email>
</contact>
<hireDate>2000-03-11</hireDate>
</employee>
<employee eid="e67721" dept="engineering">
<contact addInfo="c_20022.xml">
<name>
<firstName>Sean</firstName>
<middleName int="J">James</middleName>
<lastName>Walters</lastName>
</name>
<address>
<street>2122 Steinway Drive,</street>
<city>Dallas,</city>
<state>Texas</state>
<zipcode>78246</zipcode>
</address>
<phone>
<tel type="wk">512-3457599</tel>
<tel type="hm">512-4622556</tel>
<fax>512-3465612</fax>
</phone>
<email>swalters@comcast.net</email>
</contact>
<hireDate>12-7-2007</hireDate>
</employee>
<employee eid="cd34512" dept="content development">
<contact addInfo="c_54511.xml">
<name>
<firstName>Adam</firstName>
<middleName int="W">William</middleName>
<lastName>Hopkins</lastName>
</name>
<address>
<street>1266 Leeway Street,</street>
<city>Denver,</city>
<state>Colorado</state>
<zipcode>44699</zipcode>
</address>
<phone>
<tel type="wk">233-3467899</tel>
<tel type="hm">233-4623356</tel>
<fax>233-3465655</fax>
</phone>
<email>ahopkins@verizon.net</email>
</contact>
<hireDate>6-2-2004</hireDate>
</employee>
<employee eid="r00022" dept="research">
<contact addInfo="r_00442.xml">
<name>
<firstName>Steve</firstName>
<middleName int="D">David</middleName>
<lastName>Manley</lastName>
</name>
<address>
<street>2122 Pittsburgh Drive,</street>
<city>Pittsburgh,</city>
<state>Philadelphia</state>
<zipcode>54541</zipcode>
</address>
<phone>
<tel type="wk">588-3466699</tel>
<tel type="hm">588-4626656</tel>
<fax>588-3466655</fax>
</phone>
<email>smanley@gmail.com</email>
</contact>
<hireDate>9-10-2009</hireDate>
</employee>
<employee eid="s00236" dept="support">
<contact addInfo="c_00644.xml">
<name>
<firstName>Trevor</firstName>
<middleName int="E">Evan</middleName>
<lastName>Williams</lastName>
</name>
<address>
<street>9755 Christchurch Drive,</street>
<city>Reno,</city>
<state>Nevada</state>
<zipcode>67244</zipcode>
</address>
<phone>
<tel type="wk">922-4217899</tel>
<tel type="hm">922-5473356</tel>
<fax>922-3474255</fax>
</phone>
<email>twilliams@verizon.net</email>
</contact>
<hireDate>1-11-2002</hireDate>
</employee>
<employee eid="s00023" dept="support">
<contact addInfo="c_22122.xml">
<name>
<firstName>David</firstName>
<middleName int="F">Frank</middleName>
<lastName>Jackson</lastName>
</name>
<address>
<street>2126 Beltway Drive,</street>
<city>Dallas,</city>
<state>Texas</state>
<zipcode>78731</zipcode>
</address>
<phone>
<tel type="wk">512-3725322</tel>
<tel type="hm">512-4827633</tel>
<fax>512-3462876</fax>
</phone>
<email>swilliams@verizon.net</email>
</contact>
<hireDate>2000-03-11</hireDate>
</employee>
<employee eid="p88022" dept="programming">
<contact addInfo="c_88022.xml">
<name>
<firstName>Ben</firstName>
<middleName int="J">John</middleName>
<lastName>Ashton</lastName>
</name>
<address>
<street>724 Irvine Street,</street>
<city>San Francisco,</city>
<state>California</state>
<zipcode>78446</zipcode>
</address>
<phone>
<tel type="wk">717-3467899</tel>
<tel type="hm">717-4623356</tel>
<fax>717-3444655</fax>
</phone>
<email>bashton@comcast.net</email>
</contact>
<hireDate>22-9-2000</hireDate>
</employee>
<employee eid="hr00022" dept="hr">
<contact addInfo="hr_00022.xml">
<name>
<firstName>James</firstName>
<middleName int="M">Mark</middleName>
<lastName>Duffield</lastName>
</name>
<address>
<street>2122 Joshua Avenue,</street>
<city>Chicago,</city>
<state>Illinois</state>
<zipcode>44226</zipcode>
</address>
<phone>
<tel type="wk">603-1997899</tel>
<tel type="hm">603-7443356</tel>
<fax>603-3463855</fax>
</phone>
<email>jd@verizon.net</email>
</contact>
<hireDate>22-7-2003</hireDate>
</employee>
<employee eid="f06622" dept="finance">
<contact addInfo="f_06622.xml">
<name>
<firstName>Paul</firstName>
<middleName int="T">Terry</middleName>
<lastName>Pender</lastName>
</name>
<address>
<street>7732 LaJolla Drive,</street>
<city>San Diego,</city>
<state>California</state>
<zipcode>55981</zipcode>
</address>
<phone>
<tel type="wk">808-3467899</tel>
<tel type="hm">808-4623356</tel>
<fax>808-3465655</fax>
</phone>
<email>ppender@verizon.net</email>
</contact>
<hireDate>4-5-2001</hireDate>
</employee>
<employee eid="e00322" dept="engineering">
<contact addInfo="e_00322.xml">
<name>
<firstName>Joseph</firstName>
<middleName int="C">Chris</middleName>
<lastName>Aherne</lastName>
</name>
<address>
<street>2103 Westway Drive,</street>
<city>Boston,</city>
<state>Massacheutes</state>
<zipcode>78681</zipcode>
</address>
<phone>
<tel type="wk">677-4787899</tel>
<tel type="hm">677-9973356</tel>
<fax>677-2255655</fax>
</phone>
<email>ja@comcast.net</email>
</contact>
<hireDate>31-9-1998</hireDate>
</employee>
<employee eid="p00072" dept="programming">
<contact addInfo="p_00072.xml">
<name>
<firstName>Sean</firstName>
<middleName int="A">Adam</middleName>
<lastName>Walsh</lastName>
</name>
<address>
<street>1222 Christopher Street,</street>
<city>New York,</city>
<state>New York</state>
<zipcode>11021</zipcode>
</address>
<phone>
<tel type="wk">212-3467899</tel>
<tel type="hm">212-4623356</tel>
<fax>212-3465655</fax>
</phone>
<email>saws@verizon.net</email>
</contact>
<hireDate>21-2-2002</hireDate>
</employee>
<employee eid="f00332" dept="finance">
<contact addInfo="f_00332.xml">
<name>
<firstName>Vincent</firstName>
<middleName int="B">Barry</middleName>
<lastName>Steadman</lastName>
</name>
<address>
<street>23 Rushton Way,</street>
<city>Portland,</city>
<state>Oregon</state>
<zipcode>44731</zipcode>
</address>
<phone>
<tel type="wk">434-3467899</tel>
<tel type="hm">434-4623356</tel>
<fax>434-3465655</fax>
</phone>
<email>vas@verizon.net</email>
</contact>
<hireDate>25-7-1995</hireDate>
</employee>
</employees>
And this is my XSL file
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body style="background-color: #bf99ff">
<h2 style="text-align:center">Employee Data File</h2>
<table border="1">
<tr style="background-color:#cf99ff">
<th style="font-size:20pt">First_Name</th>
<th style="font-size:20pt">Middle_Name</th>
<th style="font-size:20pt">Last_Name</th>
<th style="font-size:20pt">Address</th>
<th style="font-size:20pt">Work Phone</th>
<th style="font-size:20pt">Home Phone</th>
<th style="font-size:20pt">Fax</th>
<th style="font-size:20pt">E-Mail</th>
<th style="font-size:20pt">Hire Date</th>
</tr>
<xsl:for-each select="employees/employee/contact">
<tr>
<td style="font-size:14pt">
<xsl:value-of select="name/firstName"/>
</td>
<td style="font-size:14pt">
<xsl:value-of select="name/middleName"/>
</td>
<td style="font-size:14pt">
<xsl:value-of select="name/lastName"/>
</td>
<td style="font-size:14pt">
<xsl:value-of select="address"/>
</td>
<td style="font-size:14pt">
<xsl:value-of select="phone/tel[@type='wk']"/>
</td>
<td style="font-size:14pt">
<xsl:value-of select="phone/tel[@type='hm']"/>
</td>
<td style="font-size:14pt">
<xsl:value-of select="phone/fax"/>
</td>
<td style="font-size:14pt">
<xsl:value-of select="email"/>
</td>
<tr>
</tr>
</tr>
</xsl:for-each>
xsl:for-each select="employees/employee">
<tr>
<td style="font-size:14pt">
<xsl:value-of select="hireDate"/>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
This is my best effort, as I say previous attempts either repeat the hire date or no date entered in the column at all.
Sorry for the long winded code..first time poster. Any help that can point me in the right direction of populating the Hire_Date column correctly would be brilliant
Thanks All 
|