Hi Fabio and Thomas,
Thanks a lot.
I took some time to look at how to produce XML output in Xwiki REST API.
The job of marshaling Java object to XML is done by
restlet.ext.JAXBProvider via Restlet 1.1.10.
|@Provider
@Consumes("application/xml")
@Produces("application/xml")
class JAXBProvider extends AbstractProvider|
Similarly, our HTMLProvider can also be devised if we want to provide a
HTML output.
|@Provider
@Produces("text/html")
class HTMLProvider extends AbstractProvider|
As discussed earlier, another issue is about html page's format and content.
An easy way would be to transform XML to html page via XSLT.
I also checked the current version of Restlet (2.0.7 stable). They added
Representation class in v2.0 and plan to add Representation
transformation (i.e., XML -> HTML) in version v2.2 via XSLT. see
Therefore, I think XSLT approach might work for plain html.
Take a simple page as an example,
|<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
<page xmlns="http://www.xwiki.org">
<title>New title</title>
<content>New content</content>
</page>|
What would be the output of html page?
|<html>
<H1>Page<H1>
<p>namespace:
<p>title: New title</p>
<p>content: New content</p>
</html>
|
Best regards
Jun Han
On 5/17/2011 5:29 AM, Fabio Mancinelli wrote:
Hi Jun
On Tue, May 17, 2011 at 9:16 AM, Jun Han<jun.han37(a)gmail.com> wrote:
Dear all,
Regarding REST API for XWiki,
Source codes are in
xwiki-trunk/xwiki-platform/xwiki-platform-core/xwiki-platform-rest.
Test codes are in
xwiki-trunk/xwiki-enterprise/xwiki-enterprise-test/xwiki-enterprise-test-rest.
I hope I am looking at the correct places.
Correct.
XWiki-5820 is related to adding an endpoint for
providing a rendered
version of the page.
Does REST API need to invoke xwiki-rendering library in order to render
the html content?
There are several getRenderedContent() methods in the Document
class... It should be enough to call them.
The current implementation will return various
resources, (e.g., pages,
tags, attachments), and produce XML responses in most cases.
In XWiki-5820, only page resources will be rendered, right?
A straight-forward way may be to add additional end point (getPage and
getPageInHTML), and they will be invoked according to different Accept
http headers.
It would be great that an example can be given to show the expected
input and output.
Actually this is a good question...
The original purpose of this resource was to provide a rendered
version of a page (typically in HTML).
Now, provided that we render in HTML, how this HTML should be returned?
If we render with the complete skin we would end up with the same
content already available from http://.../xwiki/bin/view/Space/Page
So the idea was to return the "bare HTML" that could be emdedded in
other contexts.
For the input we can consider Accept headers and media parameters
(already handled by the backend)
Thanks,
Fabio
Best regards
Jun Han
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs