xsl-list
[Top] [All Lists]

Re: [xsl] Using xsl:variable and replace() to remove specific characters.

2008-04-28 05:24:52
On 28/04/2008, Richard Corfield <richard(_dot_)corfield(_at_)iop(_dot_)org> 
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/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--