问题
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