Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / March 2008

Tip: Looking for answers? Try searching our database.

XslCompiledTransform behaves differently than XslTransform

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
steve.nickels@gmail.com - 04 Mar 2008 17:18 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.