ok...
first, in your xsl:
Code:
<xsl:output method="html"
encoding="UTF-8"
indent="yes"
doctype-public="-//W3C//DTD HTML 4.01//EN"
doctype-system="http://www.w3.org/TR/html4/strict.dtd"
standalone="yes"
omit-xml-declaration="yes">
xsl:output is a processing instruction. You don't close it at the end of the document.
You must keep it self closed. Do not put the rest of the stylesheet into it.
The correct syntax is
Code:
<xsl:output method="html"
encoding="UTF-8"
indent="yes"
doctype-public="-//W3C//DTD HTML 4.01//EN"
doctype-system="http://www.w3.org/TR/html4/strict.dtd"
standalone="yes"
omit-xml-declaration="yes"/>
without the at the end.
Code:
<xsl:template match="TVAMain/ProgramDescription/ServiceInformationTable/ServiceInformation">
is wrong. You don't give an XPath query as the name of a template.
But your template name must match (if you don't use call-template but apply-templates) the name of the final element to be matched
Then, in your first template, you have put
Code:
<html xmlns="http://www.w3.org/1999/xhtml">
Wrong again. In the xsl:output element, you have already specified that you wanted an html ouptut with a specific system doctype. You don't have to re declare it here.
And finally, at the end of your template, you have this:
Code:
xsl:template match="TVAMain/ProgramDescription/ServiceInformationTable/ServiceInformation" select="document('ServiceInformation.xml')">
So, again, the template name should not be an xpath query.
What strike me is that this template seems to have the same name that the first.
You cannot do that. Each template must be unique.
And finally, I never have seen anything like this document() function. Looking for it, I see that it's used to reference an external xml document.
So, in that field, you are alone. I never have used anything like this.
So, after those remarks, your corrected xsl document should be, I think:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:bbc='urn:tva:metadata:2005'
version="1.0">
<xsl:output method="html"
encoding="UTF-8"
indent="yes"
doctype-public="-//W3C//DTD HTML 4.01//EN"
doctype-system="http://www.w3.org/TR/html4/strict.dtd"
standalone="yes"
omit-xml-declaration="yes"/>
<!-- You always start by declaring your root element, and you start from it-->
<xsl:template match="/">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My Page</title>
</head>
<body>
<center>
<div id="container">
<xsl:apply-templates />
</div>
</center>
</body>
</xsl:template>
<!-- now, if you want to handle only informations in the ServiceInformation nodes, then you simply refer to it by the name
Now, as the root element has an xmlns attribute, it means that every nodes you want to access below it must be prefixed with the handle corresponding to the URI of the namespace.
IE: if in yml you have
<TVAMain xmlns='imgonna_blowthis'>
as the root element, you will need to declare in your xsl:
<xsl:stylsheet xmlns:anything_i_want='imgonna_blowthis'>
The resolution of the name space is done on "imgonna_blowthis"
-->
<xsl:template match="bbc:ServiceInformation" select="document('ServiceInformation.xml')">
<!-- As for the template name, you need to prefix this too-->
<xsl:value-of select="bbc:Name"/><br />
</xsl:template>
</xsl:stylesheet>
I have left your xml untouched, and applying this stylesheet to it produced:
HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<head xmlns:bbc="urn:tva:metadata:2005">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>My Page</title>
</head><body xmlns:bbc="urn:tva:metadata:2005"><center><div id="container">
BBC One<br>
BBC Two<br>
</div></center></body>
By the way, if you work on a linux machine, and you have libxslt2 installed, you can use this command to test your xml/xsl:
Code:
xsltproc file.xml file.xsl
It will print the result on the terminal windows.
Bookmarks