Quantcast
Channel: Internet Explorer Web Development forum
Viewing all articles
Browse latest Browse all 3527

Internet Explorer adding line feeds with XSL processor

$
0
0

Hi,

Just as some background I have an application that in part takes an XML fragment and processes this with an XSL template to give me an HTML output.

In order to get this to work in IE, I have added this block of code:

    var ua = window.navigator.userAgent;
        var msie = ua.indexOf("MSIE ");
        if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) {
            var xslt = new ActiveXObject("Msxml2.XSLTemplate");
            var zxsl_activex = new ActiveXObject("Msxml2.FreeThreadedDOMDocument");
            zxsl_activex.async = false;
            zxsl_activex.load("/ZymonicBlockCombined.xsl");
            xslt.stylesheet = zxsl_activex;
            var xsl_proc = xslt.createProcessor();
            if ( xml instanceof Document ) { xsl_proc.input = xml; }
            else { xsl_proc.input = xml.ownerDocument; }
            xsl_proc.transform();
            return document.createRange().createContextualFragment(xsl_proc.output);

The issue I have with this is that the string which is converted to a fragment (xsl_proc.output) has random line feeds in it, which must be added somewhere during that transform() function. For example, when you view the string in the console, it looks like this:

alidationResults.push(basic_validation("1453_dept_id","Area

2-Digit ID","char","",2,["[[display_name]]

The implication of this of course is that when the browser attempts to insert this fragment into the page and run the script, you get an 'Unterminated string constant' error.

The question is - is there a way to prevent the transform() function adding extra line feeds?

I'd like to point out that the input xml object does NOT have these additional line feeds, and the output from the FireFox XSLTProcessor doesn't either.

I've also tried stripping out line feeds from the string (that's pretty straightforward) but of course there's no way to determine if the linefeed was in the 'original' xml, or if it was one of the additional ones, so that won't work either.


Viewing all articles
Browse latest Browse all 3527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>