<html>
<head>
<title>笨狼xslt练习器 _脚本之家</title>
<style>
body
{
font-size:12;
background: #dadada;
margin-left:20;
}
#blockxml
{
font-family:verdana;
font-size:12px;
overflow:scroll;
height:400;
top:40;
left:20;
}
input
{
width:350;
}
#blockxsl
{
position: absolute;
font-family:verdana;
font-size:12px;
overflow:scroll;
height:400;
top:40;
}
#showme
{
font-family:verdana;
font-size:12px;
height:100;
overflow:visible;
top:300;
left:20;
}
</style>
</head>
<body>
<input type=file id=filexml onchange = showxml();/> xml
<input type=file id=filexsl onchange = showxsl();/> xsl
<button onclick = parsexml(); >开始转换</button>
<button onclick = browse(); >预览结果</button>
<textarea id=blockxml></textarea>
<textarea id=blockxsl></textarea>
<textarea id=showme ></textarea>
<script language=javascript>
window.resizeto(window.screen.availwidth,window.screen.availheight);
window.moveto(0,0);
blockxml.style.width = parseint(window.screen.availwidth * 0.46);
blockxsl.style.width = blockxml.style.width ;
blockxsl.style.left = parseint(window.screen.availwidth * 0.46) + 30;
showme.style.width = parseint(window.screen.availwidth * 0.92)+ 10;
var fso
fso = new activexobject(scripting.filesystemobject);
var xmldoc, xsldoc;
xmldoc = new activexobject(msxml2.domdocument);
xsldoc = new activexobject(msxml2.domdocument);
xmldoc.async = false;
xsldoc.async = false;
function browse()
{
var win=window.open();
win.document.write(showme.value);
}
function showxml()
{//在文本框内加载xml
if(validator(filexml.value,xml))
{
if(fso.fileexists(filexml.value))
{
var f = fso.getfile(filexml.value);
var ts = f.openastextstream(1, -2);
var s=;
if(!ts.atendofstream)
{
s = ts.readall();
}
ts.close();
blockxml.value = s;
filexml.value =;
}
}
else
{
alert(xml格式错误!);
}
}
function showxsl()
{//在文本框内加载xsl
if(validator(filexsl.value,xsl) || validator(filexsl.value,xslt))
{
if(fso.fileexists(filexsl.value))
{
var f = fso.getfile(filexsl.value);
var ts = f.openastextstream(1, -2);
var s=;
if(!ts.atendofstream)
{
s = ts.readall();
}
ts.close();
blockxsl.value = s;
filexsl.value =;
}
}
else
{
alert(xsl/xslt格式错误!);
}
}
function validator(instr,outstr)
{//检查文件格式
var last=instr.match(/^(.*)(\.)(.{1,8})$/)[3];
last=last.touppercase();
if(last==outstr)
{
return true;
}
else
{
return false;
}
}
function parsexml()
{//解析
if(!blockxml.value ||!blockxsl.value)
{
return
}
if(!xmldoc.loadxml(blockxml.value))
{
alert(xml未加载成功!)
}
if(!xsldoc.loadxml(blockxsl.value))
{
alert(xsl未加载成功!)
}
var s = xmldoc.transformnode(xsldoc);
showme.value = s;
}
</script>
</body>
</html>
2025国考·省考课程试听报名