Formatting XML documents with XSLT


The Struts Portlet Framework supports inclusion of XML content formatted with XSLT stylesheets in the portlet. To add a Struts action mapping that causes an XSLT stylesheet to be applied to an XML document, do the following:

  1. Specify className="com.ibm.wps.portlets.struts.WpsStrutsXmlActionMapping" on the mapping.

  2. Specify the path to the XML file. The easiest way to do this is with the forward attribute

  3. Specify the path or URL to the XSL Stylesheet with a set-property element with property="stylesheetUri" and the value attribute specifying the path or URL for the XSLT stylesheet.

For example, below is an action mapping from the Page Sequences example which is used to format content from the struts-config.xml file.

    <action    path="/strutsexplain"
               className="com.ibm.wps.portlets.struts.WpsStrutsXmlActionMapping"
               forward="/WEB-INF/struts-config.xml">
    <set-property property="stylesheetUri" value="/WEB-INF/StrutsConfigExplain.xsl"/>
    </action>

See also