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.serialize.SerializerFactory;
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 HtmlParserTest extends TestCase {
33      public void testHotSax() throws Exception {
34          XMLReader reader = XMLReaderFactory.createXMLReader("org.saxbenchmark.htmlparser.HTMLParserXMLReader");
35          reader.setFeature("http://xml.org/sax/features/namespaces", false);
36          reader.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
37          SerializerFactory serializerFactory = SerializerFactory.getSerializerFactory("html");
38  //      ToHTMLStream serializer = new ToHTMLStream();
39  //      OutputFormat outputFormat = new OutputFormat();
40  //      outputFormat.setNonEscapingElements(new String[] {"script"});
41  //      outputFormat.setCDataElements(new String[] {"script"});
42  //      outputFormat.setIndent(1);
43  //      outputFormat.setIndenting(true);
44  //      outputFormat.setPreserveSpace(true);
45  //      Serializer serializer = serializerFactory.makeSerializer(outputFormat);
46  //      serializer.setOutputByteStream(System.out);
47  //      serializer.setOutputStream(System.out);
48          
49          XMLWriter serializer = new XMLWriter();
50          serializer.setHTMLMode(true);
51          serializer.setOutput(new OutputStreamWriter(System.out));
52          
53  //      SerializerToHTML serializer = new SerializerToHTML();
54  //      serializer.setSpecialEscapeURLs(true);
55  //      Properties properties = new Properties();
56  //      serializer.setOutputFormat(properties);
57  //      serializer.setOutputStream(System.out);
58          reader.setContentHandler(serializer);
59  //        reader.setContentHandler(serializer.asContentHandler());
60          reader.parse(new InputSource(new FileInputStream("./src/data/simple.html")));
61      }
62  }