Flood Gravemind
Flood Gravemind

Reputation: 3803

Xslt for a XML with no parent tag

I have a simple xml file like

<?xml version="1.0" encoding="UTF-8"?>
<tag>Funny</tag>
<tag>Hilarious</tag>
<tag>Stupid</tag>

I am having difficulty constructing a XSLT file without a parent node. Is it possible to do this?

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
 >
 <xsl:output method="html" indent="yes"/>

 <xsl:template match="/" >
<body>
  <xsl:apply-templates select ="tags/tag"/>
</body>
 </xsl:template>

 <xsl:template match="tag" >
  <li>
  <a>
    <xsl:attribute name="href">
      album.aspx/<xsl:value-of select="."  />
    </xsl:attribute>
    <xsl:value-of select="."/>
   </a>
 </li>

I have to enclose my xml with XML for this xslt to work.

Upvotes: 0

Views: 169

Answers (1)

Navin Rawat
Navin Rawat

Reputation: 3138

I don't think so. Processor always search for well-formed XML document. You must make your XML well-formed before applying any XSLT on it.

Upvotes: 1

Related Questions