hta实现的笨狼XSLT练习器

时间:2021-05-23


<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>
<INPUTtype="file"id="fileXML"onchange="showXML();"/>&nbsp;XML&nbsp;
<INPUTtype="file"id="fileXSL"onchange="showXSL();"/>&nbsp;XSL&nbsp;&nbsp;
<buttononclick="parseXML();">开始转换</button>
<buttononclick="browse();">预览结果</button>
<textAreaid="blockXML"></textArea>
<textAreaid="blockXSL"></textArea>
<textAreaid="showMe"></textArea>
<SCRIPTLANGUAGE="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;

varfso
fso=newActiveXObject("Scripting.FileSystemObject");



varxmldoc,xsldoc;
xmldoc=newActiveXObject("MSXML2.DOMDocument");
xsldoc=newActiveXObject("MSXML2.DOMDocument");
xmldoc.async=false;
xsldoc.async=false;

functionbrowse()
{
varwin=window.open();
win.document.write(showMe.value);
}

functionshowXML()
{//在文本框内加载XML
if(Validator(fileXML.value,"XML"))
{
if(fso.FileExists(fileXML.value))
{
varf=fso.GetFile(fileXML.value);
varts=f.OpenAsTextStream(1,-2);
vars="";
if(!ts.AtEndOfStream)
{
s=ts.ReadAll();
}
ts.Close();
blockXML.value=s;
fileXML.value="";
}
}
else
{
alert("XML格式错误!");
}
}

functionshowXSL()
{//在文本框内加载XSL
if(Validator(fileXSL.value,"XSL")||Validator(fileXSL.value,"XSLT"))
{
if(fso.FileExists(fileXSL.value))
{
varf=fso.GetFile(fileXSL.value);
varts=f.OpenAsTextStream(1,-2);
vars="";
if(!ts.AtEndOfStream)
{
s=ts.ReadAll();
}
ts.Close();
blockXSL.value=s;
fileXSL.value="";
}
}
else
{
alert("XSL/XSLT格式错误!");
}
}

functionValidator(inStr,outStr)
{//检查文件格式
varlast=inStr.match(/^(.*)(\.)(.{1,8})$/)[3];
last=last.toUpperCase();
if(last==outStr)
{
returntrue;
}
else
{
returnfalse;
}

}



functionparseXML()
{//解析
if(!blockXML.value||!blockXSL.value)
{
return
}

if(!xmldoc.loadXML(blockXML.value))
{
alert("XML未加载成功!")
}

if(!xsldoc.loadXML(blockXSL.value))
{
alert("XSL未加载成功!")
}

vars=xmldoc.transformNode(xsldoc);
showMe.value=s;

}



</SCRIPT>
</BODY>
</HTML>
笨狼XSLT练习器.hta

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章