[Opensource] xsl handling: make it like JSP handling?
Michael Rimov
rimovm at centercomp.com
Fri May 9 20:17:58 PDT 2003
At 03:51 PM 5/9/2003 -0700, larry hamel wrote:
>I like the idea of encapsulating the code in XMLViewHandler.java, but in
>your counter-proposal, there is a large discrepancy between forwards of
>JSP type and forwards of the proposed xsl type. In other words, if
>Expresso documents and current practices all describe forwards like
>
> <forward name="displayItem"
> path="/jsp/groupAction/displayItem.jsp"/>
>
>then it would be natural to misunderstand a forward like
>
> <forward name="rootTree"
> path="/servlet/XMLViewHandler/xsl/rootTree.xsl"/>
>
>and it would require referring to documentation. In contrast, the original
>proposal makes .xsl files roughly equivalent to .jsp files at least for
>configuration purposes:
>
> <forward name="displayItem"
> path="/jsp/groupAction/displayItem.jsp"/>
> <forward name="rootTree" path="/xsl/rootTree.xsl"/>
Ok, fair enough... I'm with you so far.
>Consider that there are many examples of mimetype extensions being used
>for parsing purposes. JavaBeans use this with the JAF. I think Expresso
>will add a lot by parsing for a .xsl extension and handling it appropriately.
>One alternative would be to use something like
>
> <forward name="rootTree" path="xml?xsl=/xsl/rootTree.xsl"/>
>
>which makes it a little more obvious that something is going on, and even
>offers a way to add arbitrary parameters. But recognizing .xsl extension
>just seems nicer to me.
Yes, and this looks awful :) [As does
/servlet/XmlViewHandler?xsl=blah] So let's scrap this train of thought....
>One thing I can encapsulate is the file path elaboration. Instead of doing
>that in the controller, it can be placed into XMLViewHandler.java, so that
>the processing code in Controller.java becomes:
>
>// xsl processing
>if (fwd != null) {
> String path = fwd.getPath();
> if (path != null && path.endsWith(".xsl")) {
> fwd = mapping.findForward("xml");
> req.setParameter("xsl", path);
> }
>}
Great. Can you refactor this code into a "getActionForward()" or something
like this in the Controller code? Then we can easily refactor the code to
add multiple forward types, without cluttering up the main flow of control.
[Consider velocity template names, Cocoon server pages, etc].
Also, minor quibble, can you check for .xsl and .xslt? I always use xslt
in my own development. :) In fact, you might want to get the final file
extension so we can case insensitive compare it for all our Windows
developers. [I sure make things complicated, don't I? ;) ]
>while the path manipulation moves to XMLViewHandler.java and becomes
>
> // determine whether the xsl path is relative
> File xslFile = new File(xsltName);
> if (!xslFile.exists()) {
> xslFile = new File(mRootPath, xsltName);
> if (!xslFile.exists()) {
> log.error("cannot find xsl file: " + xsltName);
> }
> }
>
>can you live with that?
Fair enough!! +1 from me. I'm all for making other rendering format first
class citizens in Expresso!
Thanks for the improvement thoughts!!
-Mike
More information about the Opensource
mailing list