Is there a way for browsers to ignore or override xml-stylesheet processing instructions?

I am trying to write a bookmarklet to help some QA testers provide useful debugging information when they encounter problems. I can currently set window.location for a URL that provides this information for debugging, but this resource is an XML document with an xml table processing directive.

In fact, it would be more convenient if the testers could see either the raw XML data in plain text or the default XML rendering for IE and Firefox.

Does anyone know a way to disable or override the xml-stylesheet directives provided inside an XML document using Internet Explorer or Firefox?

Edit: I discovered generosity on this. Requirements:

  • Client-side code only, no user intervention
  • Solutions for IE and Firefox are needed (they may be different solutions)
  • Disabling the processing of style sheets and rendering them as text is acceptable
  • Prioritizing style sheets with custom XSL is acceptable.
  • Providing XML with an XML Stylesheet is acceptable by default
+5
source share
5 answers

EDIT : too bad, although everything seemed fine in the preview, clickable examples seem to be spoiled things ... Perhaps the layout is great for the story.

, IE, IE Firefox "view-source:". Firefox Mac , Safari .

XSLT, XML. Firefox , , XML XSLT (, - ​​ , Firefox):

javascript:(function(){
  var u = 'http://www.w3schools.com/xsl/cdcatalog_with_ex1.xml';
  var w = window.open();
  w.document.location.href = 'view-source:' + u;
})()

Ajax, alert oneporter, . : XSLT, :

javascript:(function(){
  var u = 'http://www.w3schools.com/xsl/cdcatalog_with_ex1.xml';

  var w = window.open(); /* open right away for popup blockers */

  var x = new XMLHttpRequest();
  x.open('GET', u, true); 
  x.onreadystatechange = function(){
    if(x.readyState == 4){
      w.document.open('text/html');
      /* hack to encode HTML entities */
      var d = document.createElement('div'); 
      var t = document.createTextNode(x.responseText); 
      d.appendChild(t);
      w.document.write('<html><body><pre>' 
          + d.innerHTML + '</pre></body></html>');
      w.document.close();
      w.focus();
    }
  };
  x.send(null); 
})()
+3

" " ?

+2

, , / ajax XML . xmlHttp, IE.

<html>
<body>

<script language="JavaScript">
function ajaxFunction()
{

var xmlHttp=new XMLHttpRequest();;

  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
      alert(xmlHttp.responseText);
      }
    }
  xmlHttp.open("GET","YOURFILE.xml",true);
  xmlHttp.send(null);

}
</script>

<a href="#" onclick="JavaScript:ajaxFunction()">Errors</a>

</body>
</html>
+2

, XML , .

  • XML- AJAX
  • XML DOM (: DOM DOM)
  • DOM .

XML - script, XML , .

:

window.location = 'http://example.com/document.xml';

:

window.location = 'http://example.com/proxy/';


script http://example.com/proxy/:

  • document.xml
  • , XML.
  • XML
+1

, , . , javascript dom xml xml/xsl . javascript, html dom.

However, depending on the type of webapp, there may be some hope. You can use ajax to get the xml of the current url. As long as there is no data to publish or any other randomness, this method should work fine.

0
source

All Articles