//************************************************
// XMLをXSLT変換する為の関数
// @xmlf:XMLファイル名
// @xslf:XSLTファイル名
// @txtp:HTML内の出力位置<div>のid名
// @async:同期(false)/非同期(true)
//************************************************

function readXML(xmlf, xsltf, txtp){
	// XMLHttpRequestオブジェクトの生成
	var xmlHttp = createXmlHttp();
	xmlHttp.onreadystatechange = function() {
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
			var xml = xmlHttp.responseXML;
			document.getElementById(txtp).innerHTML = "";
			xmlHttp.open("GET", xsltf, false);
			xmlHttp.send(null);
			var xslt = xmlHttp.responseXML;
			try{		// InternetExplorer
				var string = xml.transformNode(xslt);
				document.getElementById(txtp).innerHTML = string;
			}catch(e){	// Mozilla
				processor = new XSLTProcessor();
				processor.importStylesheet(xslt);
				var string = processor.transformToFragment(xml,document);
				document.getElementById(txtp).appendChild(string);
			}
		}
	}
	xmlHttp.open("GET", xmlf, true);
	xmlHttp.send(null);
}

function createXmlHttp(){
	xmlhttp = false;
	try{
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		MSXMLHTTP = true;
	}catch(e){
		try{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			MSXMLHTTP = true;
		}catch(e){
			xmlhttp = false;
		}
	}
	if(!xmlhttp && typeof XMLHttpRequest != 'undefined'){
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}
