Report Builder 2.0 查询:字段名称中带有空格的 ElementPath

发布于 2024-08-20 23:10:45 字数 1287 浏览 11 评论 0原文

我正在尝试使用 Report Builder 2.0 来使用 XML 数据源查询 Sharepoint 列表。我明确列出了我想要返回的字段,因为否则 我没有得到所有的,因为其中一些有时为空。但是,我需要的字段之一的名称中有一个空格。如果我执行的查询没有明确指定字段,我会将其作为字段之一返回:ows_Pre-Req Estimate。如何在 ElementPath 标记中指定此字段?当我尝试将字段名称放在引号中或仅保留空格时,出现不同的错误,如下所示:

<ElementPath IgnoreNamespaces="true">
GetListItemsResponse/GetListItemsResult/listitems/data/row{@ows_Release,@ows_Theme,@ows_ID,@ows_Pre-Req Estimate}
</ElementPath>

这是当我保留空格并尝试在查询设计器中运行查询时出现的错误:

XmlDP 查询无效。 ElementPath 第 1 行第 105 字符处存在语法错误。预期}。

我尝试检查有关 ElementPath 的 MSDN 页面,但没有看到任何内容关于带有空格的字段的注释。我在 Maria 的两分钱 有人建议使用 _x0020_ 而不是空格,但这似乎也不起作用。

交叉发布到 Microsoft 论坛

I'm trying to use Report Builder 2.0 to query a Sharepoint List using an XML data source. I explicitly list the fields I want returned because otherwise I don't get all of them, due to some of them being null sometimes. However, one of the fields I need has a space in its name. If I do a query where I don't explicitly specify fields, I get this back as one of the fields: ows_Pre-Req Estimate. How can I specify this field in the ElementPath tag? I get different errors when I try to put the field name in quotes or just leave it with a space as shown:

<ElementPath IgnoreNamespaces="true">
GetListItemsResponse/GetListItemsResult/listitems/data/row{@ows_Release,@ows_Theme,@ows_ID,@ows_Pre-Req Estimate}
</ElementPath>

Here's the error I get when I leave the space in and try to run the query in Query Designer:

The XmlDP query is invalid. Syntax error at line 1, character 105 of the ElementPath. Expected }.

I tried checking the MSDN page about ElementPath but didn't see any notes about fields with spaces. I saw on Maria's two cents that someone suggested using _x0020_ instead of a space but that doesn't seem to work either.

Cross-posted to Microsoft Forums.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

软糖 2024-08-27 23:10:45

哦,这里有一些毛茸茸的。好吧,玛丽亚的两分钱的评论者是对的:您可以使用 _x0020_ 转义 ElementPath 中的空格。我的问题是你也必须转义字段名称中的连字符。我下载了 Report Builder 3.0 并尝试在其中创建查询。之后,编辑查询的 XML 会显示应编码的字段名称:

<FieldRef Name="Pre_x002d_Req_x0020_Estimate" />

我现在可以在 Report Builder 2.0 中使用它(请注意字段名称前面的“ows_”):

<ElementPath IgnoreNamespaces="true">
GetListItemsResponse/GetListItemsResult/listitems/data/row{@ows_Release,@ows_Theme,@ows_ID,@ows_Pre_x002d_Req_x0020_Estimate}
</ElementPath>

Ooh, here's some hairiness. All right, so the commenter on Maria's Two Cents was right: you can escape a space in ElementPath with _x0020_. My problem was that you have to escape the hyphen in the field name, too. I downloaded Report Builder 3.0 and tried creating the query in it. Afterward, editing the XML of the query showed me the field names as they ought to be encoded:

<FieldRef Name="Pre_x002d_Req_x0020_Estimate" />

I can now use this in Report Builder 2.0 (note the "ows_" in front of the field names):

<ElementPath IgnoreNamespaces="true">
GetListItemsResponse/GetListItemsResult/listitems/data/row{@ows_Release,@ows_Theme,@ows_ID,@ows_Pre_x002d_Req_x0020_Estimate}
</ElementPath>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文