users@jersey.java.net

RE: [Jersey] marshalling to html templates

From: Markus Karg <markus.karg_at_gmx.net>
Date: Wed, 24 Mar 2010 21:34:31 +0100

So you are not targeting in a WebService (= machine readable, XML) but more
in a WebApplication (= human readable, XHTML)? Then certainly XHTML is the
best choice. But if your only problem is marking links as links, then XLink
possibly is what you are searching for actually, since there is no need to
move over to HTML then.

> -----Original Message-----
> From: John Calcote [mailto:john.calcote_at_gmail.com]
> Sent: Dienstag, 23. März 2010 21:15
> To: users_at_jersey.dev.java.net
> Cc: Markus Karg
> Subject: Re: [Jersey] marshalling to html templates
>
> Well, mainly our objects are represented by XML data structures, many
> of
> which contain references to other resources; this is a restful web
> service that runs on XML. I know that restful web services can also be
> run very well on XHTML, which lends itself naturally to browsability.
> But JAXB supports XML (and JSON), not XHTML, so our service runs on
> XML,
> which isn't quite as easy to browse. Browsers do a good job of
> rendering
> XML generically, but can't tell the difference between a string and a
> link. I'd like to be able to transform the XML (perhaps using a style
> sheet) into something containing clickable links rather than simple
> strings at the appropriate places, so I don't have to manually modify
> the URL in my browser based on the contents of the XML doc I'm viewing.
>
> John
>
> On 3/23/2010 12:22 PM, Markus Karg wrote:
> > 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
> >>
> >
> > ---------------------------------------------------------------------
> > 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