On Friday, February 02, 2001 11:21 AM
Andrew C.R. Martin wrote:
> On Thu, 01 Feb 2001, chad wrote:
> >
> > How can I tell sablotron to ignore xml elements that are not
defined in the xsl stylesheet?
[..]
> >
>
> The following does it for me:
>
> <xsl:stylesheet
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">
>
> <xsl:template match="person">
> <xsl:value-of select="name" />
> </xsl:template>
> </xsl:stylesheet>
>
> Providing you match the person element, then all child elements will
only get
> output if you specifically call them.
That's true of course, but many people follow the practice of an
initial match on the document root, which causes the default template
to be applied to any elements that aren't given a specific matching
template. And in the current spec (the opposite of the old MS one)
the default template behaviour is to output the text content of those
elements. The most general solution to this is to follow your match
on the root by a catch-all do-nothing template for everything other
than the specific elements for which you do provide templates.
That can also help debug obscure problems if you alter your
catch-all template to output something like UNHANDLED ELEMENT
followed by the current node name.
Amazing what that turns up sometimes...
Michael
------------------------------------------
Michael Beddow
http://www.mbeddow.net/