xslt 中的 sitecore xpath 查询中返回的额外元素

发布于 2024-12-05 13:05:57 字数 232 浏览 0 评论 0原文

在我编写的许多 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

っ左 2024-12-12 13:05:57

啊抱歉。看来以下作品有效。

<xsl:variable name="home" select="sc:item('/sitecore/content/home',.)" />
<xsl:variable name="documents" select="$home//item[@template='document type']" />

我之前尝试过类似的事情,但没有成功,

<xsl:variable name="documents" select="/sitecore/content/home//item[@template='document type']" />

我需要去阅读更多 xslt 教程;)

gah sorry. It seems the following works.

<xsl:variable name="home" select="sc:item('/sitecore/content/home',.)" />
<xsl:variable name="documents" select="$home//item[@template='document type']" />

I had tried a similar thing earlier but it didn't work

<xsl:variable name="documents" select="/sitecore/content/home//item[@template='document type']" />

I need to go read more xslt tutorials ;)

℉服软 2024-12-12 13:05:57

虽然您可以通过 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文