xsl-list
[Top] [All Lists]

[xsl] outputting ampersand to its actual character

2006-09-05 02:38:19
Hi,
I am processing a text file (for each line) in this format:

\0061\00E0=\1F05

\0065\00E0=\1F15

I will then create a variable of type element because I would use it in a find and replace function.
In my variable I have to convert these lines to:
<entry><search>&#x0061;&#x00E0;</search><replace>&#x1F05;</replace></entry>
<entry><search>&#x0065;&#x00E0;</search><replace>&#x1F15;</replace></entry>
and my problem is, whenever is try to replace '\' with an &#x62;#x I end up with &amp;#x

As you know, my find and replace function will not work for that. Is there a work around for this?

Btw, I am using Saxon and XSLT 2.0. Also this is my code:

xsl:variable name="ref_string" as="xs:string*">
<xsl:analyze-string select="unparsed-text('sgreek.txt','utf-8')" regex="[\r\n]">
       <xsl:non-matching-substring>
           <xsl:value-of select="replace(.,'\\([A-F0-9]{4})','&amp;$1;')"/>
       </xsl:non-matching-substring>
   </xsl:analyze-string>
</xsl:variable>
<xsl:variable name="sfont" select="substring-before($ref_string[position()=1],' ')"/>
<xsl:variable name="ref">
   <xsl:element name="{$sfont}">
   <xsl:for-each select="$ref_string">
       <xsl:choose>
           <xsl:when test="position()=1"/>
           <xsl:otherwise>
               <xsl:element name="entry">
<xsl:variable name="str1" as="xs:string*" select="tokenize(.,'=')"/>
                   <xsl:element name="search">
                       <xsl:value-of select="$str1[1]"/>
                   </xsl:element>
                   <xsl:element name="replace">
                       <xsl:value-of select="$str1[2]"/>
                   </xsl:element>
               </xsl:element>
           </xsl:otherwise>
       </xsl:choose>
   </xsl:for-each>
   </xsl:element>
</xsl:variable>

Thanks,
Carlo



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

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