Tuesday

javascript transformnode or javascript transform xml

XSL transformation in javascript


// ake xmldoc for client -side transformations
function MakeXMLDoc()
{
var xmlDoc;
// code for IE
if (window.ActiveXObject){
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
}
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation && document.implementation.createDocument) {
xmlDoc=document.implementation.createDocument("","",null);

}else{
alert('Your browser cannot handle this script');
}
xmlDoc.async=false;

return(xmlDoc);
}


function XSLTrasformer(xml,xsl,span_name) // >[:>]
{

//xml=loadXMLDoc("1.xml");
//xsl=loadXMLDoc("NovaSettleResponse.xsl");

// code for IE
if (window.ActiveXObject)
{
ex=xml.transformNode(xsl);
document.getElementById(span_name).innerHTML=ex;
}
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation
&& document.implementation.createDocument)
{
xsltProcessor=new XSLTProcessor();
xsltProcessor.importStylesheet(xsl);
resultDocument = xsltProcessor.transformToFragment(xml,document);
document.getElementById(span_name).appendChild(resultDocument);
}

}

function XMLPopup(xml_string,xsl_file){
xsl=MakeXMLDoc(); xml=MakeXMLDoc();
xsl.load(xsl_file);
xml.loadXML(xml_string);
ex=xml.transformNode(xsl);
//document.getElementById(span_name).innerHTML=ex;
var dbgwin;
//left=0,top=0,
dbgwin=window.open("", "xml_pop", "width=420,height=540,scrollbars=yes,status=yes,resizable=yes");
dbgwin.document.write(ex);
dbgwin.document.write("<p><input type='button' onclick='window.close();' value='close'></p>");
}

No comments:

test smtp server with powershell

Send-MailMessage -SMTPServer smtp.domain.com -To [email protected] -From [email protected] -Subject "This is a test email" -Body ...