如何解决忽略xhtml命名空间下带有xmldiff的样式标签
我正在使用xmldiff在两个xhtml文件中显示差异。根据{{3}},有一种方法可以忽略结果文件中的样式标签。
有人知道我怎么能将xhtml:b识别为样式标签? 这些是我的文件:
<xml xmlns:xhtml="http://www.w3.org/1999/xhtml">
<xhtml:div>one two three four</xhtml:div>
</xml>
和
<xml xmlns:xhtml="http://www.w3.org/1999/xhtml">
<xhtml:div>
one two
<xhtml:b>three</xhtml:b>
four
</xhtml:div>
</xml>
我尝试从以下位置更改格式器参数:
formatter = HTMLFormatter(
text_tags=('p','h1','h2','h3','h4','h5','h6','li','div'),formatting_tags=('b','u','i','strike','em','super','sup','sub','link','a','span')
)
到
formatter_xhtml = HTMLFormatter(
text_tags=('xhtml:p','xhtml:h1','xhtml:h2','xhtml:h3','xhtml:h4','xhtml:h5','xhtml:h6','xhtml:li','xhtml:div'),formatting_tags=('xhtml:b','xhtml:u','xhtml:i','xhtml:strike','xhtml:em','xhtml:super','xhtml:sup','xhtml:sub','xhtml:link','xhtml:a','xhtml:span')
)
但是我只有这个错误:
Traceback (most recent call last):
File "c:/Users/paolo/Documents/12_raw_handle/test.py",line 89,in <module>
formatter=formatter_xhtml)
File "C:\Python27\lib\site-packages\xmldiff\main.py",line 45,in diff_texts
diff_options=diff_options,formatter=formatter)
File "C:\Python27\lib\site-packages\xmldiff\main.py",line 39,in _diff
formatter=formatter)
File "C:\Python27\lib\site-packages\xmldiff\main.py",line 21,in diff_trees
formatter.prepare(left,right)
File "C:\Python27\lib\site-packages\xmldiff\formatting.py",line 322,in prepare
self.placeholderer.do_tree(left_tree)
File "C:\Python27\lib\site-packages\xmldiff\formatting.py",line 162,in do_tree
for elem in tree.xpath('//'+'|//'.join(self.text_tags)):
File "src\lxml\etree.pyx",line 1582,in lxml.etree._Element.xpath
File "src\lxml\xpath.pxi",line 305,in lxml.etree.XPathElementEvaluator.__call__
File "src\lxml\xpath.pxi",line 225,in lxml.etree._XPathEvaluatorBase._handle_result
lxml.etree.XPathEvalError: Undefined namespace prefix
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。