The following example uses the widgetorders XML document shown earlier, and this XSLT template:

<?xml version="1.0"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:template match="widget-orders">
  <table>
     <tr>
       <td>Order Id</td>
       <td>Order Status</td>
     </tr>
   <xsl:for-each select="order[@account='86666']">

     <xsl:sort select="@id"/>
       <tr>
         <td> <xsl:value-of select="@id"/> </td>
         <td> <xsl:value-of select="order-status"/> </td>
       </tr>

   </xsl:for-each>
   </table>

</xsl:template>
</xsl:stylesheet>

The example uses the servlet bean XMLTransform as follows:

<dsp:droplet name="/atg/dynamo/droplet/xml/XMLTransform">
     <dsp:param name="input" value="orders.xml"/>
     <dsp:param name="template" value="orders-template.xsl"/>

     <dsp:oparam name="failure">
       Failure to transform XML document: <dsp:valueof param="input"/>
       <br/>
     </dsp:oparam>
</dsp:droplet>

The orders.xml document is transformed by this template to yield the same output as shown in the XMLToDOM example shown earlier (in Processing XML in a JSP). The XSLT template performs the same selection and formatting as the servlet beans XMLToDOM, NodeForEach, and NodeMatch.


Copyright © 1997, 2014 Oracle and/or its affiliates. All rights reserved. Legal Notices