struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig Christophersen" <>
Subject Struts2 XSLT result
Date Wed, 14 Jan 2009 20:00:54 GMT
I am using struts2-2.014.
The result xml I get from the below action and Bean:
<dmodule>Included here is the proper xml for the document</dmodule>

The element "dmodule" is the root element of the document from getDmod().

The top level elements are all "item" except for the one from getDmod().  My question is:
Is there a property that can be set whereby "item" is not used for all other bean methods?
If there is I can essentially pass in parameters to the xsl that way.  

struts.xml action:
<action name="updateContent" class="admin.XsltTest">

<result name="success" type="xslt">

<param name="location">/xsl/descriptive.xsl</param>

<param name="matchingPattern">{^/result}</param> 

<param name="exposedValue">{user,session,hello,dmod}</param> 



package admin;

import java.util.HashMap;
import java.util.Map;

import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.apache.struts2.interceptor.SessionAware;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
import com.opensymphony.xwork2.ActionSupport;

public class XsltTest extends ActionSupport implements SessionAware

    private Map session;
    private String user;
    File testXmlFile = new File("C:\\NewData\\080\\DMC-NFA18NIAPG65AB-000A-E92-00-0000-00000-001A-Z_000.xml");
    public String execute() throws Exception
        System.out.println("In xsl method");
        user = (String)session.get("user");
        return SUCCESS;

    public String getHello()
        return "Hello";

    public String[] getMonths()
        String months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "July", "Aug", "Sep",
"Oct", "Nov", "Dec" };
        return months;

    public Document getDmod() throws ParserConfigurationException, SAXException, IOException
     //   S7ReadXmlFile s7Read = new S7ReadXmlFile(testXmlFile);
     //   Document doc = new Document().;
       System.out.println("in getDmodule;");
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        Document doc = factory.newDocumentBuilder().parse(testXmlFile);
        return doc;

    public void setSession(Map session)
        this.session = session;

    public Map getSession()
        return session;
    public void setUser(String user)
        this.user = user;

    public String getUser()
        return user;

Craig Christophersen
Software Developer
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message