CAML from Sharepoint to HTML
Asked Answered
R

2

2

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.

Rosenbaum answered 30/10, 2008 at 20:11 Comment(0)
F
5

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.

Fighterbomber answered 30/10, 2008 at 20:53 Comment(2)
Trying to write an XSLT to render the CAML as HTML sounds more painful than just writing a UI on top of a standard (i.e. non-CAML) XML (as I mention in the last paragraph of my question). What exactly is the point of CAML or does it solely exist to frustrate developers?Rosenbaum
I can only imagine that the person who created it thought there was a point i.e. we need a query language that is xml. After all, XML is like violence, if it does not solve your problems your are not using enough of it. But at the end of the day all CAML actually does is frustrate the us developers.Fighterbomber
R
4

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.

Roundy answered 30/10, 2008 at 20:17 Comment(2)
I could also just stick a fork in my eye, but what good would that do?Rosenbaum
Thanks for the edit -- doing our own rendering looks like the path we're going to pursue. I thought about trying to use SharePoint's ISAPI filter somehow to do the CAML parsing/rendering for me, but I'd rather just write some UI rather than try to hack their engine.Rosenbaum

© 2022 - 2024 — McMap. All rights reserved.