I'm encountering some weird behavior in Umbraco 4.0.4.1, particularly when attempting to visualize any XSLT based on the "RSS Feed" template, including existing code borrowed from CWS: The browser generates an XML parsing error. Here's a picture from Firefox 3.6.6:
The location in question is /umbraco/developer/xslt/xsltVisualize.aspx?rndo=22.8 The code to which it refers is the first html.replace instruction in this segment of the ASP file:
function encodeDecodeResult(isChecked) { var html = jQuery("#result").html(); if (isChecked) { jQuery("#result").html( html.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\n/g,"<br/>").replace(/\r/g,"")); } else { jQuery("#result").html( html.replace(/<BR>/g, "\n").replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>'));
Firefox is pointing to the /&/g, which looks perfectly legitimate to me -- the code replaces lone ampersands with the & token. It's a familiar passage to anyone who's ever tried to "escape" HTML characters, and I don't actually see an error here.
Trouble is, the problem's not just with Firefox. Here's the same error cropping up in Google Chrome 5.0.360.4:
IE8 doesn't show an error; it just visualizes nothing. Which is perhaps what it's supposed to do. In any event, I sincerely doubt that the xsltVisualize.aspx file is actually in error here; but once I realize what it may be that I'm doing to cause this problem, I'll learn something valuable about Umbraco. My thanks to all out there for any clues you can give me.
I don't know why it's happening, but the error is a crystal clear XML validation-error - the browser is fed something it thinks is XML, and a lone ampersand is top-priority no-no in XML, so complaining ensues... as to why the page is served as XML - have no clue... can you see the HTTP headers with Firebug or the Developer tools in Chrome/Safari?
A question you should ask yourself: Do you really need that javascript code to be in your XSLT file? This looks like something that could (and should) be in an external javascript file.
@Sebastiaan: As I understand it, the error seems to be that the xsltVisualizer.aspx file gets interpreted as XML by the browser(s) - which triggers the error in the JavaScript for the Encode/Decode result checkbox... so I don't think he's having any JavaScript in the XSLT...
just comment it out for the visualization - although you shouldn't be visualizing, as the RSS feed isn't HTML.
Basically that line changes the content type of the response to be text/xml, which means that unescaped ampersands are invalid, and should cause an error (strict XML). If you get rid of it, everything will be OK for visualizations, but the content type of your feed will be wrong so certain applications consuming it might get upset.
Bingo. Yes, Josh, that's the ticket. Commented that line out, feed visualizes as planned. Thank you very much!
Suggestion for Umbraco developers: The Visualize Feed page is currently set up to automatically visualize whatever it last visualized; and browsers tend to show error pages (like the one in the screenshot) that overwrite the entire window. Perhaps in the toolbar next to the Visualize XSLT button, someone could add a "Reset Visualizer" button that would perform the same general function as the Delete link in the Visualizer window. Otherwise, browsers like Firefox will be stuck in a rut.
Also, perhaps for future editions of the "RSS Feed" template, the ChangeContentType line could be automatically commented out, with a message that says something like, "<!-- Uncomment this instruction when development is complete -->"
XML parsing error in RSS feed XSLT
Greetings, folks:
I'm encountering some weird behavior in Umbraco 4.0.4.1, particularly when attempting to visualize any XSLT based on the "RSS Feed" template, including existing code borrowed from CWS: The browser generates an XML parsing error. Here's a picture from Firefox 3.6.6:
The location in question is /umbraco/developer/xslt/xsltVisualize.aspx?rndo=22.8 The code to which it refers is the first html.replace instruction in this segment of the ASP file:
Firefox is pointing to the /&/g, which looks perfectly legitimate to me -- the code replaces lone ampersands with the & token. It's a familiar passage to anyone who's ever tried to "escape" HTML characters, and I don't actually see an error here.
Trouble is, the problem's not just with Firefox. Here's the same error cropping up in Google Chrome 5.0.360.4:
IE8 doesn't show an error; it just visualizes nothing. Which is perhaps what it's supposed to do. In any event, I sincerely doubt that the xsltVisualize.aspx file is actually in error here; but once I realize what it may be that I'm doing to cause this problem, I'll learn something valuable about Umbraco. My thanks to all out there for any clues you can give me.
Yours,
/&/gScott Fulton &third;
Hi Scott,
I don't know why it's happening, but the error is a crystal clear XML validation-error - the browser is fed something it thinks is XML, and a lone ampersand is top-priority no-no in XML, so complaining ensues... as to why the page is served as XML - have no clue... can you see the HTTP headers with Firebug or the Developer tools in Chrome/Safari?
/Chriztian
A question you should ask yourself: Do you really need that javascript code to be in your XSLT file? This looks like something that could (and should) be in an external javascript file.
@Sebastiaan: As I understand it, the error seems to be that the xsltVisualizer.aspx file gets interpreted as XML by the browser(s) - which triggers the error in the JavaScript for the Encode/Decode result checkbox... so I don't think he's having any JavaScript in the XSLT...
/Chriztian
Ah yes, I see now. :) Would be good to see the xslt source to see what might be wrong.
If you're using the RSS Feed template, you can't visualize it with the following line left in:
just comment it out for the visualization - although you shouldn't be visualizing, as the RSS feed isn't HTML.
Basically that line changes the content type of the response to be text/xml, which means that unescaped ampersands are invalid, and should cause an error (strict XML). If you get rid of it, everything will be OK for visualizations, but the content type of your feed will be wrong so certain applications consuming it might get upset.
/Josh
Bingo. Yes, Josh, that's the ticket. Commented that line out, feed visualizes as planned. Thank you very much!
Suggestion for Umbraco developers: The Visualize Feed page is currently set up to automatically visualize whatever it last visualized; and browsers tend to show error pages (like the one in the screenshot) that overwrite the entire window. Perhaps in the toolbar next to the Visualize XSLT button, someone could add a "Reset Visualizer" button that would perform the same general function as the Delete link in the Visualizer window. Otherwise, browsers like Firefox will be stuck in a rut.
Also, perhaps for future editions of the "RSS Feed" template, the ChangeContentType line could be automatically commented out, with a message that says something like, "<!-- Uncomment this instruction when development is complete -->"
Thanks again, Josh, you've helped a lot.
<!-- Scott -->
is working on a reply...