1 /* 2 * File: XsltView.java 3 * Created: 30.05.2007 12:09:19 4 * 5 * Copyright 2007 Michal Burda. 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 */ 21 22 package net.sf.webmancer.out.xslt; 23 24 import java.util.Map; 25 26 import javax.servlet.http.HttpServletRequest; 27 import javax.servlet.http.HttpServletResponse; 28 import javax.xml.transform.Source; 29 import javax.xml.transform.dom.DOMSource; 30 31 import net.sf.webmancer.model.dom.DOMModeler; 32 33 import org.springframework.web.servlet.view.xslt.AbstractXsltView; 34 import org.w3c.dom.Document; 35 36 /** 37 * @author Michal Burda 38 * 39 */ 40 public class XsltView extends AbstractXsltView { 41 /** 42 * 43 */ 44 public static final String DEFAULT_WEBMANCER_CONTENT_TYPE = "text/html; charset=UTF-8"; 45 46 /** 47 * Constructs the XsltView. 48 * 49 */ 50 public XsltView() { 51 super(); 52 setContentType(DEFAULT_WEBMANCER_CONTENT_TYPE); 53 } 54 55 /** 56 * @see org.springframework.web.servlet.view.xslt.AbstractXsltView#createXsltSource(java.util.Map, java.lang.String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) 57 */ 58 @Override 59 protected Source createXsltSource(Map model, String rootName, HttpServletRequest request, HttpServletResponse response) throws Exception { 60 Document document = (Document) model.get(DOMModeler.MODEL_OBJECT_NAME); 61 return new DOMSource(document); 62 } 63 64 /** 65 * @throws UnsupportedOperationException because setting the root is not supported 66 * 67 * @see org.springframework.web.servlet.view.xslt.AbstractXsltView#setRoot(java.lang.String) 68 */ 69 @Override 70 public void setRoot(String root) { 71 throw new UnsupportedOperationException("Method setRoot() is not supported by " + this.getClass().getName()); 72 } 73 74 }