You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jeff Smith <je...@centralscheduling.net> on 2003/03/11 22:51:27 UTC

Model 2 with a half-order of X

I've got a situation where a lot of the content in my app is going to be
based on structured documents that are pulled from my database.

I'd like to be able to create an XML representation of this doc (at display
time) and then apply a user-selected XSLT to transform the doc into a couple
of different structures (perhaps a summary view, a detailed view and a
change-log view) before finally applying some style sheets (CSS or XSL) to
display it.

I've looked at Model2X and StrutsCX, but they're way overkill for my needs.
I'm quite happy with struts/JSP for my site layout and navigation. I don't
want to re-write my entire site just to transform a few document pages.

Does anybody have any suggestions for how to do XML generation and XSLT
transformation from within an Action method?

I imagine doing this with a two-step action. Step one is a docPreparation
step that creates the XML and does the content transformation. Step 2
(chained from step 1) would then render the doc to the tile that I'm using
for doc presentation.

Any pointers would be appreciated.

Jefficus


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Model 2 with a half-order of X

Posted by Robert McIntosh <ro...@bull-enterprises.com>.
If you go with JAXP, you can plug in your parser of choice, such as 
Xerces/Xalan. You can also plugin Dom4J (www.dom4j.org), if you want a 
lighter weight DOM model. I haven't used it yet personally, but they 
have some nice features, support JAXP (among others), built on the 
Collections API and they have some benchmarks for comparisons.

~Robert

Jeff Smith wrote:

>Thanks to all who responded. After reading those suggestions and wading
>through the billion or so pages on XML technologies, I'm going to tackle it
>this way:
>
>1) I'm already using header/footer/body tiles to construct the pages, so I
>can isolate my problem to just generating the doc itself in the document
>display tile.
>
>2) I'm going to use a three-step action to view the doc.
>    Step 1: Assemble the doc from the database elements into an XML DOM bean
>and stick that in the request scope.
>    Step 2: Chain to another action that applies content summarization
>filters and places an HTML fragment into the request scope
>    Step 3: Render the fragment into the tile (via the JSP) and rely on CSS
>classes to "skin" the display on the client side
>    (Although, steps 1 and 2 may collapse into a single action when I get
>into the thick of it.)
>
>I'll post a summary of results back here if anybody is interested.
>
>Does anybody have any recommendations regarding the merits of JAXP vs.
>Xerces/Xalan or maybe a plug for a 3rd alternative for implementing the XML
>engine stuff? (I'm particularly interested in notes on performance and
>ease-of-use.)
>
>Jefficus
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: Model 2 with a half-order of X

Posted by Patrick Peak <pa...@browsermedia.com>.
Another alternative ..

1) have the Action handle the DOM bean
2) Attach a Tiles Controller to your body tile that can do the final view
preparation, with CSS help.

Your steps 2 and 3 sound like "view presentation logic" that probably makes
sense to put into a Tile, rather than an Action. This also avoids Action
chaining.

Patrick

For more info on controllers see
http://blogs.browsermedia.com/patrick/index.do?date=20030211.


-----Original Message-----
From: Jeff Smith [mailto:jeffs@centralscheduling.net]
Sent: Wednesday, March 12, 2003 12:03 PM
To: Struts Users Mailing List
Subject: Re: Model 2 with a half-order of X


Thanks to all who responded. After reading those suggestions and wading
through the billion or so pages on XML technologies, I'm going to tackle it
this way:

1) I'm already using header/footer/body tiles to construct the pages, so I
can isolate my problem to just generating the doc itself in the document
display tile.

2) I'm going to use a three-step action to view the doc.
    Step 1: Assemble the doc from the database elements into an XML DOM bean
and stick that in the request scope.
    Step 2: Chain to another action that applies content summarization
filters and places an HTML fragment into the request scope
    Step 3: Render the fragment into the tile (via the JSP) and rely on CSS
classes to "skin" the display on the client side
    (Although, steps 1 and 2 may collapse into a single action when I get
into the thick of it.)

I'll post a summary of results back here if anybody is interested.

Does anybody have any recommendations regarding the merits of JAXP vs.
Xerces/Xalan or maybe a plug for a 3rd alternative for implementing the XML
engine stuff? (I'm particularly interested in notes on performance and
ease-of-use.)

Jefficus




---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Model 2 with a half-order of X

