]>
git.argeo.org Git - gpl/argeo-slc.git/blob - legacy/runtime/org.argeo.slc.server/src/main/java/org/argeo/slc/web/mvc/XsltMarshallerView.java
2 * Copyright (C) 2007-2012 Mathieu Baudier
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.
16 package org
.argeo
.slc
.web
.mvc
;
18 import javax
.xml
.parsers
.DocumentBuilderFactory
;
19 import javax
.xml
.transform
.Source
;
20 import javax
.xml
.transform
.dom
.DOMResult
;
21 import javax
.xml
.transform
.dom
.DOMSource
;
23 import org
.argeo
.slc
.SlcException
;
24 import org
.argeo
.slc
.core
.test
.tree
.TreeTestResult
;
25 import org
.argeo
.slc
.core
.test
.tree
.TreeTestResultCollection
;
26 import org
.argeo
.slc
.process
.SlcExecution
;
27 import org
.springframework
.oxm
.Marshaller
;
28 import org
.springframework
.web
.servlet
.view
.xslt
.XsltView
;
29 import org
.w3c
.dom
.Document
;
31 public class XsltMarshallerView
extends XsltView
{
33 private Marshaller marshaller
;
36 protected Class
<?
>[] getSourceTypes() {
37 return new Class
[] { TreeTestResult
.class,
38 TreeTestResultCollection
.class, SlcExecution
.class };
42 protected Source
convertSource(Object source
) throws Exception
{
43 Document document
= DocumentBuilderFactory
.newInstance()
44 .newDocumentBuilder().newDocument();
45 DOMResult result
= new DOMResult(document
);
46 if (!marshaller
.supports(source
.getClass()))
47 throw new SlcException("Object of type " + source
.getClass()
49 marshaller
.marshal(source
, result
);
50 return new DOMSource(result
.getNode());
53 public void setMarshaller(Marshaller marshaller
) {
54 this.marshaller
= marshaller
;