[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Using xsl:variable and replace() to remove specifi

Subject: Re: Using xsl:variable and replace() to remove specific characters.
From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Mon, 28 Apr 2008 13:17:43 +0100
Re:  Using xsl:variable and replace() to remove specifi
On 28/04/2008, Richard Corfield <richard.corfield@xxxxxxx> wrote:
>   <label>2</label>National Radio Astronomy Observatory, Chile<xref ref-type="fn" rid="aj266199afn4"><sup>9</sup></xref>; <ext-link ext-link-type="email" id="aj266199em4">email address here</ext-link>
>  </aff>

>  The problem is the trailing semi-colon between the <xref> & <ext-link> elements.

If it's exactly that problem and those elements can occur anywhere you can do:

<xsl:template match="text()[preceding-sibling::*[1][self::xref]]
        [following-sibling::*[1][self::ext-link]
        [normalize-space(.) eq ';'"]"/>

...which is a no-op template for text node that only occur between
<xref> and <ext-link> elements with a value of a colon possibly
nestled amongst some whitespace.

You will have to ensure you always use <xsl:apply-templates/> instead
of <xsl:value-of select="..."/> when outputting the value of an
element otherwise the template won't get fired (that's always good
practice anyway)

If you only ever want to remove the colon from within certain elements
(like <aff> above) then modify the match to be:

match="aff/text()"....

to prevent the text() matching template firing for all text() nodes,
which might be expensive.

-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Cast Your Vote

We need your help – Vote for DataDirect XML Products!

  • Best SOA or XML site

Winners and finalists announced at SOA World Conference in November.

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.