Re: XSL html entities

"Michael Kay" <[email protected]> Thu, 11 Dec 2008 10:20:59 -0000
Newsgroups gmane.text.xml.xslt.extensions
Message-ID <28EF5F92514A429EAA3D14CE37147E18@Sealion>
So, you don't want to replace the string "&lt;" by the character "<", you want to replace the string "<br/>" by a br element node.
 
You can do that in XSLT 2.0 using xsl:analyze-string, or in Saxon using the saxon:parse() extension. I don't think there's anything in EXSLT that will help you much. You'd be better asking on the xsl-list at mulberrytech.com
 
Michael Kay
http://www.saxonica.com/


  _____  

From: [email protected] [mailto:[email protected]] On Behalf Of Atul Shinh
Sent: 11 December 2008 10:07
To: [email protected]
Subject: [exslt] XSL html entities




Hi,

Thanks Michael for your response.
I am facing one critical issue. I am stuck in it for long time. 

I have an XML file, part of which looks like this
================ XML ========================
<kbs_prodgruppe_beschreibung> besonders sanft ab, ziehen sie leise ins Türschloß &lt; br/ &gt; und halten sie sicher geschlossen.
<kbs_prodgruppe_beschreibung>
========================================

So instead of 'break'  tag it is HTML entity for that in XML. I want to replace it with 'break' tag. Now I am trying like this
===========================================

1<xsl:variable name="after-replacement">
2   <xsl:call-template name="SEARCH-AND-REPLACE">
 3    <xsl:with-param name="string" select="$in"/>
4     <xsl:with-param name="search-for" select="&lt;"/>
5     <xsl:with-param name="replace-with" select="<"/>
.................

==================================
So when I am write '<' as in 5th line it throws an error:
XSLCmd :FATAL:   element type "null" must not contain the '<' character.�H�d�1E���e

So actually I feel that there is another way for replacing the HTML entities.

If you or anybody else  has any idea please respond.


Thanks and Regards
Atul 


On Thu, Dec 11, 2008 at 2:48 PM, Michael Kay <[email protected]> wrote:


You can call the template like this:
 
<xsl:variable name="after-replacement">
   <xsl:call-template name="SEARCH-AND-REPLACE">
     <xsl:with-param name="string" select="$in"/>
     <xsl:with-param name="search-for" select="&amp;lt;"/>
     <xsl:with-param name="replace-with" select="&lt;"/>
  </
</
 
Michael Kay
http://www.saxonica.com/


  _____  

From: [email protected] [mailto:[email protected]] On Behalf Of Atul Shinh
Sent: 11 December 2008 06:09
To: [email protected]
Subject: [exslt] XSL html entities


Hi all,

I am facing an problem with HTML entities in XSL processing. My XML file contains HTML entities like "&gt;", "&lt;"  (without quotes). So when I try to produce an PDF from this XML using an XSL file these entities are getting output as such, not being rendered as (< , >). 

So I tried using string-replace enhanced template
===================================================
 <xsl:template name="SEARCH-AND-REPLACE">
    <xsl:param name="string" />
    <xsl:param name="search-for" />
    <xsl:param name="replace-with" />
    <xsl:choose>
       <xsl:when test='contains($string,$search-for)'>
          <xsl:call-template name="SEARCH-AND-REPLACE">
             <xsl:with-param
                name="string"
                select='concat( substring-before($string,$search-for),
 $replace-with, substring-after($string,$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="$string" />
       </xsl:otherwise>
    </xsl:choose>
 </xsl:template>
======================================================

Is this approach right ?
If yes then how can I pass $string, $search.


Regards

_______________________________________________
exslt mailing list
[email protected]
http://www.exslt.org/list