diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 19:30:46 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 19:30:46 -0800 |
commit | 41cdf40d933f4029c37cf844f8cf3314114e4e0a (patch) | |
tree | cd0b0b7bd9d1346b4cb18678cec0d15d8ea47df7 /src/org/ccil/cowan/tagsoup/jaxp/JAXPTest.java | |
parent | b0e041b91e19d554585bc4423075929013f05f22 (diff) | |
download | tagsoup-41cdf40d933f4029c37cf844f8cf3314114e4e0a.tar.gz |
auto import from //depot/cupcake/@135843android-sdk-tools_r2android-sdk-1.6_r2android-sdk-1.6_r1android-sdk-1.6-docs_r1android-sdk-1.5_r3android-sdk-1.5_r1android-sdk-1.5-preandroid-1.6_r2android-1.6_r1.5android-1.6_r1.4android-1.6_r1.3android-1.6_r1.2android-1.6_r1.1android-1.6_r1android-1.5r4android-1.5r3android-1.5r2android-1.5donut-release2donut-releasedonutcupcake-releasecupcake
Diffstat (limited to 'src/org/ccil/cowan/tagsoup/jaxp/JAXPTest.java')
-rw-r--r-- | src/org/ccil/cowan/tagsoup/jaxp/JAXPTest.java | 54 |
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); + } +} |