with (classes) {

with (XML) {

if (classes.XSLTProcessor) XML.XSLTProcessor = classes.XSLTProcessor;
else {

XML.XSLTProcessor = function ()
{
 with (XSLTProcessor)
 {
  this.clearParameters = clearParameters;
  this.getParameter = getParameter;
  this.importStylesheet = importStylesheet;
  this.reset = reset;
  this.removeParameter = removeParameter;
  this.setParameter = setParameter;
  this.transformToFragment = transformToFragment;
  this.transformToDocument = transformToDocument;

  this.The_XSLTemplate = null;
  this.The_XSLProcessor = null;
  this.Stylesheet_DOMDocument = null;

  this.The_Parameters = null;

  with (this)
  {
   The_Parameters = new Object;

   try { The_XSLTemplate = new ActiveXObject("Msxml2.XSLTemplate"); } catch (e) {}
  }
 }

 return this;
}

XSLTProcessor.clearParameters = function () { with (this)
{
 for (var parameter_name in The_Parameters)
  with (parameter_name) removeParameter(substr(0, lastIndexOf('$')), substr(1 + lastIndexOf('$')));

}}

XSLTProcessor.getParameter = function (namespaceURI, localname) { with (this)
{
 return The_Parameters[namespaceURI? (namespaceURI + '$' + localName) : localName];
}}

XSLTProcessor.importStylesheet = function (style) { with (this)
{
 try {
 
 The_XSLTemplate.stylesheet = Stylesheet_DOMDocument = style.constructor? style.The_DOMDocument : style;
 
 } catch (e) {
 
 var The_XMLDocument = new ActiveXObject("Msxml2.FreeThreadedDOMDocument");

 if (The_XMLDocument)
 {
  The_XMLDocument.loadXML((style.constructor? style.The_DOMDocument : style).xml);
 
  The_XSLTemplate.stylesheet = The_XMLDocument;
 }

 }

 The_XSLProcessor = The_XSLTemplate.createProcessor();
}}

XSLTProcessor.removeParameter = function (namespaceURI, localname) { with (this)
{
 if (localname in The_Parameters && The_Parameters[localname].namespaceURI == namespaceURI)
 {
  delete The_Parameters[localname];

  The_XSLProcessor.addParameter(localname, "", namespaceURI? namespaceURI : "");
 }
}}

XSLTProcessor.reset = function () { with (this)
{
 clearParameters();

 The_XSLProcessor.reset();
}}

XSLTProcessor.setParameter = function (namespaceURI, localname, value) { with (this)
{
 var The_Parameter = new Object;

 The_Parameter.value = value;

 if (namespaceURI) The_Parameter.namespaceURI = namespaceURI;

 The_Parameters[localname] = The_Parameter;

 The_XSLProcessor.addParameter(localname, value, namespaceURI? namespaceURI : "");
}}

XSLTProcessor.transformToDocument = function (source) { with (this)
{
 var The_DOMDocument = new ActiveXObject("Msxml2.DOMDocument"); // classes.dom.DOMImplementation.createDocument(null, null, null);

 if (! The_DOMDocument) return null; // throw ...

 with (The_DOMDocument)
 {
  async = false;
  resolveExternals = false; // true;
  validateOnParse = false; // true;
 }

 var Output_NodeList;

 with (Stylesheet_DOMDocument.documentElement) Output_NodeList = getElementsByTagName(prefix? (prefix + ':' + "output") : "output");

 var textMethod = (Output_NodeList.length && Output_NodeList.item(0).getAttribute("method") == "text");

//  var result_string = (source.constructor? source.The_DOMDocument : source).transformNode(Stylesheet_DOMDocument);
// INSERTED
 with (The_XSLProcessor)
 {
  input = source.constructor? source.The_DOMDocument : source;
  output = The_DOMDocument;
  transform();
 }

 if (textMethod)
 {
  var result_string = The_DOMDocument.text;

  The_DOMDocument.loadXML("<transformiix:result xmlns:transformiix=\"http://www.mozilla.org/TransforMiix\">" + result_string + "</transformiix:result>");
 }
// END INSERTED
// The_DOMDocument.loadXML(textMethod? ("<transformiix:result xmlns:transformiix=\"http://www.mozilla.org/TransforMiix\">" + result_string + "</transformiix:result>") : result_string);

/*
//   if (source.nodeType != classes.dom.Node.DOCUMENT_NODE) The_DOMDocument.loadXML(source.transformNode(Stylesheet_DOMDocument));
//   else
 with (The_XSLProcessor)
 {
  input = source.constructor? source.The_DOMDocument : source;
  output = The_DOMDocument;
  transform();
 }
*/
 return dom.Document.call(The_DOMDocument);
}}

XSLTProcessor.transformToFragment = function (source, output) { with (this)
{
 // Currently assumes IE

 if (! source.transformNodeToObject) return null;

 var The_IXMLDOMDocumentFragment = output.createDocumentFragment();

 source.transformNodeToObject(The_XSLTemplate.stylesheet, The_IXMLDOMDocumentFragment);

 return The_IXMLDOMDocumentFragment;
}}


}

}

}

