This isn't an "[Announce]".    OK, I got that off my chest.

Assuming that you are using Xalan to do your serialization, one of the
fundamental problems you are probably having is that Xalan has decided to
output all attribute values surrounded by double quotation marks, " ,  not
single quotation marks, ' .   That decision is pretty deep in the code.
This way when it encounters a double quote in the value of the attribute
value it will escape it as " (doing its best to retain the validity of
the output being generated.

Of course there are plenty of ways to generate invalid HTML or XML with any
XSLT processor and <![CDATA[ ...    ]]> comes to mind, where you can put
just about anything in there, including unpaired less than signs.

Assuming that you are only interested in stream serialization, have you
thought of doing the serialization yourself for particular elements?  For
example, something like 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>

I think this needs polishing, but it has hope.

- Brian



                                                                           
             caporale                                                      
             <[EMAIL PROTECTED]                                             
             il.com>                                                    To 
                                       general@xml.apache.org              
             10/23/2007 05:20                                           cc 
             PM                                                            
                                                                   Subject 
                                       [Announce] Escaping double          
             Please respond to         quotation marks in XSL              
             [EMAIL PROTECTED]                                             
                   e.org                                                   
                                                                           
                                                                           
                                                                           
                                                                           





I have XSL inside Javascript.  The XML looks like this:
<image>imagename.jpg</image>.  Any time that tag's there, the output should
be &lt;img src=\"imagename.jpg\" / &gt;.  This template works, but it
doesn't escape the quotation marks:

<xsl:template match="image">

<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


--
View this message in context:
http://www.nabble.com/Escaping-double-quotation-marks-in-XSL-tf4680435.html#a13373968

Sent from the Apache XML - General mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to