aboutsummaryrefslogtreecommitdiff
path: root/src/org/ccil/cowan/tagsoup/jaxp/JAXPTest.java
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-03 19:30:46 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-03 19:30:46 -0800
commit41cdf40d933f4029c37cf844f8cf3314114e4e0a (patch)
treecd0b0b7bd9d1346b4cb18678cec0d15d8ea47df7 /src/org/ccil/cowan/tagsoup/jaxp/JAXPTest.java
parentb0e041b91e19d554585bc4423075929013f05f22 (diff)
downloadtagsoup-41cdf40d933f4029c37cf844f8cf3314114e4e0a.tar.gz
Diffstat (limited to 'src/org/ccil/cowan/tagsoup/jaxp/JAXPTest.java')
-rw-r--r--src/org/ccil/cowan/tagsoup/jaxp/JAXPTest.java54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/org/ccil/cowan/tagsoup/jaxp/JAXPTest.java b/src/org/ccil/cowan/tagsoup/jaxp/JAXPTest.java
new file mode 100644
index 0000000..61f20ad
--- /dev/null
+++ b/src/org/ccil/cowan/tagsoup/jaxp/JAXPTest.java
@@ -0,0 +1,54 @@
+// This file is part of TagSoup and is Copyright 2002-2008 by John Cowan.
+//
+// TagSoup is licensed under the Apache License,
+// Version 2.0. You may obtain a copy of this license at
+// http://www.apache.org/licenses/LICENSE-2.0 . You may also have
+// additional legal rights not granted by this license.
+//
+// TagSoup is distributed in the hope that it will be useful, but
+// unless required by applicable law or agreed to in writing, TagSoup
+// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+// OF ANY KIND, either express or implied; not even the implied warranty
+// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+package org.ccil.cowan.tagsoup.jaxp;
+
+import java.io.*;
+
+import javax.xml.parsers.*;
+import org.w3c.dom.Document;
+
+/**
+ * Trivial non-robust test class, to show that TagSoup can be accessed using
+ * JAXP interface.
+ */
+public class JAXPTest
+{
+ public static void main(String[] args)
+ throws Exception
+ {
+ new JAXPTest().test(args);
+ }
+
+ private void test(String[] args)
+ throws Exception
+ {
+ if (args.length != 1) {
+ System.err.println("Usage: java "+getClass()+" [input-file]");
+ System.exit(1);
+ }
+ File f = new File(args[0]);
+ //System.setProperty("javax.xml.parsers.SAXParserFactory", SAXFactoryImpl.class.toString());
+ System.setProperty("javax.xml.parsers.SAXParserFactory", "org.ccil.cowan.tagsoup.jaxp.SAXFactoryImpl");
+
+ SAXParserFactory spf = SAXParserFactory.newInstance();
+ System.out.println("Ok, SAX factory JAXP creates is: "+spf);
+ System.out.println("Let's parse...");
+ spf.newSAXParser().parse(f, new org.xml.sax.helpers.DefaultHandler());
+ System.out.println("Done. And then DOM build:");
+
+ Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(f);
+
+ System.out.println("Succesfully built DOM tree from '"+f+"', -> "+doc);
+ }
+}