/**
/ Object template that specifies the object that is responsable to transforms data.
/ @Package: Firebrick
/ @Author: upa
/ @Last modify: June 14, 2008
/ @Charset: utf-8
/*/

function XMLTransformer() {
	
	// Empty constructor
	
	// Methods
	
	/**
	/ Transforms a XML source to a XML result fragment using a XSL style sheet
	/*/
	this.transformToFragment = function(XMLSource,XSLFileName) {
					
		// Loads the XSL file
		var xsl = this.loadXSLDocument(XSLFileName);
		
		// Code for IE
		if(window.ActiveXObject) {
			
			// Transforms
			var fragment = XMLSource.transformNode(xsl);
		}
		
		// Code for Mozilla, Netscape and Opera
		else if(document.implementation && document.implementation.createDocument) {
			// Creates the XSLT processor
			xsltProcessor = new XSLTProcessor();
			
			// Imports the XSL file
			xsltProcessor.importStylesheet(xsl);
			
			// Transforms
			var fragment = xsltProcessor.transformToFragment(XMLSource,document);
		}
		else {
			throw("Seu navegador não suporta transformações XSL.");	
		}
			
		// Returns
		return(fragment);
	};
	
	/**
	/ Loads a XSL file.
	/*/
	this.loadXSLDocument = function(XSLFileName) {
		
		// XSL namespace
		var xslNs = 'http://www.w3.org/1999/XSL/Transform';
		
		// Code for IE
		if(window.ActiveXObject) {
			
			// Creates the XSL document
			var xsl = new ActiveXObject("Microsoft.XMLDOM");	
		}
		else if(document.implementation && document.implementation.createDocument) {
			
			// Creates the XSL document
			var xsl = document.implementation.createDocument(xslNs,"",null);
		}
		else {
			throw("Seu navegador não suporta arquivos XML.");	
		}
		
		// Configures the XSL document
		xsl.async = false;
		
		// Loads the XSL from a file
		xsl.load(XSLFileName);
		
		// Returns
		return(xsl);
	};
	
	// End of Methods
	
}
