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.FileInputStream;
19  import java.io.OutputStreamWriter;
20  
21  import junit.framework.TestCase;
22  
23  import org.apache.xml.serializer.ToHTMLStream;
24  import org.ccil.cowan.tagsoup.XMLWriter;
25  import org.xml.sax.InputSource;
26  import org.xml.sax.XMLReader;
27  import org.xml.sax.helpers.XMLReaderFactory;
28  
29  /***
30   * @author JMcCrindle
31   */
32  public class TagSoupTest extends TestCase {
33      public void testHotSax() throws Exception {
34          XMLReader reader = XMLReaderFactory.createXMLReader("org.ccil.cowan.tagsoup.Parser");
35          //reader.setFeature("http://cyberneko.org/html/features/scanner/notify-builtin-refs", true);
36  
37          //        reader.setFeature("http://xml.org/sax/features/namespaces", true);
38  //        reader.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
39        //SerializerFactory serializerFactory = SerializerFactory.getSerializerFactory("html");
40  //        ToHTMLStream serializer = new ToHTMLStream();
41        //OutputFormat outputFormat = new OutputFormat();
42        //outputFormat.setNonEscapingElements(new String[] {"script"});
43        //outputFormat.setCDataElements(new String[] {"script"});
44        //outputFormat.setIndent(1);
45        //outputFormat.setIndenting(true);
46        //outputFormat.setPreserveSpace(true);
47        //serializer.setOutputFormat(outputFormat);
48        //Serializer serializer = serializerFactory.makeSerializer(outputFormat);
49        //serializer.setWriter(new OutputStreamWriter(System.out));
50          
51          XMLWriter serializer = new XMLWriter();
52          serializer.setHTMLMode(true);
53          serializer.setOutput(new OutputStreamWriter(System.out));
54          
55  //      SerializerToHTML serializer = new SerializerToHTML();
56  //      serializer.setSpecialEscapeURLs(true);
57  //      Properties properties = new Properties();
58  //      serializer.setOutputFormat(properties);
59  //      serializer.setOutputStream(System.out);
60  //        reader.setContentHandler(serializer);
61          reader.setContentHandler(serializer);
62          reader.parse(new InputSource(new FileInputStream("./src/data/simple.html")));
63      }
64  }