Commit 61c4200e authored by Anders Nilsson's avatar Anders Nilsson
Browse files

Working on connecting x3d compiler to ontology instances.

parent 8b15ff69
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -17,6 +17,9 @@ aspect AbsGrammarGeneration {
    }

    public void Start.genAbsGrammar(PrintStream pStream) {
        pStream.println("// -*-Java-*- ");
        pStream.println();
        pStream.println("// Automatically generated JastAdd abstract grammar file ");
		pStream.println("// Predefined types");
		pStream.println("Start ::= Element*;");
		pStream.println("abstract Thing : ComplexElement ::=;");
+4 −0
Original line number Diff line number Diff line
@@ -219,6 +219,10 @@ aspect RewriteClasses {
			to OwlClassDecl {
			return new OwlClassDecl(new List(), getElementList(), getId());
		}
// 		when (hasRdfId())
// 			to OwlClassDecl {
// 			return new OwlClassDecl(new List(), getElementList(), getId());
// 		}
		when (!isTopLevel())
			to OwlClassUse {
			return new OwlClassUse(new List(), getElementList(), getId());
+1 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ aspect Types {
		}
		// No decl found, so let's return null. Not sure if that's
		// that the right thing to do though.
        System.out.println("* Couldn't find decl for: "+getId());
		return new OwlClassDecl(new List(), new List(), "_Unknown_");
    }

+66 −0
Original line number Diff line number Diff line

/* 
 * Copyright (C) 2007  Anders Nilsson <anders.nilsson@cs.lth.se>
 *
 * This file is part of OntologyCompiler.
 */

import AST.Start;
import AST.SiarasParser;
import AST.ParseException;
import java.io.*;
import java.net.*;

public class GeometryDemo extends Parser {
	public static Start getAST(String ontologyURL) {
		Start ast = null;
// 		String outfile = null;
// 		int i=0;
// 		for (i=0; i<args.length; i++) {
// 			if (args[i].equals("-o")) {
// 				outfile = args[++i];
//                 if (outfile.endsWith(".owl")) {
//                   outfile = outfile.substring(0,outfile.indexOf('.'));
//                 }
// 			}
// 		}
		try {
			Reader r = new FileReader(new URL(ontologyURL).getFile());
			SiarasParser parser = new SiarasParser(r);

			ast = parser.Start();
            ast.traverseAST();
		} catch (ParseException e) {
			System.out.println(e.getMessage());
		}
		catch (MalformedURLException e) {
			System.out.println(e.getMessage());
		}
		catch (FileNotFoundException e) {
			System.err.println("file " + ontologyURL + " not found");
		}
        return ast;

// 		try {
// 			// Generate OWL ontology, possibly transformed from Owl
// 			// Full to OWL DL
// 			if (outfile == null) {
// 				outfile = "ontology";
// 			}
// 			PrintStream pStream = new PrintStream(new File(outfile+".owl"));
// 			ast.genOntology("",pStream);
//             // have to create a matching repository file, otherwise
//             // Protege will complain severely.
// 			pStream = new PrintStream(new File(outfile+".repository"));
//             pStream.println("[Dublin Core DL Redirect]");
// 		} catch (java.io.FileNotFoundException e) {
// 			System.out.println("Could not create file: "+outfile);
// 			e.printStackTrace();
// 		}
	}

    public static void main(String[] args) {
        Start ast = getAST(args[0]);
        ast.getIndividual("Teapot_1").dumpTree("",System.out);
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ aspect SkillserverInterface {
    public Thing Thing.getIndividual(String id) {
//         System.out.println("  "+name());
//         System.out.println("Looking for: "+id+" in: "+id()+" ("+name()+")");
//         System.out.println("Looking in: "+id());
         System.out.println("Looking in: "+id()+" "+" ("+name()+")");
//         if (id().contains(id) && 
//             (this instanceof Device)) {
        if (id.equals(id())) {
Loading