views:

40

answers:

2

I'm currently in the process of updating a (lot of) old xsl+html code to render xhtml compliant code but am running up against a problem where pages include inline javascript. Some of the javascript can be removed from being inline and placed into linked js files.

However, there are a number of places where xsl elements are used inside the javascript.

When viewing the output in a browser, the rendering seems to stop at where the javascript appears in the source (the source is generated fine).

I have tried all the usual CDATA and xsl:comment hacks around these javascript blocks but still the same result.

Any help on this one would be appreciated. Please ask if you need any further information.

+1  A: 

Try running the transformed page through an XML validator. This would at least tell you if its a XML compliance or a browser compatibility issue. Without seeing the transformed code its hard to diagnose what's going on. Your issue could be related to a Javascript error or invalid XML. Also the browser itself could be processing the XSLT incrementally and rendering as you didn't specify if the transform was being done prior to render or as part of the render. The best way to get to the bottom is to pull apart the pieces. run the XSLT thru a compliant XSLT processor to make sure the XSLT is valid. Then run its output thru an XML validator to make sure you're not getting any XML validation errors. Finally, run the XSLT output through an XHTML verifier. If all of these steps succeed then you could be facing something as simple as a Javascript error.

Cliff
Many thanks. You've added some extra steps in for my troubleshooting. I'll get back to you once I've picked about some more.What is puzzling me is that all the pages rendered correctly before the addition of the xhtml headers in the html code and directives for the xsl. I can tell you that the transform is done server-side and passed complete to the browser. I'll try to pull together an example to better explain the issue.
Rob Wood
A: 

After an (enforced) break from this task, I have revisited and found the error that was preventing the browser rendering the content correctly. The XSL was outputting iframe and script elements incorrectly as self-closing tags. To prevent this happening, I have forced some white-space into the element using <xsl:text> </xsl:text>.

Thanks for your help and suggestions.

Rob Wood