xsl-list
[Top] [All Lists]

match text node

2003-10-13 05:11:25
Hello,

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.

Template to delete &#xA; marks:
<xsl:template name="replace" match="text()" mode="replace">
        <xsl:param name="str" select="."/>
        <xsl:param name="search-for" select="'&#xA;'"/>
        <xsl:param name="replace-with">
                   <xsl:text/>
        </xsl:param>
        <xsl:choose>
                <xsl:when test="contains($str,$search-for)">
                        <xsl:value-of 
select="substring-before($str,$search-for)"/>
                        <xsl:copy-of select="$replace-with"/>
                        <xsl:call-template name="replace">
                                <xsl:with-param name="str" 
select="substring-after($str,$search-for)"/>
                                <xsl:with-param name="search-for" 
select="$search-for"/>
                                <xsl:with-param name="replace-with" 
select="$replace-with"/>
                        </xsl:call-template>
                </xsl:when>
                <xsl:otherwise>
                        <xsl:value-of select="$str"/>
                </xsl:otherwise>
        </xsl:choose>
</xsl:template>

The problem is I don't know how to apply it correctly.

Please, help me to solve this problem.

-- 
 Yours sincerely, Evgenia Firsova (saigo(_at_)nevatravel(_dot_)ru)
 ---------------------------------------------------
 NEVA Travel Company    http://www.nevatravel.ru/  
 Russia, St.Petersburg, 1st. Sovetskaya str. 8
 fax +7 (812) 327-3267  phone +7 (812) 277-4212


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



<Prev in Thread] Current Thread [Next in Thread>