This is a migrated thread and some comments may be shown as answers.

Error: "XSLTProcessor" is undefined

1 Answer 201 Views
HTMLPlaceHolder
This is a migrated thread and some comments may be shown as answers.
Seb
Top achievements
Rank 1
Seb asked on 04 Nov 2011, 11:15 AM
Hi,

When I set the HTMLPlaceHolder with this HTML Page, I get Error: "XSLTProcessor" is undefined , but in all browser this page works
perfectly :

Thanks to answer me.
<html>

<head>

<script type="text/javascript">
 
	function transformxml() {
 
		if (document.implementation && document.implementation.createDocument) {
 
			// Mozilla
 
			// XML:
 
			var xmltxt
 
			xmltxt = document.getElementById("xmlcode").value
 
			if (xmltxt == "") {
 
				alert("The XML is empty")
 
				return false
 
			}
 
			var doc = new DOMParser();
 
			var xml = doc.parseFromString(xmltxt, "text/xml");
 
 
 
			if (xml.documentElement.nodeName == "parsererror") {
 
				document.write("Error in XML<br /><br />" + xml.documentElement.childNodes[0].nodeValue);
 
				alert("Error in XML\n\n" + xml.documentElement.childNodes[0].nodeValue);
 
				return false;
 
			}
 
			// XSL:
 
			var xsltPrs = new XSLTProcessor();
 
			var xsltxt
 
			xsltxt = document.getElementById("xsltcode").value
 
			if (xsltxt == "") {
 
				alert("The XSLT is empty")
 
				return false
 
			}
 
			xsl = doc.parseFromString(xsltxt, "text/xml");
 
			if (xsl.documentElement.nodeName == "parsererror") {
 
				document.write("Error in XSLT<br /><br />" + xsl.documentElement.childNodes[0].nodeValue);
 
				alert("Error in XSLT\n\n" + xsl.documentElement.childNodes[0].nodeValue);
 
				return false;
 
			}
 
 
 
			xsltPrs.importStylesheet(xsl);
 
 
 
			// Transform:
 
			var result = xsltPrs.transformToFragment(xml, document);
 
			document.getElementById("result_output").appendChild(result);
 
			//	document.replaceChild(result,window.document.childNodes[0])
 
		}
 
		else if (window.ActiveXObject) {
 
			// IE
 
 
 
			// XML:
 
			var xmltxt
 
			xmltxt = document.getElementById("xmlcode").value
 
			if (xmltxt == "") {
 
				alert("The XML is empty")
 
				return false;
 
			}
 
			xml = new ActiveXObject("MSXML2.DOMDocument");
 
			xml.async = false
 
			xml.loadXML(xmltxt)
 
			if (xml.parseError.errorCode != 0) {
 
				document.write("Error in XML<br /><br />Line " + xml.parseError.line + ": " + xml.parseError.reason);
 
				alert("Error in XML\n\nLine " + xml.parseError.line + ": " + xml.parseError.reason);
 
				return false
 
			}
 
			// XSL:
 
			var xsltxt
 
			xsltxt = document.getElementById("xsltcode").value
 
			if (xsltxt == "") {
 
				alert("The XSLT is empty")
 
				return false
 
			}
 
			xsl = new ActiveXObject("Microsoft.XMLDOM")
 
			xsl.async = false
 
			xsl.loadXML(xsltxt)
 
			if (xsl.parseError.errorCode != 0) {
 
				document.write("Error in XSLT<br /><br />Line " + xsl.parseError.line + ": " + xsl.parseError.reason);
 
				alert("Error in XSLT\n\nLine " + xsl.parseError.line + ": " + xsl.parseError.reason);
 
				return false
 
			}
 
 
 
			// Transform:
 
			document.write(xml.transformNode(xsl));
 
		}
 
		else {
 
			// No Browser support:
 
			alert("Your browser does not support this example.");
 
		}
 
	}

</script>

</head>



<body onload="transformxml()">

<div id="result_output"></div>

<textarea id="xmlcode" style="display:none"><?xml version="1.0" encoding="ISO-8859-1"?>

<!-- Edited by XMLSpy® -->

<catalog>

	<cd>

		<title>Empire Burlesque</title>

		<artist>Bob Dylan</artist>

		<country>USA</country>

		<company>Columbia</company>

		<price>10.90</price>

		<year>1985</year>

	</cd>

	<cd>

		<title>Hide your heart</title>

		<artist>Bonnie Tyler</artist>

		<country>UK</country>

		<company>CBS Records</company>

		<price>9.90</price>

		<year>1988</year>

	</cd>

	<cd>

		<title>Greatest Hits</title>

		<artist>Dolly Parton</artist>

		<country>USA</country>

		<company>RCA</company>

		<price>9.90</price>

		<year>1982</year>

	</cd>

	<cd>

		<title>Still got the blues</title>

		<artist>Gary Moore</artist>

		<country>UK</country>

		<company>Virgin records</company>

		<price>10.20</price>

		<year>1990</year>

	</cd>
	

</catalog>

</textarea>

<textarea id="xsltcode" style="display:none"><?xml version="1.0" encoding="ISO-8859-1"?>

<!-- Edited by XMLSpy® -->

<xsl:stylesheet version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">

  <html>

  <body>

	<h2>My CD Collection</h2>

	<table border="1">

	  <tr bgcolor="#9acd32">

	  <th>Title</th>

	  <th>Artist</th>

	</tr>

	<xsl:for-each select="catalog/cd">
	
	  <tr>

		<td><xsl:value-of select="title"/></td>

		<td><xsl:value-of select="artist"/></td>

		</tr>

	</xsl:for-each>

	</table>

  </body>

  </html>

</xsl:template>

</xsl:stylesheet>

</textarea>

</body>

</html>


1 Answer, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 09 Nov 2011, 01:25 PM
Hi Seb,

Please have a look at the answer I posted in this forum thread and let me know if it helps or if we can further assist you.

All the best,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
HTMLPlaceHolder
Asked by
Seb
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Share this question
or