XSLT tranformation XML to HTML in browser don't work



I have XML like this:



<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="transformation.xslt"?>
<data-xml>
<limit type="integer">10</limit>
<entries type="array">
<entry>
<key>key1</key>
<value type="integer">1</value>
</entry>
<entry>
<key>key2</key>
<value type="integer">2</value>
</entry>
<entry>
<key>key3</key>
<value type="integer">3</value>
</entry>
</entries>
</data-xml>


and such XSLT (transormation.xslt), which should transfrom my XML to HTML with table:



<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet xmlns:xsl="http://ift.tt/tCZ8VR" version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/data-xml">

<html>
<head>
<title>XML data</title>
</head>
<body>
<strong>Limit: </strong> <xsl:value-of select="limit"/>
<table>
<tr>
<th>Key</th>
<th>Value</th>
</tr>
<xsl:for-each select="entries/entry">
<tr>
<td> <xsl:value-of select="key"/> </td>
<td> <xsl:value-of select="value"/> </td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>


XML and XSLT files are successfully loaded, but instead expected HTML I see this: ugly plain text


I tested this in FF in Chrome and received identical result. But very ugly and incorrect result.


What do I do wrong?


Thanks you.


No comments:

Post a Comment