I am having some headache with this XML and XSL; I’m looking at it and can’t figure out why it does not work. Maybe some other eyes will be able to spot my mistake as I must be missing something here.
2 documents: lecturers.xml and lecturers.xsl. I can't get the XSL templates formatting to work, all i see is the heading[h1] and an empty table (only table headings are populated[th]).
lecturers.xmllecturers.xslCode:<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="lecturers.xsl" ?> <!DOCTYPE lecturers [ <!ELEMENT lecturers (lecturer+)> <!ELEMENT lecturer (name)> <!ELEMENT name (teaching, research)> <!ELEMENT teaching (course+)> <!ELEMENT course (#PCDATA)> <!ELEMENT research (#PCDATA)> <!ATTLIST name title CDATA "title" first CDATA "first name" last CDATA "last name" > <!ATTLIST course code ID #REQUIRED > ]> <lecturers> <lecturer> <name title="Professor" first="Peter" last="Quirk"> <teaching> <course code="CO3070">XML and the Web</course> <course code="CO3300">Web Server Architectures</course> </teaching> <research> The application of Web protocols to Biology </research> </name> </lecturer> <lecturer> <name title="Professor" first="John" last="Doe"> <teaching> <course code="CO3100">Advanced Multimedia</course> <course code="CO3390">Flash MX</course> </teaching> <research> The application of Web protocols to Biology </research> </name> </lecturer> </lecturers>Thanks in advance.Code:<?xml version='1.0' ?> <xsl:stylesheet version='1.0' xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" version="4.0" /> <xsl:template match="/"> <html> <head> <title>Lecturers</title> </head> <body> <h1>Lecturers</h1> <table border = "1"> <tr> <th>Title</th> <th>Name</th> <th>Teaching</th> <th>Research</th> </tr> <xsl:for-each select="lecturers/lecturer"> <tr> <td><xsl:value-of select="lecturers/lecturer/name/@title" /></td> <td><xsl:value-of select="lecturers/lecturer/name/@name" /></td> <td><xsl:value-of select="lecturers/lecturer/teaching/course" /></td> <td><xsl:value-of select="lecturers/lecturer/research" /></td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet>


LinkBack URL
About LinkBacks
Reply With Quote

