On 05/02/2015 12:29, Sergey Beryozkin wrote:
Hi Francesco
On 05/02/15 08:13, Francesco Chicchiriccò wrote:
On 04/02/2015 14:49, Sergey Beryozkin wrote:
Hi Francesco,

Finally, not an issue but a praise for a WADL stylesheet shipped with
Syncope. I saw a recent presentation from Colm, and I thought, wow,
would it be great if CXF WADLGenerator could optionally reference such
a stylesheet via an XML processing instruction. In fact I've even
updated the generator to do it if it is configured with a reference to
a class path resource.
We've done in CXF some work for the optional Swagger integration and
Andriy Redko even did a demo. I think one of the reasons Swagger is so
popular because people can get UI auto-generated out of it.

Would it possible to get this style-sheet shipped in a self-contained
module? CXF users who need would add it to a classpath and then
configure CXF WADLGenerator with a class path reference to it...

Nice that you like our old-fashioned-technology XSLT :-)
When I built that I've also taken a look at Swagger, liked it but
had to
drop it out because of some heavy dependency (the Scala compiler).

I think WADL is very capable. I think Swagger is flying because it is
uses a JSON format (it is just more popular as opposed to more capable
than XML), has the option to add the extensions, and + UI.
WADL is more capable in describing REST services IMHO, the extensions
can be easily added, UI can be there. I'm not trying to say people have
to use WADL if they like Swagger :-), but WADL does deserve a bit more
'justice' I'd say, it was a very well designed spec from M.Hadley

If you want, and also provide some details and guidance about how to
fit
into there, I can contribute the XSL to a new CXF module and we can
have
also Syncope to depend on that. WDYT?

I'll try to create a CXF test with some basic copy/transform template
and then I'll share a link and we can discuss what might be done next

I prototyped some initial code where CXF WADLGenerator can be asked to
either add a processing instruction to a WADL DOM response or
transform it locally ([1], [2]).

I've seen your commits: the idea is to experiment with 3.0.4-SNAPSHOT,
right? (that would ease testing against Syncope, in case).

Yes or may be even 3.0.5-SNAPSHOT. Right now WADLGenerator can be linked to stylesheets in general which can help people to do minor WADL transformations or experiment with the one available at [3]...
So the idea is that a developer would update WADLGenerator with a
template reference, and then the local or browser based transformation
will happen.

A template like the one at [3] is easy enough to use as it has no
extra parameters.
I've checked Syncope WADL templates, they are a bit more involved with
JQuery being used, etc, no wonder the result is so impressive :-)

I'm not sure if it really makes sense to try and do a browser-based
transformation with Syncope templates, the local one might do.

Agree: think that the transformation we currently do in Syncope [4] is a
Servlet depending on Cocoon 3.0 (which is not strictly necessary, in
this case).
Basically, the same WADL file is processed twice: for generating
index.html (via index.xsl) and for generating schema_X_Y.html (via
index.xsl) - where X is the position of the schema in the WADL file and
Y is the schema prefix.
With index.xsl links are generated to address references in the related
schema page.

This second aspect is particularly hard to implement with simple
browser-based transformation.

OK, I understand

I'd like to experiment with the index.xsl first. It depends on JQuery
libraries being available at the web server. I think it is reasonable,
just a minor query here, can JQuery optionally tried first at CDN
first and if it is a local network only then do try a local web server ?

I'd say that we should give the opportunity to specify:

  * a local CSS (currently index.xsl embeds something very basic)
  * CDN or local references to jQuery / HighlightJS

Sure
The other question is what is the relationship between index.xsl and
schema.xsl. Can index.html import schema.xsl in principle ? Can using
index.xsl only would turn WADL to HTML ?

As explained above, index.xsl generates links to HTML pages that are
supposed to be generated via schema.xsl; this can be turned off,
naturally, but would result in a significant feature drop, to me.
Sure.

What is your opinion on index.xsl importing schema.xsl, with index.xsl delegating to schema.xsl targets when it matches a grammar, passing it the required parameters ? It is been awhile since I did some moderately complex XSLT but I vaguely recall it may be possible to do it in XSLT. If it were possible to do a single transformation only via this refactoring then WADLGenerator would most likely be able to work with index.html too.

Importing schema.xsl into index.xsl (or simply merging the two into a single XSLT, which is equivalent) can be done.

The point is that, at least for the current page design and linking, we need to have (at least) two separate HTML files: index.html and schema_X_Y.html; and for this reason two separate XSLT files are required.

Refactoring things so that a single HTML page is used for both operation description and schema information is indeed possible, but I don't think it is trivial - at least for me.

I guess it makes sense to see if this model (configuring CXF WADLGenerator with a reference to Syncope index.xsl only) works - either with a local or in-browser transform.

Agree: how are you thinking to organize such PoC? Do you want me to contribute / review something in particular? Is there any issue at CXF for this?
I've no particular plan yet. I guess it all depends on whether Syncope WADLServlet would stay as a prerequisite for 3rd party users or not.

If index.xsl importing schema.xsl can work then it would likely make sense to have a standalone module for keeping these stylesheets plus extra resources like CSS files, etc. (Syncope sub-project or module or the same in CXF but it is you who did it all so IMHO it should be in the Syncope space, but it can be discussed).

Otherwise it would likely make sense to have WADLServlet + the stylesheets be in a standalone module...

Whichever way it is done Syncope would still use WADLServlet, nno real side-effects. CXF (and other) users would either work directly with two stylesheets or indirectly via WADLServlet...

Something like that. Can you please give me a favor and check if index/schema xsl import idea works and then we can review what can be done next ?

As said above, the whole point is if we are able to have all the current features in a single HTML page: if so, producing a single XSLT is surely possible (by merging current index.xsl and schema.xsl); unfortunately, I don't see this change as trivial.

Alternatively, we can disable the schema linking from operations: in this case only a modified index.xsl is needed.

Regards.

[1] http://git-wip-us.apache.org/repos/asf/cxf/commit/28379a02
[2] http://git-wip-us.apache.org/repos/asf/cxf/commit/ad8e4ddf
[3] https://github.com/ipcsystems/wadl-stylesheet/blob/master/wadl.xsl
[4] https://github.com/apache/syncope/blob/1_2_X/core/src/main/java/org/apache/syncope/core/rest/WADLServlet.java

--
Francesco Chicchiriccò

Tirasa - Open Source Excellence
http://www.tirasa.net/

Involved at The Apache Software Foundation:
member, Syncope PMC chair, Cocoon PMC, Olingo PMC
http://people.apache.org/~ilgrosso/


Reply via email to