]>
git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.server/src/main/java/org/argeo/slc/web/mvc/XsltMarshallerView.java
af5bfd11d22e269bd646466abafe85170b053be1
2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org
.argeo
.slc
.web
.mvc
;
19 import javax
.xml
.parsers
.DocumentBuilderFactory
;
20 import javax
.xml
.transform
.Source
;
21 import javax
.xml
.transform
.dom
.DOMResult
;
22 import javax
.xml
.transform
.dom
.DOMSource
;
24 import org
.argeo
.slc
.SlcException
;
25 import org
.argeo
.slc
.core
.test
.tree
.TreeTestResult
;
26 import org
.argeo
.slc
.core
.test
.tree
.TreeTestResultCollection
;
27 import org
.argeo
.slc
.process
.SlcExecution
;
28 import org
.springframework
.oxm
.Marshaller
;
29 import org
.springframework
.web
.servlet
.view
.xslt
.XsltView
;
30 import org
.w3c
.dom
.Document
;
32 public class XsltMarshallerView
extends XsltView
{
34 private Marshaller marshaller
;
37 protected Class
<?
>[] getSourceTypes() {
38 return new Class
[] { TreeTestResult
.class,
39 TreeTestResultCollection
.class, SlcExecution
.class };
43 protected Source
convertSource(Object source
) throws Exception
{
44 Document document
= DocumentBuilderFactory
.newInstance()
45 .newDocumentBuilder().newDocument();
46 DOMResult result
= new DOMResult(document
);
47 if (!marshaller
.supports(source
.getClass()))
48 throw new SlcException("Object of type " + source
.getClass()
50 marshaller
.marshal(source
, result
);
51 return new DOMSource(result
.getNode());
54 public void setMarshaller(Marshaller marshaller
) {
55 this.marshaller
= marshaller
;