Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Generate Web Output in Multiple Formats and Languages with StrutsCX : Page 2

StrutsCX overcomes the limitations of the Struts Framework by enabling you to utilize XML, XSLT, and XPath technologies instead of its standard JavaServer Pages.


advertisement
How XSLT Fits In
XSLT is an official W3C standard for a flexible and powerful language that transforms the structure of XML data into text, PDF, HTML/XHTML, WML, VoiceXML, or any other XML format. An XSLT processor like Xalan or Saxon actually performs the transformation by using an XSL Stylesheet, which itself is an XML document (see Figure 3).

You define rules for the transformation of your XML data inside the XSL Stylesheet. The XSLT processor uses these rules during transformation. You also can use XPath expressions inside your XSL Stylesheet to select parts of your XML document in a compact manner.

Figure 3: Principle of XSLT Transformation



The basic concept behind XSLT/XPath is to separate XML data from its presentation. The same data can easily be presented in different forms and formats to suit different output devices. All the while, the input XML document stays unchanged. For each additional output format you just define another XSL Stylesheet. For a Struts application, this means you can:

  • Represent all your data in the form of an XML document
  • Transform this document (with the help of an XSL Stylesheet) into any data format you like
  • Of course you can generate your XML document in memory; it's not necessary to work with physical files. You can create the XML document as a Java object and hand it directly to the XSLT processor, which enhances performance incredibly.

    StrutsCX: Struts with XSLT
    StrutsCX combines the elegance of Struts with the power of XSLT. StrutsCX replaces the JSP of the View with XSLT while leaving the Controller and the Model part of Struts untouched.

    Figure 4 illustrates the differences between Struts and StrutsCX. In the View, StrutsCX does not forward to a JavaServer Page but to a servlet, which organizes the construction of an XML-Output-Document object as well as the transformation of this object with an XSL Stylesheet. If an ActionForm Bean is present, the Action copies it to the HttpServletRequest, which is also added to the XML-Output-Document. Similar to Struts, the job of the StrutsCX Action is to mediate between the presentation tier and the other tiers of the Web or J2EE architecture, the business and integrations tiers.

    Figure 4: The StrutsCX Architecture

    StrutsCX behaves differently than Struts in the following aspects:

  • In the View, StrutsCX uses XSLT instead of JSP.
  • Internationalization is not realized through the Java Resource Bundle technique but through a pure XML solution.
  • StrutsCX does not need any Tag Libraries to present error messages. It uses W3C standards like XML and XSLT/Xpath instead.
  • Despite their differences, you can use StrutsCX in parallel with your existing Struts application. StrutsCX merely abandons some of the standard Struts features and replaces them with XML, XSLT, and XPath.



    Comment and Contribute

     

     

     

     

     


    (Maximum characters: 1200). You have 1200 characters left.

     

     

    Sitemap