This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: how to translate entities with XSL


> 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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]