写电子病历web 察看,本来计划用ajax传xml 到浏览器端进行xslt 转换,可是偏偏没输出,只能硬编码了xml 到html,今天偶然看到 stylesheet 的完整节点定义
<xsl:stylesheet id="sheet" version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="" xmlns:html="http://www.w3.org/1999/xhtml">
改成这样 firefox 就认xslt了. 一个困扰了2周的问题就这样解决了,唉,firefox遵循的标准太严格了或者现在的书写的太不严谨了
简单测试
HTML
<html>
<head>
<script language="javascript">
function t(){
var oXmlDoc=document.implementation.createDocument("","",null);
oXmlDoc.async=false;
var oXsltDoc=document.implementation.createDocument("","",null);
oXsltDoc.async=false;
oXmlDoc.load("employees.xml");
oXsltDoc.load("employees.xslt");
var oProcessor = new XSLTProcessor();
oProcessor.importStylesheet(oXsltDoc);
var oResultDom = oProcessor.transformToDocument(oXmlDoc);
var oSerializer = new XMLSerializer();
var sXml = oSerializer.serializeToString(oResultDom,"text/xml");
document.getElementById('d1').innerHTML=sXml
}
</script>
</head>
<body>
<div id="d1"/>
<script language="javascript">
t();
</script>
</body>
</html>
xml:
<?xml version="1.0"?>
<employees>
<employee title="Software Enginneer">
<name>Nicholas C. Zakas</name>
</employee>
</employees>
xslt:
<?xml version="1.0"?>
<xsl:stylesheet id="sheet" version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="" xmlns:html="http://www.w3.org/1999/xhtml">
<xsl:output method="html"/>
<xsl:template match="/">
<div>
<p>hello world</p>
</div>
</xsl:template>
</xsl:stylesheet>
posted on 2009-03-20 20:03
zarra 阅读(352)
评论(1) 编辑 收藏