xslt 中的 sitecore xpath 查询中返回的额外元素
在我编写的许多 xslt 中,我使用以下内容来检索 Sitecore 中特定类型的所有文档的集合。
<xsl:variable name="documents" select="//item[@template='document type']" />
它几乎按预期工作,只是总是返回一个额外的空白元素,我不确定为什么。也许上面也返回模板本身,但我不知道如何验证这一点。
In a number of xslt's I've written I've used the following to retrieve a set of all the document of a particular type within Sitecore.
<xsl:variable name="documents" select="//item[@template='document type']" />
It almost works as expected except that one extra blank element is always returned and I'm not sure why. Perhaps the above is also returning the template itself but I don't know how to verify this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
啊抱歉。看来以下作品有效。
我之前尝试过类似的事情,但没有成功,
我需要去阅读更多 xslt 教程;)
gah sorry. It seems the following works.
I had tried a similar thing earlier but it didn't work
I need to go read more xslt tutorials ;)
虽然您可以通过 XSLT 选择来实现此目的,但搜索站点的所有后代(尤其是从主节点开始)可能是一项非常昂贵的操作,并且通常表明需要再次查看该体系结构。您确定这是您需要在网站中执行的操作,或者您可能需要重新考虑您想要实现的目标吗?
如果这些文档模板遍布整个站点并且您确实需要找到它们,那么当您有大量内容时,Lucene 索引将更适合您。查看高级数据库爬网程序。
Whilst you can achieve this through an XSLT selection, searching through all descendants of a site, particularly starting at the Home node, can be a very expensive operation and is often a sign that the architecture needs to be looked at again. Are you sure this is what you need to do in your site, or perhaps you need to rethink what you are trying to achieve?
If you have these document templates spread out across all of your site and you do need to find them, a Lucene Index is going to be much better for you if you have a lot of content. Take a look at the Advanced Database Crawler.