Announcement Announcement Module
No announcement yet.
Spring and XSLT Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring and XSLT

    I'm trying to get the Spring and XSLT example in the documenation to work. The documentation has an incomplete example so i'm having a hard time getting it to work. The error message i'm getting is:

    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'home' defined in null: Initialization of bean failed; nested exception is org.springframework.context.ApplicationContextExce ption: Can't load stylesheet from ServletContext resource [/WEB-INF/xsl/home.xslt] in XSLT view 'home'; nested exception is javax.xml.transform.TransformerConfigurationExcept ion: Could not compile stylesheet

    I know its loading the stylesheet but I think its not getting the XML object from my HomePage class. What should the link be between the HomePageController class and the HomePage class. Here's my code:

    package xslt;

    import java.util.Iterator;
    import java.util.List;
    import java.util.Map;

    import javax.servlet.http.*;

    import org.jdom.Element;
    import org.jdom.output.DOMOutputter;
    import org.springframework.web.servlet.view.xslt.Abstract XsltView;
    import org.w3c.dom.Node;

    public class HomePage extends AbstractXsltView {

    protected Node CreateDomNode(
    Map model, String rootName, HttpServletRequest req, HttpServletResponse res
    ) throws Exception{
    org.jdom.Document doc = new org.jdom.Document();
    Element root = new org.jdom.Element(rootName);

    List words = (List) model.get("wordlist");
    for (Iterator it = words.iterator(); it.hasNext() {
    String nextWord = (String);
    Element e = new Element("word");

    return new DOMOutputter().output( doc );

    package xslt;

    import org.springframework.web.servlet.mvc.Controller;
    import org.springframework.web.servlet.ModelAndView;

    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    import java.util.Map;
    import java.util.HashMap;
    import java.util.ArrayList;
    import java.util.List;

    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;

    public class HomePageController implements Controller {

    /** Logger for this class and subclasses */
    protected final Log logger = LogFactory.getLog(getClass());

    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {"returning home.xslt view");

    Map map = new HashMap();
    List wordlist = new ArrayList();


    map.put("wordlist", wordlist);;

    return new ModelAndView("home", map);


    <bean id="messageSource" class=" eBundleMessageSource">
    <property name="basename"><value>messages</value></property>

    <bean id="HomePageController" class="xslt.HomePageController"/>

    <bean id="HomePage" class="xslt.HomePage"/>

    <bean id="urlMapping" class="org.springframework.web.servlet.handler.Sim pleUrlHandlerMapping">
    <property name="mappings">
    <prop key="/home.htm">HomePageController</prop>
    <prop key="/priceincrease.htm">priceIncreaseForm</prop>

    <bean id="viewResolver" class="org.springframework.web.servlet.view.Resour ceBundleViewResolver">
    <property name="basename">


  • #2
    No Responses yet. Is that because nobody is using Spring and XSLT or is my problem just stupid and I should be able to figure it out on my own?


    • #3
      It sounds like your stylesheet is invalid. Make sure any <xsl:imports> and <xsl:includes> are also valid. I've been successfully using extensions to AbstractXsltView for a while as well as my own Xslt view implementations.


      • #4
        I've got the same problem.
        Does someone has any suggestions?


        • #5
          complete XSLT example?

          The spring documentation for the integration of XSLT views definitely wasn't written for folks new to Java. Assumptions are made and details are glossed over. I would love to see a simple example application that works and is explicit about what's going on.