Re: [xsl] Selecting a descendant child at arbitrary depth

Subject: Re: [xsl] Selecting a descendant child at arbitrary depth
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Wed, 14 Mar 2001 09:57:38 +0000
Hi Peter,

> Now, I have invented a tag called <docBody> which surrounds the
> XHTML that I am actually interested in. What I want to do is copy
> the contents of the <docBody> to the output, but ignore anything
> else that surrounds it:

It should work if you just have:

  <xsl:template match="mainDisplay">
    <xsl:copy-of select=".//docBody/*" />
  </xsl:template>

If that doesn't work, then I'd suspect a namespace issue (i.e. the
docBody in the source XML is actually in a default namespace but
you're trying to find one in the null namespace).  Either that or the
docBody doesn't have any element content - you might try:

  <xsl:template match="mainDisplay">
    <xsl:copy-of select=".//docBody/node()" />
  </xsl:template>

instead.

Or, possibly, you have some other template around that's matching the
docBody with greater priority.  If you use the above you'll get round
that - as long as the mainDisplay template matches then the copy
should be made.

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread