Re: [xslt] Problems with xsl:text



Le 2001.10.11 15:09, Gero Meißner a écrit :
>     <xsl:attribute name="href">
>       <xsl:text disable-output-escaping="yes">
>         javascript:zoom('./zoom.html?file=abc.jpg&amp;width=300&amp;400');
>       </xsl:text>
>     </xsl:attribute>
[...]
> Using LibXML and LibXSLT the newly created document still contains the
> entity reference '&amp;' instead of the character '&'.

Please read the XSLT spec, 16.4 Disabling Output Escaping:
  It is an error for output escaping to be disabled for a text node that is
used for something other than a text node in the result tree. Thus, it is
an error to disable output escaping for an xsl:value-of or xsl:text element
that is used to generate a string-value of a comment, processing
instruction or attribute node [...] an XSLT processor may signal the error;
if it does not signal the error, it must recover by ignoring the
disable-output-escaping attribute.

> There are no problems when using xalan or saxon on MS Windows.

So they are broken, or at least not XSLT-compliant.

> Is there any possiblity to get the right character when using
> LibXML and LibXSLT?

It shouldn't be needed, a browser should translate the &amp; and pass an &
to the javascript engine. We're not responsible for broken browsers which
don't understand well-formed HTML...

<Off-Topic>
When you write links like the one above, please do not write
  <a href="javascript:func('url')">...</a>
which is not "portable" at all (not everyone has javascript enabled or a
javascript-enabled browser) but
  <a href="url" onclick="func(this.href)">...</a>

This way, you also get rid of your problem
</Off-Topic>

Tom.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]