xsl-list
[Top] [All Lists]

Re: [xsl] Entity escaping/translation

2009-06-17 14:14:47
At 2009-06-17 13:56 -0400, dvint(_at_)dvint(_dot_)com wrote:
I have a stylesheet I've inherited. We are currently using v1 with saxon.
I need to create the following output: <img src="<? echo(fldImg(2)) ?>">

Since that is not well-formed it cannot be created with XSLT 1. Even disable-output-escaping= cannot be used here because it is attribute content.

but the stylesheet is producing <img src="<? echo(fldImg(2)) ?&gt;">

I'm surprised you aren't getting:

  <img src="&lt;? echo(fldImg(2)) ?>">

... since the only sensitive character in that attribute sequence is the less-than.

Can you review your output? I cannot think of a way of getting the output you cite.

I tried switching the output type to text thinking that this would keep my
> from changing to &gt; Currently we are running a BB script on the output
file to do a regex on this pattern, and I would like to remove that step.

Then you will have to use XSLT 2 and character maps to get what you want.

I hope the example below helps as it shows your desired output being created.

. . . . . . . . Ken

t:\ftemp>type dan.xsl
<?xml version="1.0" encoding="US-ASCII"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                version="2.0">

<xsl:output use-character-maps="dan" omit-xml-declaration="yes"/>

<xsl:character-map name="dan">
  <xsl:output-character character="&#xffd0;" string="&lt;"/>
  <xsl:output-character character="&#xffd1;" string="&gt;"/>
</xsl:character-map>

<xsl:template match="/">
  <img src="&#xffd0;? echo(fldImg(2)) ?&#xffd1;"/>
</xsl:template>

</xsl:stylesheet>
t:\ftemp>xslt2 dan.xsl dan.xsl
<img src="<? echo(fldImg(2)) ?>"/>
t:\ftemp>


--
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman                 mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


--~------------------------------------------------------------------
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>
--~--