[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: how to translate entities with XSL

Subject: Re: how to translate entities with XSL
From: Mike Brown <mike@xxxxxxxx>
Date: Thu, 8 Jun 2000 15:19:12 -0600 (MDT)
xsl translate br
> I know this is probably bad form, but this is the way I get the xml.
> There isn't an easy way to change this.

OK.

> disable-output-escaping works if the symbols aren't already escaped in the
> xml itself.  For instance, if I use the following xml and xsl, I get: 
> 
> output test <br/> this should be on the next line 
> 
> instead of: 
> 
> output test 
> this should be on the next line 
>
> [xml with "output test &lt;br/&gt; this should be on the next line"]
> [xsl that copies it with output escaping disabled]

What you are getting is what you asked for. Do you want to get rid of the
5 characters < b r / > entirely, replacing them with a single newline
character, mimicking the behavior of an HTML processor? (Not completely
accurate, as surrounding whitespace factors in..)

If so, then instead of value-of @html, use apply-templates @html, with
this derivative of a Michael Kay contribution to the FAQ:

<xsl:template match="@html">
  <xsl:call-template name="break"/>
</xsl:template>

<xsl:template name="break">
  <xsl:param name="text" select="."/>
  <xsl:variable name="br" select="'&lt;br/&gt;'"/>
  <xsl:choose>
    <xsl:when test="contains($text,$br')">
      <xsl:value-of select="concat(substring-before($text,$br),'&#xA;')"/>
      <xsl:call-template name="break">
        <xsl:with-param name="text" select="substring-after($text,$br)"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$text"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.