001 /*
002 * (c) Copyright 2009 University of Bristol
003 * All rights reserved.
004 * [See end of file]
005 */
006
007 package rdfa;
008
009 import com.hp.hpl.jena.rdf.model.Model;
010 import com.hp.hpl.jena.rdf.model.ModelFactory;
011 import com.hp.hpl.jena.util.FileManager;
012 import java.io.InputStream;
013 import java.util.LinkedList;
014 import java.util.List;
015
016 /**
017 * Simple command line tool
018 *
019 * @author pldms
020 */
021 public class parse {
022
023 public static void main(String... args) throws ClassNotFoundException {
024 if (args.length == 0) usage();
025
026 // Ensure hooks run
027 Class.forName("net.rootdev.javardfa.RDFaReader");
028
029 String format = "XHTML";
030 boolean getFormat = false;
031
032 List<String> uris = new LinkedList<String>();
033
034 for (String arg: args) {
035 if (getFormat) { format = arg; getFormat = false; }
036 else if ("--help".equalsIgnoreCase(arg)) usage();
037 else if ("--format".equalsIgnoreCase(arg)) getFormat = true;
038 else uris.add(arg);
039 }
040
041 if (getFormat) usage();
042
043 Model m = ModelFactory.createDefaultModel();
044 FileManager fm = FileManager.get();
045 for (String uri: uris) {
046 InputStream in = fm.open(uri);
047 m.read(in, uri, format);
048 }
049 m.write(System.out, "TTL");
050 }
051
052 private static void usage() {
053 System.err.println("rdfa.parse [--format XHTML|HTML] <url> [...]");
054 System.exit(0);
055 }
056
057 }
058
059 /*
060 * (c) Copyright 2009 University of Bristol
061 * All rights reserved.
062 *
063 * Redistribution and use in source and binary forms, with or without
064 * modification, are permitted provided that the following conditions
065 * are met:
066 * 1. Redistributions of source code must retain the above copyright
067 * notice, this list of conditions and the following disclaimer.
068 * 2. Redistributions in binary form must reproduce the above copyright
069 * notice, this list of conditions and the following disclaimer in the
070 * documentation and/or other materials provided with the distribution.
071 * 3. The name of the author may not be used to endorse or promote products
072 * derived from this software without specific prior written permission.
073 *
074 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
075 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
076 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
077 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
078 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
079 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
080 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
081 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
082 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
083 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
084 */