Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - XSLT string replacement question [Thread Next] Re: XSLT string replacement questionTo: NULL Date: 6/2/2004 2:25:00 AM In article <af913759.0406011546.1feda850@p...>, J Trost <jt6211@e...> wrote: % I was wondering if anyone knows if it is possible to do basic string % replacement using XSLT even though the strings being replaced may % contain "<" and ">". Here is my problem: What you're doing isn't really string replacement, since the things that need replacing aren't available to the style sheet as strings. % <?xml version="1.0" encoding="UTF-8"?> I don't think the XML declaration is available to XSLT at all. % <java version="1.4.2_03" class="java.beans.XMLDecoder"> For the other things, you could do something like <xsl:template match="*"> <xsl:text>&lt;</xsl:text> <xsl:value-of select='name()'/> <xsl:for-each select='@*'> <xsl:text> </xsl:text> <xsl:value-of select='name()'/> <xsl:text>="</xsl:text> <xsl:value-of select='.'/> <xsl:text>"</xsl:text> </xsl:for-each> <xsl:text>&gt;</xsl:text> <xsl:apply-templates/> <xsl:text>&lt;/</xsl:text> <xsl:value-of select='name()'/> <xsl:text>&gt;</xsl:text> </xsl:template> This will not give you your original document with <, &, and > replaced by entities, but it ought to give you an equivalent document. I wouldn't even consider using XSLT for this task, by the way. -- Patrick TJ McPhee East York Canada ptjm@i... | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