Posted by Jeff Smith <je...@centralscheduling.net>.
Thanks to all who responded. After reading those suggestions and wading
through the billion or so pages on XML technologies, I'm going to tackle it
this way:

1) I'm already using header/footer/body tiles to construct the pages, so I
can isolate my problem to just generating the doc itself in the document
display tile.

2) I'm going to use a three-step action to view the doc.
    Step 1: Assemble the doc from the database elements into an XML DOM bean
and stick that in the request scope.
    Step 2: Chain to another action that applies content summarization
filters and places an HTML fragment into the request scope
    Step 3: Render the fragment into the tile (via the JSP) and rely on CSS
classes to "skin" the display on the client side
    (Although, steps 1 and 2 may collapse into a single action when I get
into the thick of it.)

I'll post a summary of results back here if anybody is interested.

Does anybody have any recommendations regarding the merits of JAXP vs.
Xerces/Xalan or maybe a plug for a 3rd alternative for implementing the XML
engine stuff? (I'm particularly interested in notes on performance and
ease-of-use.)

Jefficus


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: Model 2 with a half-order of X

Posted by Kris Schneider <kr...@dotech.com>.
If you're able to use JSTL, it makes it pretty easy to leverage a JSP for both
the creation of the XML document and the application of a transformation:

<x:transform xslt="${style}">
  <!-- body specifies XML document and transform params -->
</x:transform>

You can also capture the result of the transformation as an org.w3c.dom.Document:

<x:transform xslt="${style}" var="xformDoc" scope="request">
  <!-- body specifies XML document and transform params -->
</x:transform>

or a javax.xml.transform.Result:

<x:transform xslt="${style}" result="${xformResult}">
  <!-- body specifies XML document and transform params -->
</x:transform>

Quoting James CE Johnson <jc...@tragus.org>:

