]>
git.argeo.org Git - gpl/argeo-slc.git/blob - XsltMarshallerView.java
127188b842a8caf112ea357dc6e18751d4c11eb4
1 package org
.argeo
.slc
.web
.mvc
;
3 import javax
.xml
.parsers
.DocumentBuilderFactory
;
4 import javax
.xml
.transform
.Source
;
5 import javax
.xml
.transform
.dom
.DOMResult
;
6 import javax
.xml
.transform
.dom
.DOMSource
;
8 import org
.argeo
.slc
.core
.SlcException
;
9 import org
.springframework
.oxm
.Marshaller
;
10 import org
.springframework
.web
.servlet
.view
.xslt
.XsltView
;
11 import org
.w3c
.dom
.Document
;
13 public class XsltMarshallerView
extends XsltView
{
15 private Marshaller marshaller
;
18 protected Class
<?
>[] getSourceTypes() {
19 return new Class
[] { Object
.class };
23 protected Source
convertSource(Object source
) throws Exception
{
24 Document document
= DocumentBuilderFactory
.newInstance()
25 .newDocumentBuilder().newDocument();
26 DOMResult result
= new DOMResult(document
);
27 if (!marshaller
.supports(source
.getClass()))
28 throw new SlcException("Object of type " + source
.getClass()
30 marshaller
.marshal(source
, result
);
31 return new DOMSource(result
.getNode());
34 public void setMarshaller(Marshaller marshaller
) {
35 this.marshaller
= marshaller
;