1   /*
2    * Copyright 2001-2004 The Apache Software Foundation.
3    * 
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
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
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.
15   */
16  package org.saxbenchmark;
17  
18  import java.io.FileReader;
19  
20  import junit.framework.TestCase;
21  
22  import org.apache.xml.serialize.HTMLSerializer;
23  import org.apache.xml.serialize.OutputFormat;
24  import org.xml.sax.InputSource;
25  import org.xml.sax.XMLReader;
26  import org.xml.sax.helpers.XMLReaderFactory;
27  
28  /***
29   * @author JMcCrindle
30   */
31  public class HotSaxTest extends TestCase {
32      public void testHotSax() throws Exception {
33          XMLReader reader = XMLReaderFactory.createXMLReader("hotsax.html.sax.SaxParser");
34        HTMLSerializer serializer = new HTMLSerializer();
35        OutputFormat outputFormat = new OutputFormat();
36        outputFormat.setNonEscapingElements(new String[] {"script"});
37        outputFormat.setCDataElements(new String[] {"script"});
38        outputFormat.setIndent(1);
39        outputFormat.setIndenting(true);
40        outputFormat.setPreserveSpace(true);
41        serializer.setOutputFormat(outputFormat);
42        serializer.setOutputByteStream(System.out);
43  
44  //        XMLWriter serializer = new XMLWriter();
45  //        serializer.setHTMLMode(true);
46  //        serializer.setOutput(new OutputStreamWriter(System.out));
47          
48  //      SerializerToHTML serializer = new SerializerToHTML();
49  //      serializer.setSpecialEscapeURLs(true);
50  //      Properties properties = new Properties();
51  //      serializer.setOutputFormat(properties);
52  //      serializer.setOutputStream(System.out);
53          reader.setContentHandler(serializer);
54          reader.parse(new InputSource(new FileReader("./src/data/simple.html")));
55      }
56  }