This is a namespace issue. You've defined templates that match elements with the local names feed
and entry
that are not in a namespace, but your source document has them in the http://www.w3.org/2005/Atom
namespace. Therefore your templates don't match anything, and the default template rules are used instead, which will result in outputting all the text nodes in the whole source document.
I see that you have defined the p
prefix in your stylesheet bound to the http://www.w3.org/2005/Atom
namespace, so you simply need to use that prefix in your match patterns and select expressions.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:p="http://www.w3.org/2005/Atom"
xmlns="http://www.w3.org/1999/xhtml"
version="1.0">
<xsl:output method="xml"
omit-xml-declaration="yes"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"/>
<xsl:template match="p:feed">
<html>
<body>
<h1>W3C Atom Document</h1>
<ul>
<xsl:apply-templates select="p:entry"/>
</ul>
</body>
</html>
</xsl:template>
<xsl:template match="p:entry">
<li>
<xsl:value-of select="p:title" />
</li>
</xsl:template>
</xsl:stylesheet>
Note that I've also constrained the apply-templates
to pick out just the entry
elements, so you don't get the text of the global title
, id
, generator
, etc. as well.