RE: [xsl] Newbie issue with apply-templates and output

Subject: RE: [xsl] Newbie issue with apply-templates and output
From: "Touchtel" <omprakashv@xxxxxxxxxxxxxxxxx>
Date: Fri, 11 Mar 2005 22:02:32 +0530
]         You may try the other gentleman's suggestion or remove the
xsl:apply-templates from
          inside the template for element if you know it only has text


-----Original Message-----
From: A.Little [mailto:A.Little@xxxxxxxxxx]
Sent: Friday, March 11, 2005 9:52 PM
To: xsl-list
Subject: [xsl] Newbie issue with apply-templates and output


I'm quite new to all this XSL stuff and have now got very confused with
what's happening with the output using my XSL - it's dumping out the
text from nodes even tough I've not specified in the XSL to do this. The
code (xml & xsl) is given below with the output - and I'm confused why
it's output 'heading 1' etc twice, and why 'I'm here' is being output at
all. How can I change my xsl so it only outputs the headings once, and
the extra text isn't displayed at all?

It's probably obvious to everyone else - but not to me! :-(

Any help/explanation much appreciated,
Here's the XSL:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
<xsl:output method="xml"/>

<xsl:template match="/">

<xsl:template match="element">
  <temp><xsl:value-of select="."/></temp>

<xsl:template match="body">


And here is the xml:

<?xml version="1.0" encoding="UTF-8"?>
	<element>heading 1</element>
	<element>heading 2</element>
		<element>heading 3</element>
		<element>heading 4</element>
		I'm here

But the output I'm getting is:

<?xml version="1.0" encoding="UTF-16"?>
	<temp>heading 1</temp>
	heading 1
	<temp>heading 2</temp>
	heading 2
	<temp>heading 3</temp>
	heading 3
	<temp>heading 4</temp>
	heading 4
	I'm here

Current Thread