01: /*
02: * Copyright 2005-2007 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package edu.iu.uis.eden.xml;
18:
19: import java.io.FileOutputStream;
20:
21: import javax.xml.transform.Templates;
22: import javax.xml.transform.Transformer;
23: import javax.xml.transform.TransformerFactory;
24: import javax.xml.transform.stream.StreamResult;
25: import javax.xml.transform.stream.StreamSource;
26:
27: import junit.framework.TestCase;
28:
29: import org.junit.Test;
30:
31: public class StylesheetTestCase extends TestCase {
32:
33: @Test
34: public void testTransformation() throws Exception {
35:
36: String xslInURI;
37: // Instantiate the TransformerFactory, and use it with a StreamSource
38: // XSL stylesheet to create a translet as a Templates object.
39: TransformerFactory tFactory = TransformerFactory.newInstance();
40: Templates translet = tFactory.newTemplates(new StreamSource(
41: getClass().getClassLoader().getResourceAsStream(
42: "edu/iu/uis/eden/edoclite/edlstyle.xsl")));
43: // ...
44: String xmlInURI;
45: String htmlOutURI;
46: String xmlInURI2;
47: String htmlOutURI2;
48: // ...
49: // For each thread, instantiate a new Transformer, and perform the
50: // transformations on that thread from a StreamSource to a StreamResult;
51: Transformer transformer = translet.newTransformer();
52: transformer.transform(new StreamSource(getClass()
53: .getClassLoader().getResourceAsStream(
54: "edu/iu/uis/eden/edoclite/edldoccontent.xml")),
55: new StreamResult(
56: new FileOutputStream("SampleHTML.html")));
57: int i = 0;
58: }
59:
60: }
|