Hello.
I'm in the midst of moving a web application from ASP.NET 1.1 to
ASP.NET 2.0 (framework 3.0), and as part of this move, I am told by
Visual Studio that the XslTransform object is now deprecated, and I
should use XslCompiledTransform. For the most part changing to this
object works fine, however I have noticed in some cases a difference
of behavior that breaks the proper running of my app.
I am using XSL templates to transform XML into HTML to be outputted to
the browser, and in some of my templates I have HTML "script" tags,
like so:
<script ...></script>
Using the old XslTransform object, this was handled just fine.
However, using the new XslCompiledTransform object, instances of these
script tags are reduced to single-tag versions in the output, like so:
<script ... />
Since this syntax is currently not valid HTML, browsers are not
correctly handling this output, and I get lots of javascript errors
and display problems.
Is this expected behavior by the new XslCompiledTransform object? Is
there any way to prevent it from doing this, or do I just need to keep
using the deprecated XslTransform instead?
Thanks!
--Steve
Martin Honnen - 04 Mar 2008 17:38 GMT
> I am using XSL templates to transform XML into HTML to be outputted to
> the browser, and in some of my templates I have HTML "script" tags,
[quoted text clipped - 7 lines]
>
> <script ... />
Make sure your stylesheet has
<xsl:output method="html"/>
and that script element is in no namespace.
If you still have problems then show us how you use XslCompiledTransform
exactly, you might need to make sure you use the OutputSettings property
of XslCompiledTransform:
<URL:http://msdn2.microsoft.com/en-us/library/System.Xml.Xsl.XslCompiledTransform.Out
putSettings.aspx>

Signature
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
steve.nickels@gmail.com - 05 Mar 2008 18:19 GMT
> steve.nick...@gmail.com wrote:
> > I am using XSL templates to transform XML into HTML to be outputted to
[quoted text clipped - 12 lines]
> <xsl:output method="html"/>
> and that script element is in no namespace.
Adding the xsl:output tag fixed the problem.
Thanks!
--Steve
David Greene - 04 Mar 2008 19:27 GMT
I put an <xsl:text> </xsl:text> (there is a "regular" space in there)
to force the </script> tag to show up.
I'm using <xsl:element name="script"> etc.
I would assume if you are writing the script tag directly you may have to
put at least a space or maybe a non-breaking space between the opening and
closing tag.
> Hello.
>
[quoted text clipped - 28 lines]
>
> --Steve