Collective.xdv 中的 local-name() 支持
我有一个 Plone 3.5 网站,我正在尝试将 Simple Social 的 FB Like 操作嵌入到 Collective.xdv 主题中的内容中。 FB Like 函数嵌入在 XML 标记中
<fb:like></fb:like>
,我试图通过选择其 XPATH
//*[local-name()="like"]
但是,我没有看到任何输出。 Collective.xdv 支持上述内容吗?还有另一种方法可以在 XPATH 中选择 fb:like 标签吗?
I have a Plone 3.5 site and I am trying to embedded Simple Social's FB Like action for a content in a collective.xdv theme. The FB Like function is embedded in an XML tag
<fb:like></fb:like>
I am trying to select its XPATH via
//*[local-name()="like"]
However, I do not see any output. Is the above supported in collective.xdv? Is there another way to select the fb:like tag in XPATH?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
lxml 使用的 libxml2 HTMLParser 以及 xdv/diazo 会去除名称空间前缀,因此您应该能够使用“//like”选择它。
您将需要添加一些 xslt 代码来修复这些标签,因为它们必须呈现为才能工作:
虽然可以使 xdv/diazo 与 XMLParser 一起使用,但您需要确保添加了 xmlns:fb ="..." 声明您的文档,并且您的所有输入都是有效的 xhtml,这对于基于浏览器的 html 编辑器来说很难确保。
劳伦斯
The libxml2 HTMLParser used by lxml and thus xdv/diazo strips namespace prefixes, so you should be able to select it with "//like".
You will need to add some xslt code to fix up those tags, as they must be rendered as in order to work:
While xdv/diazo could be made to work with the XMLParser you would then need to ensure that you added an xmlns:fb="..." declaration to your document and that all your input was valid xhtml, which is difficult to ensure with browser based html editors.
Laurence
aiui,这不是本地名称的工作原理。您需要匹配命名空间限定的标记,然后 local-name() 返回非限定名称。我相信
//*
仅返回默认命名空间中的标签节点集。您尝试过
//fb:like
吗? [我知道,这太简单了 - 我认为这是错误的 - 但话又说回来,它很简单:-)]aiui, that's not how local-name works. You need to match on a namespace-qualified tag, and then local-name() returns the unqualified name. I believe
//*
is only returning a nodeset of tags in the default namespace.Have you tried
//fb:like
? [I know, that's far too easy - and I think it's wrong - but then again, it is easy :-) ]