[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Unwanted elements in xsl output
Hi, > <xsl:template match="/"> > <html> > <head><title>Web app. list</title></head> > <body> > <xsl:for-each select="webapps/website"> > <table border="1" summary="Web Application Table"> > <tr> > <td>Site Name:</td> > <td><xsl:value-of select="@name"/></td> > </tr> > <xsl:apply-templates/> Here you ask to process all the child nodes, including the language element > </table> > </xsl:for-each> > </body> > </html> > </xsl:template> > > <xsl:template match="address"> and this will match the address elements > <tr> > <td>URL:</td> > <td><xsl:value-of select="."/></td> > </tr> > </xsl:template> but you don't have a template to match the language element. Thus, the build-in template is used to process it, see <http://www.w3.org/TR/xslt#built-in-rule>. The result is that a text node "PHP" will be added to the result tree, without tr and td element wrappers. The HTML DTD doesn't allow PCDATA inside table, thus browser error recovery kicks in; Mozilla recovers by outputting the PCDATA after the table, IE before. You can fix your stylesheet by either selecting only the elements you want to process in the / template, i.e. <xsl:apply-templates select="address" /> or be adding a template to match the language element and output nothing in it. <xsl:template match="language"/> It usually/always helps in debugging if you use a command-line XSLT processor, or an IDE like Xselerator to see what the output is, instead of just looking at the HTML renderation on a browser. Cheers, Jarno - Razed In Black: Oh My Goth!... aah, the nostalgia XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|