xsl-list
[Top] [All Lists]

RE: Newbie issue with apply-templates and output

2005-03-11 09:33:28
That's done the trick ;-) Thanks, Alex 

-----Original Message-----
From: Ross, Douglas [mailto:DRoss(_at_)Kronos(_dot_)com] 
Sent: 11 March 2005 16:25
To: xsl-list
Subject: RE: [xsl] Newbie issue with apply-templates and output

There is a default template that matches I believe text nodes.

To turn the default template off try adding <xsl:template
match="text()"/>.

Douglas Ross
Developer, HTML UI Framework
Kronos
E-mail: dross(_at_)kronos(_dot_)com
Voice: (978) 947-4305
Fax: (978) 256-2474
www.kronos.com
Smaller, Faster, Sharper, Easier(tm)

-----Original Message-----
From: A.Little [mailto:A(_dot_)Little(_at_)open(_dot_)ac(_dot_)uk]
Sent: Friday, March 11, 2005 11:22 AM
To: xsl-list
Subject: [xsl] Newbie issue with apply-templates and output

Hi,

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,
Alex
 --------------------
Here's the XSL:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="xml"/>

<xsl:template match="/">
        <report>
        <xsl:apply-templates/>
        </report>
</xsl:template>

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

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

</xsl:stylesheet>

And here is the xml:

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

But the output I'm getting is:

<?xml version="1.0" encoding="UTF-16"?>
<report>
        <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
</report>

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>