I am using struts2-2.014.
The result xml I get from the below action and Bean:
<result>
 <item>Admin</item>
 <item><entry><key>user</key><value>Admin</value</entry></item>
<item>Hello</item>
<dmodule>Included here is the proper xml for the document</dmodule>
</result>

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> 


</result>

</action>

Bean:
package admin;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
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");
        setUser(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
Synesis7
crai...@synesis7.com

Reply via email to