> > Jeff,
> >
> > I haven't tried this before, but it seems like one solution would be to
> > generate your XML doc in the Action (or some delegate) and place it in
> > the appropriate scope and then use XTags
> > (http://jakarta.apache.org/taglibs/doc/xtags-doc/intro.html) to
> > transform the doc.
> >
> > Another solution, would be to generate the XML doc and transform it in
> > the Action (or delegate) and then write directly to the response output
> > stream and return a null ActionForward which will tell Struts that the
> > response has been handled. Ofcourse, you will have to render the entire
> > page (header, body, footer).
> 
> You can aleviate that by using tiles. Create a layout that does your
> header/body/footer inclusions. Then your 'body 'provider can do the XML
> transformation as you describe.
> 
> >
> > You may also want to look into Cocoon. I believe its just servlet,
> > instead of
> > an entire framework, which can be used to transform XML docs.
> >
> > HTH,
> >
> > robert
> >
> >> -----Original Message-----
> >> From: Jeff Smith [mailto:jeffs@centralscheduling.net]
> >> Sent: Tuesday, March 11, 2003 4:51 PM
> >> To: Struts Users Mailing List
> >> Subject: Model 2 with a half-order of X
> >>
> >>
> >> I've got a situation where a lot of the content in my app is going to
> >> be based on structured documents that are pulled from my database.
> >>
> >> I'd like to be able to create an XML representation of this doc
> >> (at display
> >> time) and then apply a user-selected XSLT to transform the doc
> >> into a couple
> >> of different structures (perhaps a summary view, a detailed view and a
> >> change-log view) before finally applying some style sheets (CSS or
> >> XSL) to display it.
> >>
> >> I've looked at Model2X and StrutsCX, but they're way overkill for my
> >> needs.
> >> I'm quite happy with struts/JSP for my site layout and navigation. I
> >> don't want to re-write my entire site just to transform a few document
> >> pages.
> >>
> >> Does anybody have any suggestions for how to do XML generation and
> >> XSLT transformation from within an Action method?
> >>
> >> I imagine doing this with a two-step action. Step one is a
> >> docPreparation step that creates the XML and does the content
> >> transformation. Step 2 (chained from step 1) would then render the doc
> >> to the tile that I'm using for doc presentation.
> >>
> >> Any pointers would be appreciated.
> >>
> >> Jefficus
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org For
> >> additional commands, e-mail: struts-user-help@jakarta.apache.org
> >>
> >>
> >
> >
> > --------------------------------------------------------------------- To
> > unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org For
> > additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 


-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: Model 2 with a half-order of X

Posted by James CE Johnson <jc...@tragus.org>.
> Jeff,
>
> I haven't tried this before, but it seems like one solution would be to
> generate your XML doc in the Action (or some delegate) and place it in
> the appropriate scope and then use XTags
> (http://jakarta.apache.org/taglibs/doc/xtags-doc/intro.html) to
> transform the doc.
>
> Another solution, would be to generate the XML doc and transform it in
> the Action (or delegate) and then write directly to the response output
> stream and return a null ActionForward which will tell Struts that the
> response has been handled. Ofcourse, you will have to render the entire
> page (header, body, footer).

You can aleviate that by using tiles. Create a layout that does your
header/body/footer inclusions. Then your 'body 'provider can do the XML
transformation as you describe.

>
> You may also want to look into Cocoon. I believe its just servlet,
> instead of
> an entire framework, which can be used to transform XML docs.
>
> HTH,
>
> robert
>
>> -----Original Message-----
>> From: Jeff Smith [mailto:jeffs@centralscheduling.net]
>> Sent: Tuesday, March 11, 2003 4:51 PM
>> To: Struts Users Mailing List
>> Subject: Model 2 with a half-order of X
>>
>>
>> I've got a situation where a lot of the content in my app is going to
>> be based on structured documents that are pulled from my database.
>>
>> I'd like to be able to create an XML representation of this doc
>> (at display
>> time) and then apply a user-selected XSLT to transform the doc
>> into a couple
>> of different structures (perhaps a summary view, a detailed view and a
>> change-log view) before finally applying some style sheets (CSS or
>> XSL) to display it.
>>
>> I've looked at Model2X and StrutsCX, but they're way overkill for my
>> needs.
>> I'm quite happy with struts/JSP for my site layout and navigation. I
>> don't want to re-write my entire site just to transform a few document
>> pages.
>>
>> Does anybody have any suggestions for how to do XML generation and
>> XSLT transformation from within an Action method?
>>
>> I imagine doing this with a two-step action. Step one is a
>> docPreparation step that creates the XML and does the content
>> transformation. Step 2 (chained from step 1) would then render the doc
>> to the tile that I'm using for doc presentation.
>>
>> Any pointers would be appreciated.
>>
>> Jefficus
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org For
>> additional commands, e-mail: struts-user-help@jakarta.apache.org
>>
>>
>
>
> --------------------------------------------------------------------- To
> unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org For
> additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: Model 2 with a half-order of X

Posted by Robert Taylor <rt...@mulework.com>.
Jeff,

I haven't tried this before, but it seems like one solution would be
to generate your XML doc in the Action (or some delegate) and place
it in the appropriate scope and then use XTags
(http://jakarta.apache.org/taglibs/doc/xtags-doc/intro.html) to transform
the doc.

Another solution, would be to generate the XML doc and transform it in the
Action (or delegate) and then write directly to the response output stream
and return a null ActionForward which will tell Struts that the response
has been handled. Ofcourse, you will have to render the entire page (header,
body, footer).

You may also want to look into Cocoon. I believe its just servlet, instead
of
an entire framework, which can be used to transform XML docs.

HTH,

robert

> -----Original Message-----
> From: Jeff Smith [mailto:jeffs@centralscheduling.net]
> Sent: Tuesday, March 11, 2003 4:51 PM
> To: Struts Users Mailing List
> Subject: Model 2 with a half-order of X
>
>
> I've got a situation where a lot of the content in my app is going to be
> based on structured documents that are pulled from my database.
>
> I'd like to be able to create an XML representation of this doc
> (at display
> time) and then apply a user-selected XSLT to transform the doc
> into a couple
> of different structures (perhaps a summary view, a detailed view and a
> change-log view) before finally applying some style sheets (CSS or XSL) to
> display it.
>
> I've looked at Model2X and StrutsCX, but they're way overkill for
> my needs.
> I'm quite happy with struts/JSP for my site layout and navigation. I don't
> want to re-write my entire site just to transform a few document pages.
>
> Does anybody have any suggestions for how to do XML generation and XSLT
> transformation from within an Action method?
>
> I imagine doing this with a two-step action. Step one is a docPreparation
> step that creates the XML and does the content transformation. Step 2
> (chained from step 1) would then render the doc to the tile that I'm using
> for doc presentation.
>
> Any pointers would be appreciated.
>
> Jefficus
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org