Using Msxml.createProcessor()

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Using Msxml.createProcessor()

Post by kendall »

Hello,

I have a script i pulled off somewhere that loads an XSL document

Code: Select all

function loadXslStylesheet(templatePath)
{/* load the XSL template */
	try {
		var oXmlDom = createDomFromUri(templatePath, true);
	} catch (e) {
		
		return false;
	}

	//if (! parseXmlDom(oXmlDom)) {
		// only contuine if the XSL style sheet is valid
	//	return false;
	//}

	if ((typeof XSLTProcessor) != "undefined") { // w3c Compliant browsers
		
		var oXslt = new XSLTProcessor();
		oXslt.importStylesheet(oXmlDom);
	
		return oXslt;		
	} else if (window.ActiveXObject) { // Internet Explorer
		var xslTemplate = new ActiveXObject("Msxml2.XSLTemplate");
		xslTemplate.stylesheet= oXmlDom;
		return xslTemplate.createProcessor();
	}
}
Now i have tree sets of XSL fragments that i use to build an html page

Code: Select all

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- DWXMLSource="../photogallery/photos.xml" -->
<!DOCTYPE xsl:stylesheet  [
	<!ENTITY nbsp   " ">
	<!ENTITY copy   "©">
	<!ENTITY reg    "®">
	<!ENTITY trade  "&#8482;">
	<!ENTITY mdash  "&#8212;">
	<!ENTITY ldquo  "&#8220;">
	<!ENTITY rdquo  "&#8221;"> 
	<!ENTITY pound  "£">
	<!ENTITY yen    "¥">
	<!ENTITY euro   "&#8364;">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="div_scroll.xsl"/>
<xsl:import href="photo_view.xsl"/>
  <xsl:output method="html" encoding="iso-8859-1" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
  <xsl:template match="gallery">	
    <div>
      <xsl:for-each select="photo">
        <xsl:sort data-type="number" order="ascending" select="@order"/>
		<xsl:if test="(@order = 1)">
		 <xsl:call-template name="photo1"/>
		</xsl:if>
        <xsl:call-template name="photo"/>
      </xsl:for-each>
    </div>
  </xsl:template>
</xsl:stylesheet>
Now as you can see the above is the main stylesheet that imports 2 other stylesheet

In Firefox the above application works fine but in IE some where along the line the browser is telling me i dont have a proper stylesheet and it probably not "well formed"

Now somewhere along the line around here
var xslTemplate = new ActiveXObject("Msxml2.XSLTemplate.3.0");
xslTemplate.stylesheet= oXmlDom;
return xslTemplate.createProcessor();
its seems to be returning a undefined...yet when i do a
alert(xslTemplate) before the stylesheet i get a object
i get an object being alerted yet
if i do this after the stylesheet property setting it does alert me

can anyone shed some light here on this?

Kendall
Post Reply