I have the following XML that I want to transform by XSLT. My main purpose is to have a list of urls only. It means any line that contains "http:// ".
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<urlset xmlns="http://www.google.com" xmlns:image="http://www.google1.com" xmlns:video="http://www.google2.com" xmlns:xhtml="http://www.google3.com">
<url>
<loc id="837">http://url1</loc>
</url>
<url>
<loc id="2332">http://url2</loc>
<image:image>
<image:loc>http://url3</image:loc>
</image:image>
<image:image>
<image:loc>http://url4</image:loc>
</image:image>
</url>
</urlset>
I created an XSLT as the following;
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<xsl:template match="/">
<html>
<body>
<h1>URLS</h1>
<ul>
<xsl:for-each select="urlset/url">
<li>
<xsl:value-of select="loc"/>
</li>
</xsl:for-each>
<xsl:for-each select="urlset/url/image:image">
<li>
<xsl:value-of select="image:loc"/>
</li>
</xsl:for-each>
</ul>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
The first foreach does not return anything and the second foreach gives exception like:
SystemId Unknown; Line #15; Column #53; Prefix must resolve to a namespace: image
Could anybody help why this XSLT fails ?
http://www.google.com
? -- 2. "My main purpose is to have a list of urls only. It means any line that contains "http:// "." I don't see any lines containing "http:// " in your example. – michael.hor257kimage:loc
will retrieve only some of the locations. – michael.hor257k