www.webdeveloper.com
Results 1 to 4 of 4

Thread: Issues with displaying XML info on webpage using XSL

  1. #1
    Join Date
    Apr 2009
    Posts
    2

    Issues with displaying XML info on webpage using XSL

    So I need to make an XML file, an XSL file, and display the information from the XML file on a HTML page while using Javascript. I've made all 3 files, and I'm able to display my column headings I made in the XSL file, but the information from the XML file will not show up, and was hoping somebody could take a look at everything to make sure I'm not missing something huge.

    Code:
    <html>
    <head>
    <title>CSET3100 Assignment 20</title>
    </head>
    <body>
    <h3 align=center>Employee List</h3>
    <script language="javascript">
    
    var xml = new ActiveXObject("Microsoft.XMLDOM")
    xml.async = false
    xml.load("Assignment20.xml")
    
    var xsl = new ActiveXObject("Microsoft.XMLDOM")
    xsl.async = false
    xsl.load("Assignment20.xsl")
    
    document.write(xml.transformNode(xsl))
    </script>
    
    </body>
    </html>
    Code:
    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://w3.org/TR/WD-xsl">
    <xsl:template match="/">
    <html>
    <body>
    <table align="center" border="1" bgcolor="#CC99FF">
    <tr>
    <th>Employee ID#</th>
    <th>First Name</th>
    <th>Last Name</th>
    <th>Title</th>
    <th>Social Security Number</th>
    
    <th>Date of Birth</th>
    <th>Salary</th>
    <th>Gender</th>
    </tr>
    <xsl:for-each select="/">
    <tr>
    <td align="right">
    	<xsl:value-of select="empid"/>
    </td>
    <td>
    	<xsl:value-of select="fname"/>
    </td>
    
    <td>
    	<xsl:value-of select="lname"/>
    </td>
    <td>
    	<xsl:value-of select="title"/>
    </td>
    <td>
    	<xsl:value-of select="SSN"/>
    </td>
    <td>
    	<xsl:value-of select="DOB"/>
    </td>
    <td>
    
    	<xsl:value-of select="salary"/>
    </td>
    <td>
    	<xsl:value-of select="gender"/>
    </td>
    </tr>
    </xsl:for-each>
    </table>
    </body>
    </html>
    </xsl:template>
    </xsl:stylesheet>
    Code:
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <employees>
    <employee>
    <empid>1</empid>
    <fname>Marcus</fname>
    <lname>Johanssen</lname>
    <title>Director of HR</title>
    <SSN>111-22-3333</SSN>
    <DOB>11/21/1954</DOB>
    <salary>54000</salary>
    
    <gender>M</gender>
    </employee>
    
    <employee>
    <empid>2</empid>
    <fname>Steve</fname>
    <lname>Francis</lname>
    <title>Director of Marketing</title>
    <SSN>122-24-3543</SSN>
    <DOB>7/13/1972</DOB>
    <salary>65000</salary>
    <gender>M</gender>
    </employee>
    
    <employee>
    <empid>3</empid>
    <fname>Jenny</fname>
    <lname>Wilder</lname>
    <title>Branch Manager</title>
    <SSN>321-24-0192</SSN>
    <DOB>8/01/1963</DOB>
    <salary>41000</salary>
    <gender>f</gender>
    </employee>
    
    <employee>
    <empid>4</empid>
    <fname>Jim</fname>
    <lname>Johanssen</lname>
    <title>Director of HR</title>
    <SSN>111-22-3333</SSN>
    <DOB>11/21/1954</DOB>
    <salary>54000</salary>
    <gender>M</gender>
    </employee>
    
    
    <employee>
    <empid>5</empid>
    <fname>Jose</fname>
    <lname>Cruz</lname>
    <title>Marketing Branch manager</title>
    <SSN>234-12-4321</SSN>
    <DOB>10/11/1958</DOB>
    <salary>52000</salary>
    <gender>M</gender>
    </employee>
    
    <employee>
    <empid>6</empid>
    <fname>Dennis</fname>
    <lname>Gritten</lname>
    <title>Intern</title>
    <SSN>888-77-2371</SSN>
    <DOB>4/21/1987</DOB>
    <salary>0</salary>
    <gender>M</gender>
    </employee>
    
    
    
    <employee>
    <empid>7</empid>
    <fname>Colin</fname>
    <lname>Deohy</lname>
    <title>Janitor</title>
    <SSN>555-55-5555</SSN>
    <DOB>1/31/1981</DOB>
    <salary>29000</salary>
    <gender>M</gender>
    </employee>
    
    <employee>
    <empid>8</empid>
    <fname>Wilbur</fname>
    <lname>Drennen</lname>
    <title>IT Branch Manager</title>
    <SSN>333-55-7878</SSN>
    <DOB>3/4/1956</DOB>
    <salary>56000</salary>
    <gender>M</gender>
    </employee>
    
    
    
    <employee>
    <empid>9</empid>
    <fname>Olivia</fname>
    <lname>Reynolds</lname>
    <title>HR Assistant Director</title>
    <SSN>444-33-9999</SSN>
    <DOB>2/20/1980</DOB>
    <salary>35000</salary>
    <gender>f</gender>
    </employee>
    
    <employee>
    <empid>10</empid>
    <fname>Tony</fname>
    <lname>Kornheiser</lname>
    <title>Budget Director</title>
    <SSN>666-11-5555</SSN>
    <DOB>10/2/1947</DOB>
    <salary>75000</salary>
    <gender>M</gender>
    </employee>
    
    </employees>

  2. #2
    Join Date
    May 2007
    Posts
    288
    <xsl:for-each select="/">
    should be
    <xsl:for-each select="//employee">

  3. #3
    Join Date
    Apr 2009
    Posts
    2
    I updated that line of code you suggested, and still no information from my XML table.

    EDIT: Although the code in my first post may not represent it due to me being unable to edit my first post for some reason, I did update my copies of the code.

  4. #4
    Join Date
    May 2007
    Posts
    288
    Also, you're using the old xsl namespace.
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles