RE: [xsl] Omit Data While Using Copy

Subject: RE: [xsl] Omit Data While Using Copy
From: cknell@xxxxxxxxxx
Date: Wed, 11 Aug 2004 16:18:20 -0400
The first thing I spotted was an un-closed element, the final "<hanvisning>". Eliminate or fix that in order to get an XML document. A document that isn't well-formed, isn't XML.

Next I noticed that your encoding attribute value was in lower case. It should read "UTF-8".

To get to the heart of your problem, when you don't specify a template to use in processing a node, the default template is applied. That built-in template copies the text value of an un-matched node to the output. In this case, the text value of <titel>. By adding a "no-op" template that matches <titel>, the output will be suppressed:

<xsl:template match="titel" />

The next thing I noticed was that your template matches "kapitel/hanvisning". The <hanvisning> element has no child elements.

I am a little puzzled as to why the <titel> element is being processed. It is not a child of <hanvisning>. I had always thought that the default template was applied when <xsl:apply-templates /> is used, but it seems that is incorrect. Perhaps one of those better acquainted with the XSL spec can explain it to us.
-- 
Charles Knell
cknell@xxxxxxxxxx - email



-----Original Message-----
From:     Trevor Majic <majic87@xxxxxxxxxxx>
Sent:     Wed, 11 Aug 2004 13:57:39 -0500
To:       xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  [xsl] Omit Data While Using Copy

How would I be able to display all of the data from the following xml file, 
EXCEPT for the <titel> text? (see xml example below  which is one of 1200)

<?xml version="1.0"?><?xml:stylesheet type='text/xsl' href='manual.xsl'?>
<kapitel><titel>Measures every 10 percussion hours</titel><text/><hanvisning 
from="ID(SEUHS-SLAGVT-10-MATARE13)">Feeder</hanvisning><text/><hanvisning 
from="ID(SEUHS-SLAGVT-10-BOM19)">Boom</hanvisning><text/><hanvisning></kapitel>


I can use xsl:copy and select=node() to display everything, but no matter 
what I try, I can't seem to keep the <titel> from displaying.  If I try to 
just use match, I am only able to display "Feeder".

This is the basic xsl I was working from:

<?xml version='1.0' encoding='utf-8' ?>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <xsl:template match="kapitel/hanvisning">
     <xsl:copy>
	<xsl:value-of select="node()"/>
     </xsl:copy>
  </xsl:template>
</xsl:stylesheet>


If you respond to this, please be fairly descriptive, as I am very new to 
xsl.

Thanks in advance,
Trevor

_________________________________________________________________
Take charge with a pop-up guard built on patented Microsoft. SmartScreen 
Technology. 
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines 
  Start enjoying all the benefits of MSN. Premium right now and get the 
first two months FREE*.

Current Thread