OntologyGeneration.jrag 2.03 KB
Newer Older
1
2
3
/* -*-Java-*- */

/* 
Anders Nilsson's avatar
Anders Nilsson committed
4
 * Copyright (C) 2007  Anders Nilsson <anders.nilsson@cs.lth.se>
5
6
7
8
9
10
 *
 * This file is part of OntologyCompiler.
 */

import java.io.PrintStream;

Anders Nilsson's avatar
Anders Nilsson committed
11
aspect OntologyGeneration {
12
	public void ASTNode.genOntology(String ind, PrintStream pStream) {
13
14
15
16
17
// 		for (int i=0; i<getNumChild(); i++) {
// 			getChild(i).genOntology(ind, pStream);
// 		}
	}

18
19
20
21
	public void StringElement.genOntology(String ind, PrintStream pStream) {
		pStream.print(getLITERAL());
	}

Anders Nilsson's avatar
Anders Nilsson committed
22
23
24
25
26
27
28
29
	public void IntElement.genOntology(String ind, PrintStream pStream) {
		pStream.print(getLITERAL());
	}

	public void FloatElement.genOntology(String ind, PrintStream pStream) {
		pStream.print(getLITERAL());
	}

30
31
32
33
34
35
36
37
38
39
40
41
42
43
	public void ComplexElement.genOntology(String ind, PrintStream pStream) {
		pStream.print(ind+"<"+name());
		for (int i=0; i<getNumAttribute(); i++) {
			pStream.print(" ");
			getAttribute(i).genOntology(pStream);
		}
		if (getNumElement() > 0) {
			pStream.println(">");
			for (int i=0; i<getNumElement(); i++) {
				getElement(i).genOntology(ind+"  ", pStream);
			}
			pStream.println(ind+"</"+name()+">");
		} else {
			pStream.println("/>");
44
45
46
		}
	}

Anders Nilsson's avatar
Anders Nilsson committed
47
// 	public void Thing.genOntology(String ind, PrintStream pStream) {
48

Anders Nilsson's avatar
Anders Nilsson committed
49
// 	}
50

51
52
	public void Start.genOntology(String ind, PrintStream pStream) {
		pStream.println("<?xml version=\"1.0\"?>");
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
		for (int i=0; i<getNumElement(); i++) {
			getElement(i).genOntology(ind+"  ", pStream);
		}
	}

	public void RdfDeclaration.genOntology(String ind, PrintStream pStream) {
		pStream.print(ind+"<rdf:RDF");
		for (int i=0; i<getNumAttribute(); i++) {
			pStream.println();			
			pStream.print(ind+"  ");
			getAttribute(i).genOntology(pStream);
		}
		pStream.println(">");
		for (int i=0; i<getNumElement(); i++) {
			getElement(i).genOntology(ind+"  ", pStream);
		}
		pStream.println(ind+"</rdf:RDF>");
	}

// 	public void OwlOntology.genOntology(String ind, PrintStream pStream) {
// 		pStream.print(ind+"<"+name()
// 	}

	public void Attribute.genOntology(PrintStream pStream) {
		pStream.print(id()+"="+getValue().getSTRING_LITERAL());
78
79
	}
}