Timothy,
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[ >]>>
</xsl:template>
<!-- handle src attribute of an image element -->
<xsl:template match="image/@src>
<![CDATA[ src=\"]>><value-of select="."><![CDATA[\"]>>
</xsl:template>
Note in the template rule for the src attribute, the leading CDATA has
src=\"
and the losing CDATA has \"
which is the injected and escaped (backslash before each one) double
quotes.
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
should
> be <img src=\"imagename.jpg\" / >. This template works, but it
> doesn't escape the quotation marks:
>
> <xsl:template match="image">
> <img>
> <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: [EMAIL PROTECTED]
"Timothy Jones"
<[EMAIL PROTECTED]
niverse.com> To
Brian Minchau/Toronto/[EMAIL PROTECTED]
10/24/2007 12:52 cc
PM <[email protected]>,
<[EMAIL PROTECTED]>,
<[EMAIL PROTECTED]>
Subject
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 &. Since = -> " is a similar encoding to
& -> &, wouldn't this help?
I apologize if I am missing the point...
tlj
-----Original Message-----
From: Brian Minchau [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 24, 2007 12:31 PM
To: Timothy Jones
Cc: [email protected]; [EMAIL PROTECTED];
[EMAIL PROTECTED]
Subject: RE: [Announce] Escaping double quotation marks in XSL
Timothy,
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 " which is not what the user wanted.
- Brian
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]