[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: dvint@xxxxxxxxx
Date: Wed, 17 Jun 2009 14:57:28 -0400
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.

I agree


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

Here is the line of XSLT that is creating this:

<xsl:for-each select="((../figList/tempChFigure))" >
     <span class="branch2" >
        <img>
           <xsl:attribute name="src">
               &#60;? echo(fldImg(2)) ?&#62;
          </xsl:attribute>
       </img>
    <a href="{@link}" target="mainFrame">
        <xsl:value-of select="@linkText"/>
    </a>
   </span>&#xA;
</xsl:for-each>

Sample source:

<figList>
         <tempChFigure child="false" linkText="1-1   Frontispiece"
link="./NonIPB/chap1-1.html#f0000001" number="2"/>
         <tempChFigure child="false" linkText="1-2  5-Inch 62-Caliber Gun
Mount Mk 45 Mod 4: Dimensions"
link="./NonIPB/chap1-1-1.html#f0000002" number="2"/>
         <tempChFigure child="false" linkText="1-3  5-Inch 62-Caliber Gun
Mount Mk 45 Mod 4: General Arrangement"
link="./NonIPB/chap1-1-2.html#f0000003" number="2"/>
         <tempChFigure child="false" linkText="1-4  Gun Laying System"
link="./NonIPB/chap1-1-2-2.html#f0000004" number="2"/>
</figlist>


I've tried changing the line in question to use
<xsl:processing-instruction> and I've also tried just assigning the
content to a variable and then using that directly as the value for the
src attribute like this:

<xsl:variable name="foo">&lt;? echo here ?></xsl:variable>

I can get you more content from the stylesheet, but its huge and I haven't
quite figured everything out yet.

Note that what is being created is a text file that is used by PHP. We are
in this case creating a set of files that are used to drive a table of
contents in a web browser.



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

That was a Visual Basic script that we are running.

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

I lied we are using v1.1, but I don't think that will make a difference.
Here is the start of the stylesheet:

<?xml version="1.0"?>
   <xsl:stylesheet
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      version="1.1">
   <xsl:output method="html"></xsl:output>

Thanks for the suggestion on v2. I'll probably have to leave it this way
as is (it works with the extra step of the VB script), I'll just add it to
the list of things I would improve. What I find strange is that this
process I inherited uses a combiantaion of OmniMark and XSLT. I'm
surprised that they didn't use OmniMark for this particular effort.

..dan

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