users@jersey.java.net

RE: [Jersey] marshalling to html templates

From: Markus Karg <markus.karg_at_gmx.net>
Date: Tue, 23 Mar 2010 19:22:03 +0100

Well, this just describes an obviously possible technical way, but it I
think it would be more interesting to learn what actual semantic translation
you like to reach: HTML is about structuring documents into chapters, so how
do you plan to structure cars, printers or fruits with HTML?

> -----Original Message-----
> From: John Calcote [mailto:john.calcote_at_gmail.com]
> Sent: Montag, 22. März 2010 22:28
> To: users_at_jersey.dev.java.net
> Cc: Markus Karg
> Subject: Re: [Jersey] marshalling to html templates
>
> I've been trying to figure out how to render POJO's into HTML documents
> for ReST API browsability. I've since discovered a mechanism that I
> think may just work for me. I'll use JAXB to marshall to XML, then (on
> detection of a request for text/html listed first in the accept header)
> use JAXP to transform XML to HTML using an XSLT style sheet.
>
> John
>
> On 3/22/2010 12:42 PM, Markus Karg wrote:
> > I can imagine that JAXB would be a perfect fit for solutions that
> natively
> > deal with documents, since HTML obviously is THE description for
> documents.
> > But I actually wonder what the sense of JAXB-to-HTML shall be like in
> a
> > generic way? I mean, how to encode a "chair", "fruit", or "car" into
> a HTML
> > document? Ain't it more the case (like Paul says) that you like to
> view
> > *descriptions* of objects (i. e. XML ---> XSL ---> HTML) instead of
> objects
> > themselves?
> >
> >
> >> -----Original Message-----
> >> From: Paul.Sandoz_at_Sun.COM [mailto:Paul.Sandoz_at_Sun.COM]
> >> Sent: Montag, 22. März 2010 11:30
> >> To: users_at_jersey.dev.java.net
> >> Subject: Re: [Jersey] marshalling to html templates
> >>
> >> Hi John,
> >>
> >> On Mar 18, 2010, at 6:18 PM, John Calcote wrote:
> >>
> >>
> >>> Has anyone ever considered using JAXB and HTML templates to
> marshall
> >>> Java objects to/from HTML?
> >>>
> >>>
> >> There is nothing specifically in JAXB support that, so it would
> >> require some addition stuff. An XML style sheet would IMHO be the
> best
> >> fit, XML to HTML or XHTML, rather than code that operates on the
> JAXB
> >> related classes.
> >>
> >>
> >>
> >>> Seems like a useful thing to do, and I've got a use case for it at
> >>> the moment. I have a ReST webapp and client that exchange XML
> >>> messages. For testing and browsability, it would be nice to support
> >>> text/html as an accept header mimetype from the browser.
> >>>
> >>> Thoughts?
> >>>
> >> That should be possible if you reference a style sheet with the XML.
> >> Browsers should be able to process the XML and apply the style
> sheet.
> >>
> >> In JAXB one can set the style sheet on the marshaller using the
> >> property:
> >>
> >> https://jaxb.dev.java.net/nonav/2.1.10/docs/
> >> vendorProperties.html#xmlheader
> >> http://n2.nabble.com/Marshaling-JAXB-objects-including-
> stylesheet-
> >> information-td2429726.html
> >>
> >> In JAX-RS/Jersey you can supply a ContextResolver<Marshaller> for
> the
> >> JAXB objects.
> >>
> >> Two alternatives if the server supports such style sheet
> >> transformation:
> >>
> >> - write a message body writer supporting JAXB and text/html and
> reuse
> >> the JAXB XML support via the injected Providers interface.
> >>
> >> - write a template provider such that one can specify the style
> sheet
> >> as a view.
> >>
> >> return new Viewable("mystylesheet.xml", myJaxbInstance);
> >>
> >> Paul.
> >>
> >>
> >> --------------------------------------------------------------------
> -
> >> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> >> For additional commands, e-mail: users-help_at_jersey.dev.java.net
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> > For additional commands, e-mail: users-help_at_jersey.dev.java.net
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net