SiteExperts.com Logo Home | Community | Developer's Paradise
User Groups | Site Tools | Site Information | Search
 Main Menu
 Forums
SiteExperts.com Forums
All Discussions

SiteExperts Feedback
The Lounge
Dynamic HTML
Site Design/ Critiques
HTML and CSS
XML Technologies
The Wireless Internet
Internet Explorer
Microsoft .NET
The Server
Technical Support

Sponsored Links

User Groups : Forums : SiteExperts : XML Technologies :

Previous DiscussionNext Discussion
 Strange XML

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <title>Results</title>
    <not>hi</not>
  </head>
<body>
<results>hello</results>
</body>
</html>

This is my very simple XML document

<?xml version="1.0"?>
  <xsl:stylesheet version="1.0"
                           xmlns:xsl="
http://www.w3.org/1999/XSL/Transform"
                           xmlns:myNS="
http://devedge.netscape.com/2002/de">

    <xsl:output method="html" />

    <xsl:template match="html">
<xsl:for-each select="head">
<xsl:value-of select="." />
</xsl:for-each>

    </xsl:template>

  </xsl:stylesheet>

This is my very simple XSL document which should display the contents of html/head in the source document. Instead though, it gives me everything contained in the document - anything located anywhere, so in this case my output is Results hi hello rather than just Results hi.

Can anyone think why it's printing off everything? I've never come accross this before.


Started By captain92939 on Mar 24, 2005 at 3:19:10 AM

2 Response(s) | Reply

Earlier Replies | Replies 1 to 2 of 2 | Later Replies
MHenke on Mar 24, 2005 at 3:37:01 AM (# 1)

Try to add an empty template for all elements that aren't covered by a specific template.
Otherwise the default template of your processor for HTML output will apply for these elements (that is, it will output the content).

<xsl:template match="*">
</xsl:template>


simonleung on Mar 24, 2005 at 6:47:51 AM (# 2)
This message has been edited.

the xpath expression in the match and select returns a nodeset, not a single node, so you dont need to use for-each


Earlier Replies | Replies 1 to 2 of 2 | Later Replies

To respond to a discussion, you must first logon.

If you are not registered, please register yourself to become a member of the SiteExperts.community.

User Name
Password
Copyright 1997-2004 InsideDHTML.com, LLC. All rights reserved.