XML/XSLT doesn't display properly in a browser

hi, i'm a xml/xslt beginner having trouble getting a simple network inventory doc to display correctly in a browser (it just shows a list of values, no formatting), i'd appreciate any feedback r.e. where i'm going wrong.  thanks.

XML code - networkinventory.xml

<?xml version="1.0" encoding="ISO8859-1"?>
<?xml-stylesheet type="text/xsl" href="networkinventory.xsl"?>
<!DOCTYPE NetworkInventory [
<!ELEMENT NetworkInventory (ComputerName,UserID,Password,IPAddress,Department,Location)>
<!ELEMENT ComputerName (#PCDATA)>
<!ELEMENT UserID (#PCDATA)>
<!ELEMENT Password (#PCDATA)>
<!ELEMENT IPAddress (#PCDATA)>
<!ELEMENT Department (#PCDATA)>
<!ELEMENT Location (#PCDATA)>
<!ELEMENT IPAddress (#PCDATA)>
]>
<NetworkInventory>
  <NetworkInv>
    <ComputerName>AdminPC</ComputerName>
    <UserID>TOKeeffe</UserID>
    <Password>migrate</Password>
    <IPAddress>192.168.1.20</IPAddress>
    <Department>IT</Department>
    <Location>Waterford</Location>
  </NetworkInv>
  <NetworkInv>
    <ComputerName>PC_1</ComputerName>
    <UserID>GOByrne</UserID>
    <Password>jumpship</Password>
    <IPAddress>192.168.1.21</IPAddress>
    <Department>New Business</Department>
    <Location>Waterford</Location>
  </NetworkInv>
  <NetworkInv>
    <ComputerName>PC_2</ComputerName>
    <UserID>GODwyer</UserID>
    <Password>motion</Password>
    <IPAddress>192.168.1.22</IPAddress>
    <Department>Renewals</Department>
    <Location>Waterford</Location>
  </NetworkInv>
  <NetworkInv>
    <ComputerName>PC_3</ComputerName>
    <UserID>RMCGrath</UserID>
    <Password>flood</Password>
    <IPAddress>192.168.1.23</IPAddress>
    <Department>Renewals</Department>
    <Location>Waterford</Location>
  </NetworkInv>
  <NetworkInv>
    <ComputerName>AdminPC</ComputerName>
    <UserID>TOKeeffe</UserID>
    <Password>migrate</Password>
    <IPAddress>192.168.1.20</IPAddress>
    <Department>IT</Department>
    <Location>Waterford</Location>
  </NetworkInv>
  <NetworkInv>
    <ComputerName>AdminPC</ComputerName>
    <UserID>TOKeeffe</UserID>
    <Password>migrate</Password>
    <IPAddress>192.168.1.20</IPAddress>
    <Department>IT</Department>
    <Location>Waterford</Location>
  </NetworkInv>
  <NetworkInv>
    <ComputerName>AdminPC</ComputerName>
    <UserID>TOKeeffe</UserID>
    <Password>migrate</Password>
    <IPAddress>192.168.1.20</IPAddress>
    <Department>IT</Department>
    <Location>Waterford</Location>
  </NetworkInv>
  <NetworkInv>
    <ComputerName>AdminPC</ComputerName>
    <UserID>TOKeeffe</UserID>
    <Password>migrate</Password>
    <IPAddress>192.168.1.20</IPAddress>
    <Department>IT</Department>
    <Location>Waterford</Location>
  </NetworkInv>
  <NetworkInv>
    <ComputerName>AdminPC</ComputerName>
    <UserID>TOKeeffe</UserID>
    <Password>migrate</Password>
    <IPAddress>192.168.1.20</IPAddress>
    <Department>IT</Department>
    <Location>Waterford</Location>
  </NetworkInv>
  <NetworkInv>
    <ComputerName>AdminPC</ComputerName>
    <UserID>TOKeeffe</UserID>
    <Password>migrate</Password>
    <IPAddress>192.168.1.20</IPAddress>
    <Department>IT</Department>
    <Location>Waterford</Location>
  </NetworkInv>
  <NetworkInv>
    <ComputerName>AdminPC</ComputerName>
    <UserID>TOKeeffe</UserID>
    <Password>migrate</Password>
    <IPAddress>192.168.1.20</IPAddress>
    <Department>IT</Department>
    <Location>Waterford</Location>
  </NetworkInv>
  <NetworkInv>
    <ComputerName>AdminPC</ComputerName>
    <UserID>TOKeeffe</UserID>
    <Password>migrate</Password>
    <IPAddress>192.168.1.20</IPAddress>
    <Department>IT</Department>
    <Location>Waterford</Location>
  </NetworkInv>
  <NetworkInv>
    <ComputerName>AdminPC</ComputerName>
    <UserID>TOKeeffe</UserID>
    <Password>migrate</Password>
    <IPAddress>192.168.1.20</IPAddress>
    <Department>IT</Department>
    <Location>Waterford</Location>
  </NetworkInv>
  <NetworkInv>
    <ComputerName>AdminPC</ComputerName>
    <UserID>TOKeeffe</UserID>
    <Password>migrate</Password>
    <IPAddress>192.168.1.20</IPAddress>
    <Department>IT</Department>
    <Location>Waterford</Location>
  </NetworkInv>
  <NetworkInv>
    <ComputerName>AdminPC</ComputerName>
    <UserID>TOKeeffe</UserID>
    <Password>migrate</Password>
    <IPAddress>192.168.1.20</IPAddress>
    <Department>IT</Department>
    <Location>Waterford</Location>
  </NetworkInv>
  <NetworkInv>
    <ComputerName>AdminPC</ComputerName>
    <UserID>TOKeeffe</UserID>
    <Password>migrate</Password>
    <IPAddress>192.168.1.20</IPAddress>
    <Department>IT</Department>
    <Location>Waterford</Location>
  </NetworkInv>
  <NetworkInv>
    <ComputerName>AdminPC</ComputerName>
    <UserID>TOKeeffe</UserID>
    <Password>migrate</Password>
    <IPAddress>192.168.1.20</IPAddress>
    <Department>IT</Department>
    <Location>Waterford</Location>
  </NetworkInv>
  <NetworkInv>
    <ComputerName>AdminPC</ComputerName>
    <UserID>TOKeeffe</UserID>
    <Password>migrate</Password>
    <IPAddress>192.168.1.20</IPAddress>
    <Department>IT</Department>
    <Location>Waterford</Location>
  </NetworkInv>
  <NetworkInv>
    <ComputerName>AdminPC</ComputerName>
    <UserID>TOKeeffe</UserID>
    <Password>migrate</Password>
    <IPAddress>192.168.1.20</IPAddress>
    <Department>IT</Department>
    <Location>Waterford</Location>
  </NetworkInv>
  <NetworkInv>
    <ComputerName>AdminPC</ComputerName>
    <UserID>TOKeeffe</UserID>
    <Password>migrate</Password>
    <IPAddress>192.168.1.20</IPAddress>
    <Department>IT</Department>
    <Location>Waterford</Location>
  </NetworkInv>
  <NetworkInv>
    <ComputerName>AdminPC</ComputerName>
    <UserID>TOKeeffe</UserID>
    <Password>migrate</Password>
    <IPAddress>192.168.1.20</IPAddress>
    <Department>IT</Department>
    <Location>Waterford</Location>
  </NetworkInv>
  <NetworkInv>
    <ComputerName>AdminPC</ComputerName>
    <UserID>TOKeeffe</UserID>
    <Password>migrate</Password>
    <IPAddress>192.168.1.20</IPAddress>
    <Department>IT</Department>
    <Location>Waterford</Location>
  </NetworkInv>
  <NetworkInv>
    <ComputerName>AdminPC</ComputerName>
    <UserID>TOKeeffe</UserID>
    <Password>migrate</Password>
    <IPAddress>192.168.1.20</IPAddress>
    <Department>IT</Department>
    <Location>Waterford</Location>
  </NetworkInv>
  <NetworkInv>
    <ComputerName>AdminPC</ComputerName>
    <UserID>TOKeeffe</UserID>
    <Password>migrate</Password>
    <IPAddress>192.168.1.20</IPAddress>
    <Department>IT</Department>
    <Location>Waterford</Location>
  </NetworkInv>
  <NetworkInv>
    <ComputerName>AdminPC</ComputerName>
    <UserID>TOKeeffe</UserID>
    <Password>migrate</Password>
    <IPAddress>192.168.1.20</IPAddress>
    <Department>IT</Department>
    <Location>Waterford</Location>
  </NetworkInv>
  <NetworkInv>
    <ComputerName>AdminPC</ComputerName>
    <UserID>TOKeeffe</UserID>
    <Password>migrate</Password>
    <IPAddress>192.168.1.20</IPAddress>
    <Department>IT</Department>
    <Location>Waterford</Location>
  </NetworkInv>
</NetworkInventory>  

XSLT Code - NetworkInventory.xsl

<?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>
  <h2>Network Inventory</h2>
  <table border="1">
    <tr bgcolor="#9acd32">
            <th>ComputerName</th>
            <th>UserID</th>
      <th>Password</th>
      <th>IPAddress</th>
      <th>Department</th>
      <th>Location</th>
    </tr>
    <xsl:for-each select="network/inventory">
    <tr>
            <td><xsl:value-of select="ComputerName"/></td>
            <td><xsl:value-of select="UserID"/></td>
      <td><xsl:value-of select="Password"/></td>
      <td><xsl:value-of select="IPAddress"/></td>
      <td><xsl:value-of select="Department"/></td>
      <td><xsl:value-of select="Location"/></td>
    </tr>
    </xsl:for-each>
  </table>
  </body>
  </html>
</xsl:template>

</xsl:stylesheet>
tokeeAsked:
Who is Participating?
 
Geert BormansConnect With a Mentor Information ArchitectCommented:
Your DTD is not correct

<!DOCTYPE NetworkInventory [
<!ELEMENT NetworkInventory (NetworkInv)+>
<!ELEMENT NetworkInv (ComputerName,UserID,Password,IPAddress,Department,Location)>
<!ELEMENT ComputerName (#PCDATA)>
<!ELEMENT UserID (#PCDATA)>
<!ELEMENT Password (#PCDATA)>
<!ELEMENT IPAddress (#PCDATA)>
<!ELEMENT Department (#PCDATA)>
<!ELEMENT Location (#PCDATA)>

and there is a bug in the XPath for the for each

           <xsl:for-each select="NetworkInventory/NetworkInv">

and then it works
0
 
tokeeAuthor Commented:
Thanks a lot Gertone, it would've taken me a long time to spot that!  Tony
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.