You can use XML transformation servlet beans together with targeting servlet beans. The following example applies XMLTransform to the results obtained by TargetingForEach, as follows:

Note: This example assumes that a display template is associated with the XML documents. For more information about XML transformation and templates, seeTransforming XML Documents with Templates.

<dsp:droplet name="/atg/targeting/TargetingForEach">
  <dsp:param bean="/atg/registry/RepositoryTargeters/myXmlRepository"
  name="targeter"/>
  <dsp:oparam name="outputStart">
    <b> Formatted Output </b>
     <ul>
  </dsp:oparam>

  <dsp:oparam name="output">

     <dsp:droplet name="/atg/dynamo/droplet/xml/XMLTransform">
     <dsp:param name="input" param="element.document"/>
     <dsp:oparam name="failure">
       Failure to transform XML document: <dsp:valueof param="input"/>
       <br/>
     </dsp:oparam>
     </dsp:droplet>

  </dsp:oparam>
  <dsp:oparam name="outputEnd">
     </ul>
  </dsp:oparam>
</dsp:droplet>
Optimizing performance

Transforming an XML document into a DOM object can incur considerable overhead. To obtain better performance, you can make some part of an XML document an attribute of the content item. In this way, you can access these attributes directly, rather than first transform the XML to a DOM and manipulate the DOM, or apply a template to the whole document.

For example, in the Quincy Funds demo application, the Funds list at fundlist.jsp uses a targeter to locate and display the names and symbols of all stock funds. The fund descriptions are XML documents. Rather than transform the XML document into DOM objects and extract their fund name and symbol properties, the Funds repository treats the fundName and symbol as attributes of the repository item. Parsing an XML document into a DOM object for display occurs only when a user wants to view the entire XML fund description.

<dsp:droplet name="/atg/targeting/TargetingForEach">
   <dsp:param bean="/atg/registry/RepositoryTargeters/Funds/stockFunds"
   name="targeter"/>
   <dsp:oparam name="outputStart">
     <b>Stock Mutual Funds </b>
     <ul>
   </dsp:oparam>
   <dsp:oparam name="output">
     <dsp:a href="fund.jsp">
        <dsp:param name="ElementId" param="element.repositoryId"/>
        <dsp:valueof param="element.fundName"/></dsp:a> -
     <dsp:valueof param="element.Symbol"/><br/>
   </dsp:oparam>
   <dsp:oparam name="outputEnd">
     </ul>
   </dsp:oparam>
</dsp:droplet>