Re: [xsl] match text node

Subject: Re: [xsl] match text node
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Mon, 13 Oct 2003 07:19:08 -0700 (PDT)
> I have document like:
> <Descr>
>        valid html
> </Descr>
> "valid html" - I mean every html (xml-valid) you can imagine with no
> limitation at all. Of course, there are some texts. And there may be
> any nodes inside text and so on.
> 
> My task: I need to copy whole document (all nodes and all attributes)
> but in text nodes I need to delete all &#xA; marks.

You do not need sophisticated string-replacement locic to delete a single
character.

In a template matching any text node and overriding the identity rule use
the translate function like this:


<xsl:stylesheet version="1.0" 
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
 
 <xsl:output omit-xml-declaration="yes"/>
  
  <xsl:template match="node() | @*">
    <xsl:copy>
      <xsl:apply-templates select="node() | @*"/>
    </xsl:copy>
  </xsl:template>
  
  <xsl:template match="text()">
    <xsl:value-of select="translate(., '&#xA;', '')"/>
  </xsl:template>
</xsl:stylesheet>





=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

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


Current Thread