Subject: RE: [xsl] match text node From: "Jim Fuller" <jim.fuller@xxxxxxxxxxxxxxxxxx> Date: Mon, 13 Oct 2003 13:48:58 +0100 |
-----Original Message----- From: saigo@xxxxxxxxxxxxx [mailto:saigo@xxxxxxxxxxxxx] Sent: 13 October 2003 13:11 To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx Subject: [xsl] match text node 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 
 marks. ---------------------------------------------------------------------------------------------------------------------------------------- try something like this, you need to apply-templates then do an identify transform, your call template naturally matches text() so its fine. I also removed the mode attribute for replace template...not needed. <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template name="replace" match="text()"> <xsl:param name="str" select="."/> <xsl:param name="search-for" select="'
'"/> <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> </xsl:stylesheet> untested, and make sure you look at the raw output to ensure that they have indeed been replaced I would put a visible value in e.g. <xsl:param name="replace-with"> testing testing <xsl:text/> </xsl:param> good luck, Jim Fuller XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] match text node, Евгения Фирсова | Thread | Re: [xsl] match text node, Dimitre Novatchev |
[xsl] match text node, Евгения Фирсова | Date | RE: [xsl] Re: XSLT 2.0: On xsl:sequ, Michael Kay |
Month |