我有一个XML文件和一个相应的XSLT。我想得到一个可以用python浏览器运行的HTML文件。在
下面是我的python代码:
from lxml import etree
dom = etree.parse(path_xml)
xslt =etree.parse(path_xslt)
transform = etree.XSLT(xslt)
newdom = transform(dom)
print(etree.tostring(newdom, pretty_print=True))
问题是我得不到回报
因为我是一个初学者,我把我的文件调亮了,因为我认为这是问题的原因,但结果发现问题仍然存在:
XML文件:
^{pr2}$以下是我的XSLT表的内容:
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" doctype-system="about:legacy-compat" encoding="UTF-8"
indent="yes" />
<xsl:template match="verfication">
<html>
<head>
<meta charset="utf-8"/>
</head>
<body>
<p><img src="image.jpg" alt="Binevenue"/></p>
<h1 align="center" > Comparaison Status= FALSE </h1>
<p>Nombre d'erreurs = <xsl:value-of select="verification/nberror"/></p>
<p><a href="">See more Details ...</a></p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
代码中有多个错误源。您需要同时修改XML文件和XSLT样式表。在
在XML文件中
verification
元素的statut
属性的值没有用单引号或双引号括起来f_tst
元素的value
属性的值,没有左引号在XSLT样式表中
<xsl:value-of select="verification/nberror"/>
应该读<xsl:value-of select="nberror"/>
,因为上下文(模板匹配verification
)此外,一个名为验证dtd“可能对XSLT处理器或浏览器不可用。在
输入(修改)
样式表
^{pr2}$吹毛求疵,但是
alt="Binevenue"
在法语中应该是alt="Bienvenue"
。在相关问题 更多 >
编程相关推荐