At 05:18 PM 3/7/2003, Mike wrote:
In XSLT you copy the things you want to keep from the source document to
the result document. If there's an element you don't want in the result,
then don't copy it. "Delete" implies that you have to do something to
get rid of an element: you don't need to do anything, in fact, you need
to do nothing.
To put this together with the solution just offered -- an identity template
along with a template matching the unwanted element that "does nothing",
remember that by default (by means of built-in templates, just mentioned in
another thread)
Elements are not copied, but their contents (descendants) are processed
Text nodes are copied (or: their values are reported)
So if your stylesheet is truly a "null stylesheet" (that is, has no
templates at all) what you get back is the whole source tree, with all the
elements gone (since element nodes were not copied though their children
were processed) but the text there (since the values of text nodes were
copied). Written out it looks a lot like <xsl:value-of select="/"/> -- the
whole source with all the markup gone.
What happens anyway, without your having to ask for it, is a frequent
source of confusion for beginning XSLTers; but it's not hard to understand
once you're clued into it.
And in this case, "doing nothing" means including a template that does
nothing. A zen koan: what is the sound of an empty template matching?
Cheers,
Wendell
___&&__&_&___&_&__&&&__&_&__&__&&____&&_&___&__&_&&_____&__&__&&_____&_&&_
"Thus I make my own use of the telegraph, without consulting
the directors, like the sparrows, which I perceive use it
extensively for a perch." -- Thoreau
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list