Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: XSLT string replacement question

From: ptjm@--------.--- (------- -- ------)
To: 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>&amp;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>&amp;gt;</xsl:text>
   <xsl:apply-templates/>
   <xsl:text>&amp;lt;/</xsl:text>
   <xsl:value-of select='name()'/>
   <xsl:text>&amp;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...


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent