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

Re: Entity escaping/translation

Subject: Re: Entity escaping/translation
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 17 Jun 2009 11:07:15 -0700
Re:  Entity escaping/translation
At 2009-06-17 13:56 -0400, dvint@xxxxxxxxx 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@xxxxxxxxxxxxxxxxxxxx Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal

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.