xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Minchau <minc...@ca.ibm.com>
Subject RE: [Announce] Escaping double quotation marks in XSL
Date Wed, 24 Oct 2007 21:22:55 GMT
the original detested example was this:

<!-- self serialization of image elements with tag for image done in CDATA,
but delegate attributes serialization -->
<xsl:template match="image">
 <![CDATA[ <image]>><xsl:apply-templates select="@*"/> <![CDATA[ >]>>

<!-- handle src attribute of an image element -->
<xsl:template match="image/@src>
<![CDATA[  src=\"]>><value-of select="."><![CDATA[\"]>>

Note in the template rule for the src attribute, the leading CDATA has
and the losing CDATA has  \"
which is the injected and escaped (backslash before each one) double

Joseph Caporale: are you still following this thread? You started it going.

caporale wrote:
> I have XSL inside Javascript.  The XML looks like this:
> <image>imagename.jpg</image>.  Any time that tag's there, the output
> be &lt;img src=\"imagename.jpg\" / &gt;.  This template works, but it
> doesn't escape the quotation marks:
> <xsl:template match="image">
> &lt;img&gt;
> <xsl:attribute name="src">
> <xsl:apply-templates />
> </xsl:attribute>
> </img>
> </xsl:template>
> What do I need to do to escape the quotation marks from that?  I've seen
> about 400 examples on-line--none of which actually do what I want.
> Thanks,
> Joseph Caporale

- Brian
- - - - - - - - - - - - - - - - - - - -
Brian Minchau, Ph.D.
XSLT Development, IBM Toronto
(780) 431-2633
e-mail:        minchau@ca.ibm.com

             "Timothy Jones"                                               
             niverse.com>                                               To 
                                       Brian Minchau/Toronto/IBM@IBMCA     
             10/24/2007 12:52                                           cc 
             PM                        <general@xml.apache.org>,           
                                       RE: [Announce] Escaping double      
                                       quotation marks in XSL              

In the detested example
    > <xsl:template match="image">
    >  <![CDATA[ <image]>><xsl:apply-templates select="@*"/> <![CDATA[
    > </xsl:template>
I didn't see any attempt to inject double quotes (I'll even admit to not
reading the subject line!).

But for inserting arbitrary characters (even metacharacters) without
escaping, maybe the disable-output-escaping attribute of <xsl:value-of> and
<xsl:text> would be useful.  In my application I have an XSL-generated HTML
page with hyperlinks with GET parameters, and I use <xsl:value-of
disable-output-escaping='yes'> to prevent the & characters in my GET URLs
from being converted to &amp;.  Since = -> &quot; is a similar encoding to
& -> &amp;, wouldn't this help?

I apologize if I am missing the point...

-----Original Message-----
From: Brian Minchau [mailto:minchau@ca.ibm.com]
Sent: Wednesday, October 24, 2007 12:31 PM
To: Timothy Jones
Cc: general@xml.apache.org; tranceradi@hotmail.com;
Subject: RE: [Announce] Escaping double quotation marks in XSL

well, .... yes, .... but I think that trying to inject double quotes into
the attribute value (with modifications to you suggestion)  in this way
will only get them escaped as &quot; which is not what the user wanted.

- Brian

To unsubscribe, e-mail: general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org

View raw message