// Path: src/main/java/net/nordu/mdx/utils/XMLUtils.java
// public class XMLUtils {
// 
// 	public static byte[] o2b(XmlObject o) throws IOException {
// 		ByteArrayOutputStream out = new ByteArrayOutputStream();
//         writeObject(o,out);
//         return out.toByteArray();
// 	}
// 	
// 	public static void writeObject(XmlObject o, OutputStream out) throws IOException {
// 		XmlOptions opts = new XmlOptions();
// 		
// 		opts.setSaveOuter();
//         opts.setSavePrettyPrint();
//         opts.setSaveAggressiveNamespaces();
//         o.save(out,opts);
// 	}
// 	
// 	public static String o2s(XmlObject o) throws IOException {
// 		return new String(o2b(o));
// 	}
// 	
// }


import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.nordu.mdx.utils.XMLUtils;
import org.apache.xmlbeans.XmlObject;
import org.springframework.web.servlet.View;
package net.nordu.mdx.spring;





public class PrettyPrintXmlBeansView implements View {

	private String contentType;
	
	public void setContentType(String contentType) {
		this.contentType = contentType;
	}
	
	public String getContentType() {
		return contentType;
	}

	public PrettyPrintXmlBeansView() { }
	
	protected XmlObject findXmlObject(Map<String, ?> map) {
		for (Map.Entry<String, ?> e : map.entrySet()) {
			if (e.getValue() instanceof XmlObject) {
				return (XmlObject)e.getValue();
			}
		}
		
		return null;
	}
	
	public void render(Map<String, ?> map, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		XmlObject o = findXmlObject(map);
		if (o != null)
// Path: src/main/java/net/nordu/mdx/utils/XMLUtils.java
// public class XMLUtils {
// 
// 	public static byte[] o2b(XmlObject o) throws IOException {
// 		ByteArrayOutputStream out = new ByteArrayOutputStream();
//         writeObject(o,out);
//         return out.toByteArray();
// 	}
// 	
// 	public static void writeObject(XmlObject o, OutputStream out) throws IOException {
// 		XmlOptions opts = new XmlOptions();
// 		
// 		opts.setSaveOuter();
//         opts.setSavePrettyPrint();
//         opts.setSaveAggressiveNamespaces();
//         o.save(out,opts);
// 	}
// 	
// 	public static String o2s(XmlObject o) throws IOException {
// 		return new String(o2b(o));
// 	}
// 	
// }


// Path: src/main/java/net/nordu/mdx/spring/PrettyPrintXmlBeansView.java
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.nordu.mdx.utils.XMLUtils;
import org.apache.xmlbeans.XmlObject;
import org.springframework.web.servlet.View;

package net.nordu.mdx.spring;





public class PrettyPrintXmlBeansView implements View {

	private String contentType;
	
	public void setContentType(String contentType) {
		this.contentType = contentType;
	}
	
	public String getContentType() {
		return contentType;
	}

	public PrettyPrintXmlBeansView() { }
	
	protected XmlObject findXmlObject(Map<String, ?> map) {
		for (Map.Entry<String, ?> e : map.entrySet()) {
			if (e.getValue() instanceof XmlObject) {
				return (XmlObject)e.getValue();
			}
		}
		
		return null;
	}
	
	public void render(Map<String, ?> map, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		XmlObject o = findXmlObject(map);
		if (o != null)
			XMLUtils.writeObject(o, response.getOutputStream());