Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to apply xsl styles to an embedded xml inside html with javascript
    primarykey
    data
    text
    <p>I have a html file embedded xml tags inside, here i am trying to apply xslt styles are written in another separate file (somefile.xsl) importing with javascript, i am successful applying styles with external xslt file importing with javascript but it is working only in internet explorer , other browsers failed to apply styles.. bellow is my html code please look at my code. where i am doing wrong here ? Except IE no other browser seem working with these technique.</p> <pre><code> &lt;HTML&gt; &lt;HEAD&gt; &lt;TITLE&gt;Sample XML with XSL&lt;/TITLE&gt; &lt;xml id="elx"&gt; &lt;hello-world&gt; &lt;greeter&gt;An XSLT Programmer&lt;/greeter&gt; &lt;greeting&gt;Hello, World! &lt;/greeting&gt; &lt;/hello-world&gt; &lt;/xml&gt; &lt;/HEAD&gt; &lt;BODY&gt; &lt;SCRIPT language = "javascript"&gt; if(window.ActiveXObject) { //IE alert("hi"); var xslDoc = new ActiveXObject("Microsoft.XMLDOM"); xslDoc.async = false; xslDoc.load("helloworld.xsl"); document.write(elx.transformNode(xslDoc)); } else if (document.implementation &amp;&amp; document.implementation.createDocument) { //For Other Browsers xsltProcessor=new XSLTProcessor(); xsltProcessor.importStylesheet("helloworld.xsl"); result = xsltProcessor.transformToDocument(elx); // here 'elx' is id of embedded xml in header. document.write(result); } &lt;/SCRIPT&gt; &lt;/BODY&gt; &lt;/HTML&gt; </code></pre> <p>and here is my xsl ( helloworld.xsl ) file which i am trying to import with javascript and adding styles to embedded xml inside html file</p> <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1" ?&gt; &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" &gt; &lt;xsl:output method="html" version="1.1" encoding="iso-8859-1" /&gt; &lt;xsl:template match="/hello-world"&gt; &lt;HTML&gt; &lt;HEAD&gt; &lt;TITLE&gt; &lt;/TITLE&gt; &lt;/HEAD&gt; &lt;BODY&gt; &lt;H1&gt; &lt;xsl:value-of select="greeting"/&gt; &lt;/H1&gt; &lt;xsl:apply-templates select="greeter"/&gt; &lt;/BODY&gt; &lt;/HTML&gt; &lt;/xsl:template&gt; </code></pre> <p> within my html file i get only id of that xml file, by using that xml id i need to apply styles using javascript. hope you understand my issue and please solve this as soon as possible.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload