This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

BOUNCE xsl-list@lists.mulberrytech.com: Admin request of type/\bremove\b/i at line 3


>From mail@jenitennison.com  Thu Jan 11 04:51:04 2001
Received: from bravo.whitburn.xcalibre.co.uk 
(mail@bravo.whitburn.xcalibre.co.uk [194.201.48.11])
	by biglist.com (8.8.8/8.8.5/BL-2) with ESMTP id EAA13550
	for <xsl-list@lists.mulberrytech.com>; Thu, 11 Jan 2001 
04:51:04 -0500 (EST)
Received: from [194.88.81.28] (helo=TIFERET)
	by bravo.whitburn.xcalibre.co.uk with esmtp (Exim 3.15 #1)
	id 14GeAs-00045v-00; Thu, 11 Jan 2001 09:37:39 +0000
Date: Thu, 11 Jan 2001 09:46:18 +0000
From: Jeni Tennison <mail@jenitennison.com>
X-Mailer: The Bat! (v1.49) Business
Reply-To: Jeni Tennison <mail@jenitennison.com>
Organization: Jeni Tennison Consulting Ltd
X-Priority: 3 (Normal)
Message-ID: <462488197.20010111094618@jenitennison.com>
To: "Devlin, Kurt" <Kurt.Devlin@westgroup.com>
CC: xsl-list <xsl-list@lists.mulberrytech.com>
Subject: Re: [xsl] BOUNCE xsl-list@lists.mulberrytech.com:     Admin 
request of type /\bremove\b/i at line 1
In-reply-To: <a05001908b682f40144ff@[63\.48\.105\.105]>
References: <a05001908b682f40144ff@[63.48.105.105]>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi Kurt,

>  I need to remove some PCDATA prior to a specified element. I am
>  rendering my XML to HTML. In the main section I want all the
>  information shown. In the table of references that gets generated at
>  the end of the document, I want to strip certain elements and the
>  PCDATA that appears directly before that element.
>
>  Currently, I have templates that ignore the elements that I'm not
>  interested, but I'm not sure how to get to the PCDATA before this
>  element.

You can match text() whose immediately following sibling is a foo
element using the match pattern:

   text()[following-sibling::node()[1][self::foo]]

Put that in an empty template, and it will ignore all those text
elements:

<xsl:template match="text()[following-sibling::node()[1][self::foo]]"
               mode="ToC" />

If you have more elements whose immediately preceding text you want to
ignore, then you can add them to the predicate:

   text()[following-sibling::node()[1]
           [self::foo or self::bar or self::baz]]

So you can get rid of text for all these elements using just one
template.

You say:
>  I have created a simple example of what I want to do below. In this
>  example it would be simple to just look at the elements that I do
>  want, but in my real project there are too many elements that I do
>  want. I really only want to add a couple of templates to handle
>  ignoring the element and its preceding PCDATA.

If you want to select all elements aside from a chosen few, you can
use the same kind of syntax, using the self:: axis.  For example, the
following selects all elements that aren't foo, bar or baz elements.

   <xsl:apply-templates
     select="*[not(self::foo or self::bar or self::baz)]"
     mode="ToC" />

This is slightly better (I think) than applying templates to all the
elements and having empty templates that match those you don't want
because it narrows down the nodes that the templates are applied to
early on.

I hope that helps,

Jeni

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

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]