CAML 从 Sharepoint 到 HTML
我正在调用返回 CAML 的 SharePoint 的 Web 服务 API 之一分段。 我已经在互联网上进行了广泛的搜索,但我一直无法弄清楚如何使这个 CAML 片段呈现为“正常”HTML,我可以在更理智的环境中呈现,例如 Plumtree、WLP、Liferay 或任何其他门户除了 SharePoint 之外。
如果没有办法做到这一点,我想知道为什么 Microsoft 首先编写返回 CAML 的 SharePoint Web 服务调用。 Web 服务用于互操作性,并且 CAML 似乎仅在 SharePoint 中运行的 WebPart 中有效。 [Bill 和 Steve 请注意:这不是互操作性。]
如果我无法使用返回的 CAML 执行任何操作,我只需调用另一个仅返回数据的 Web 服务,然后编写我自己的 UI。 我希望有一条更容易的路。 任何建议将不胜感激。
I'm invoking one of SharePoint's web service APIs that returns a CAML fragment. I've searched the interweb far and wide but I've been unable to figure out how to make this CAML fragment to render as "normal" HTML that I can render in a more sane environment like Plumtree, WLP, Liferay or any other portal besides SharePoint.
Without a way to do this, I'm wondering why Microsoft wrote SharePoint web service calls that return CAML in the first place. Web services are for interoperability and it seems the CAML is only valid within a WebPart running within SharePoint. [Note to Bill and Steve: that's not interoperability.]
If I can't do anything with the CAML that comes back, I'm just going to call a different web service that returns only data and then write my own UI. I was hoping for an easier path. Any suggestions would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
CAML 仍然是 XML,并且如上所述,XSLT 将能够将其呈现为 HTML。 CAML 的实际全局嵌套 OR/AND 结构是另一个问题。
这需要展开 CAML 结构并以普通人理解的方式显示它。
不幸的是,XSLT 语言不适合展开这样的嵌套结构(它没有堆栈)。 这是可能的,但完成后我强烈建议使用另一种语言来解析和展开 CAML。
我还没有看到 CAML 到 SQL 的转换代码。 听起来像是一个很棒的 Codeplex 项目。
总而言之……你有点被 CAML 塞满了。 虽然它是 XML,但它的结构不适合在任何其他查询语言中使用。
The CAML is still XML and as mentioned, XSLT will be able to render it as HTML. The actual gnraly nested OR/AND structure of CAML is a whole nother issue.
That would require unrolling the CAML structure and displaying it in a way that normal people understand.
Unfortunately, the XSLT language is unsuitable for unrolling nested structures like this (it has no stack). It is possible, but having done it I recommend strongly using another language to parse and unroll the CAML.
I have yet to see a CAML to SQL conversion code. Sounds like a great Codeplex project.
So in summary... you are a bit stuffed with CAML. While it is XML, it's structure is unsuited to use in any other query language.
您可以通过 XSLT 样式表发送 CAML 以生成 HTML 或 XHTML。
编辑:
考虑到您的第一个问题(为什么 SharePoint 从其某些 Web 服务返回 CAML)...谁知道呢? 它可能是为了支持 SharePoint 设计器等创作工具。 但从文档和工具的缺乏看来,CAML 或多或少是 SharePoint 内部的东西。 目前,执行 CAML 到 HTML 的转换需要以某种方式访问 SharePoint 中的 CAML 呈现引擎,或者重新实现它。 这两种选择都没有吸引力。
我认为您的结论(调用数据返回 Web 服务并自行渲染 HTML)可能是您最好的选择。
You could send the CAML through an XSLT stylesheet to generate HTML or XHTML.
Edit:
Considering your first question (why SharePoint returns CAML from some of its web services)... who knows? It may be there to support authoring tools such as SharePoint designer. But it seems clear from the dearth of documentation and tools that CAML is a more-or-less internal SharePoint thing. At present, performing CAML-to-HTML conversion would require either somehow accessing the CAML rendering engine within SharePoint, or re-implementing it. Neither option is attractive.
I think that your conclusion (calling data-returning web services and rendering the HTML yourself) is probably your best bet.