3

I have following StyleSheet information in a XSLT file located in my project directory, am reading this file and storing it inside a TextArea in HTML and then later i read the Textarea using javascript.

When i read the Text Area in IE9+ browsers using document.getElementByID("TestAreaID").value, it automatically removes the name spaces and hence am unable to Generate a PDF in IE9+ browsers. when i add the namespaces in debug mode then it is opening in IE9+ browsers.

<textarea id="TestAreaID>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:fo="http://www.w3.org/1999/XSL/Format"
        xmlns:fox="http://xmlgraphics.apache.org/fop/extensions"
        xmlns:svg="http://www.w3.org/2000/svg"
        xmlns:java="http://xml.apache.org/xslt/java"
        xmlns:xalan="http://xml.apache.org/xalan"
        xmlns:barcode="http://barcode4j.krysalis.org/ns"
        xmlns:pagematrix="http://phi.thc.com/pagematrix"
        xmlns:math="xalan://java.lang.Math" extension-element-prefixes="math" version="1.1">

        <xsl:output method="xml" omit-xml-declaration="no" indent="yes" version="1.0" doctype-system="http://www.w3.org/TR/2000/CR-SVG-20000802/DTD/svg-20000802.dtd" doctype-public="-//W3C//DTD SVG 20000802//EN"/>
</textarea>

After reading the Text Area in javascript using document.getElementByID("TestAreaID").value, only below informations are returned

 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" extension-element-prefixes="math" version="1.1">

        <xsl:output method="xml" omit-xml-declaration="no" indent="yes" version="1.0" doctype-system="http://www.w3.org/TR/2000/CR-SVG-20000802/DTD/svg-20000802.dtd" doctype-public="-//W3C//DTD SVG 20000802//EN"/>

Am confused why it is not reading the TextArea value fully and omitting some namespaces, but it working fine in Chrome,FireFox nd IE8 browser.

Below is the HTML code

<textarea id="TestAreaID" name="TestAreaID_index_0" style="display:none">
  $formInputData.getField("PrintControl").getValue()
</textarea>

getField() is a static method which reads and returns the xsl file contents,,This returns the xsl file contents properly, but when i read it in javascript namespaces are removed

This is what we have in javascript part

 var xmlText = document.getElementById("TestAreaID").value;                                             

  xmlText = xmlText.replace(/~1/g, "~");  // This gets set back to ampersand later
  xmlText = xmlText.replace(/~2/g, "<");


  if (window.DOMParser)
  {
    parser=new DOMParser();
    _xmlDoc=parser.parseFromString(xmlText,"text/xml");
  }
  else // Internet Explorer
  {
    _xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
    _xmlDoc.async="false";
    _xmlDoc.loadXML(xmlText); 
  }
document.getElementById("TestAreaID").value = xmlText;
user2918673
  • 141
  • 1
  • 9
  • Can you show the code "reading this file and storing it inside a TextArea in HTML"? It is not clear which platform you use for that, is that also done using Javascript inside the browser or on the server? – Martin Honnen Jul 11 '16 at 08:08
  • The code which read the xsl file and placing it inside the TextArea Tag is done properly i verified in IE9 browser but when i try to read this using javascript some namespace tags are missing – user2918673 Jul 11 '16 at 08:35
  • If it is only a HTML and Javascript problem then please add minimal but complete executable code snippets directly in your question allowing us to reproduce the problem. I see no problem in https://jsfiddle.net/1sn1cwk9/ and IE 11 on Windows 10. – Martin Honnen Jul 11 '16 at 08:49
  • It is working in IE9+ browsers ,in compatibility mode but not in the standard mode – user2918673 Jul 11 '16 at 08:53
  • https://jsfiddle.net/1sn1cwk9/ works fine in IE 11 in standards mode so please provide a minimal but complete sample that allows us to reproduce the problem or if you don't want us to do that then go ahead and file a bug on IE if you think you have found one. – Martin Honnen Jul 11 '16 at 08:58
  • Added the HTML code Martin.. The real code is about 1000 lines , hence am just sharing the part which has the XSL file contents alone – user2918673 Jul 11 '16 at 09:11
  • I meant my actual code is working in Compatibility mode and not in standard mode,,jsFiddle example works in both the modes thanks for trying – user2918673 Jul 11 '16 at 09:15
  • Martin i looked in to your post for dropping namespaces in IE9 http://stackoverflow.com/questions/11398813/either-domparser-or-xmlserializer-is-dropping-my-namespace-declaration-in-ie9 – user2918673 Jul 11 '16 at 09:46
  • Are you using DOMParser and XMLSerializer? So far you have only told us that you read out the value of a textarea. And it seems Microsoft has not fixed that issue in IE so I am not sure what we on stackoverflow could do anyway. If your current code works in compat mode then you might be forced to use that if there is really a problem in IE in standards mode. – Martin Honnen Jul 11 '16 at 10:25
  • I have added the javascript code to the question – user2918673 Jul 11 '16 at 10:44
  • But parsing concept will come into picture if actually reading an xml file..But in my case am reading the xsl file in java and returning it to a html and storing it inside a textarea...But am confused on how it is smart enough to drop namespaces as it reads using document.getElementById() property – user2918673 Jul 11 '16 at 11:08
  • IE has DOMParser but perhaps not in compat mode so that might explain why you get different results. I would really suggest you use the cde snippet feature to add a minimal but complete sample allowing us to reproduce the problem. On the other hand, if it is the problem linked to in the other question then, as already said, you will have to work around the IE problem or pressure Microsoft to fix it. – Martin Honnen Jul 11 '16 at 12:26
  • But when i refreshed the page i got an error exactly in this line in java Transformer transformer = factory.newTransformer( Criteria.getXsltStream());transformer.setParameter("versionParam", "1.0"); --> It threw a null pointer Exception – user2918673 Jul 12 '16 at 08:50

1 Answers1

0

The question i raised was clearly answered in the below link

https://dzone.com/articles/domparsers-parsefromstring

user2918673
  • 141
  • 1
  • 9