Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

Sponsored Links

Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs

Boost Struts with XSLT and XML

An introduction to Model 2X

  • Print
  • Feedback

Page 6 of 6

  <xsl:template match="table">
    <table cellpadding="0" cellspacing="0" border="0" bgcolor="red">
      <tr>
       <td valign="top">
          <table cellpadding="4" cellspacing="1" border="0">
            <xsl:apply-templates select="tr"/>
          </table>
        </td>
      </tr>
    </table>
  </xsl:template>
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>


Performance

Model 2X's current implementation dynamically creates an XML DOM tree and sends it to the XSLT transformer. Using SAX (Simple API for XML) notably enhances performance, particularly latency and large documents' memory footprints. In addition, stylesheet compilation improves XSLT processing times. Xalan, the Apache Project's XSLT processor, provides a mechanism to compile stylesheets into a set of Java classes, known as translets.

Client-side processing

The latest browsers, such as Internet Explorer 5/6 and Mozilla, can perform client-side transformations, which can relieve application servers' processing load. Similarly, XInclude (XML Inclusions), if supported, can download and cache resources and other data from the application server. XInclude provides a generic mechanism for recognizing and processing inclusions, and as such, can offer a simpler overall authoring experience, greater performance, and less code redundancy. This approach's drawback: developers must ensure that the XML documents and stylesheets sent to the clients contain only information the user is allowed to see.

Enhance Struts with Model 2X

In conclusion, XML and XSLT use in Model 2X encourages developers to separate business and presentation logic and brings the Web applications world a step closer to delivering on MVC's original promise. Additional benefits, such as well-formed output documents, reliance on standardized languages, increased presentation layer flexibility, and shortened development cycles make the new model not only elegant but also powerful and efficient.

You could easily improve the simple implementation described in this article to refine the model, tune performance, and add flexibility.

About the author

Julien Mercay is a senior software engineer at Orbeon, a company specializing in J2EE (Java 2 Platform, Enterprise Edition) and XML technologies. Before joining Orbeon as a Unix, Java, and XML guru, Mercay worked at Sun Microsystems where he received the Technical Achievement Award for his major contribution on Sun's Web-based auctioning system. Gilbert Bouzeid created several J2EE applications for big companies, including NEC Computer, Context Integration, and Symantec before joining Orbeon. He is well versed in e-commerce applications, particularly in databases and XML technologies.

Read more about Enterprise Java in JavaWorld's Enterprise Java section.

  • Print
  • Feedback

Resources