local-name() support in Collective.xdv

China☆狼群 提交于 2019-12-07 11:54:05

问题


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?


回答1:


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:

<xsl:template match="activity|add-profile-tab|bookmark|comments|friendpile|like|like-box|live-stream|login-button|pronoun|recommendations|serverFbml|profile-pic|user-status">
  <xsl:element name="fb:{local-name()}" xmlns:fb="http://www.facebook.com/2008/fbml">
    <xsl:apply-templates select="@*|node()"/>
  </xsl:element>
</xsl:template>

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




回答2:


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 :-) ]



来源:https://stackoverflow.com/questions/5578910/local-name-support-in-collective-xdv

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!