Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Anders Nilsson
OwlCompiler
Commits
3eeed532
Commit
3eeed532
authored
Jan 29, 2007
by
Anders Nilsson
Browse files
Seems to be able to generate ontology with instances which do not make Protege scream in agony.
parent
d1ac614c
Changes
2
Hide whitespace changes
Inline
Side-by-side
CompilerGeneration.jrag
View file @
3eeed532
...
@@ -236,17 +236,17 @@ aspect GenRewrites {
...
@@ -236,17 +236,17 @@ aspect GenRewrites {
// Rewrite isSkillOf/hasSkill/hasProperty/isPropertyOf to ClassUse.
// Rewrite isSkillOf/hasSkill/hasProperty/isPropertyOf to ClassUse.
// Should probably be auto-generated instead.
// Should probably be auto-generated instead.
pStream.println(ind(1)+"rewrite ComplexElement {");
pStream.println(ind(1)+"rewrite ComplexElement {");
pStream.println(ind(2)+"when ((name().equals(\"hasSkill\")");
//
pStream.println(ind(2)+"when ((name().equals(\"hasSkill\")");
pStream.println(ind(2)+"|| name().equals(\"hasProperty\"))");
//
pStream.println(ind(2)+"|| name().equals(\"hasProperty\"))");
pStream.println("&& getNumAttribute() > 0 && getAttribute(0) instanceof RdfResource)");
//
pStream.println("&& getNumAttribute() > 0 && getAttribute(0) instanceof RdfResource)");
pStream.println(ind(2)+"to ClassUse {");
//
pStream.println(ind(2)+"to ClassUse {");
pStream.println(ind(3)+"ClassUse use = new ClassUse();");
//
pStream.println(ind(3)+"ClassUse use = new ClassUse();");
pStream.println(ind(3)+"String att = getAttribute(0).name();");
//
pStream.println(ind(3)+"String att = getAttribute(0).name();");
pStream.println(ind(3)+"use.setOwlIdentifier(new OwlIdentifier(att.substring(att.indexOf('#')+1,att.indexOf('_'))));");
//
pStream.println(ind(3)+"use.setOwlIdentifier(new OwlIdentifier(att.substring(att.indexOf('#')+1,att.indexOf('_'))));");
pStream.println(ind(3)+"use.setAttributeList(getAttributeList());");
//
pStream.println(ind(3)+"use.setAttributeList(getAttributeList());");
pStream.println(ind(3)+"use.setElementList(new List());");
//
pStream.println(ind(3)+"use.setElementList(new List());");
pStream.println(ind(3)+"return use;");
//
pStream.println(ind(3)+"return use;");
pStream.println(ind(2)+"}");
//
pStream.println(ind(2)+"}");
pStream.println(ind(2)+"when (name().equals(\"rdf:RDF\") && !(this instanceof RdfDeclaration))");
pStream.println(ind(2)+"when (name().equals(\"rdf:RDF\") && !(this instanceof RdfDeclaration))");
pStream.println(ind(2)+"to RdfDeclaration {");
pStream.println(ind(2)+"to RdfDeclaration {");
pStream.println(ind(3)+"return new RdfDeclaration(getOwlIdentifier(),getAttributeList(),getElementList());");
pStream.println(ind(3)+"return new RdfDeclaration(getOwlIdentifier(),getAttributeList(),getElementList());");
...
@@ -316,11 +316,13 @@ aspect GenRewrites {
...
@@ -316,11 +316,13 @@ aspect GenRewrites {
// Rearrange device nodes on the AST to get away from the
// Rearrange device nodes on the AST to get away from the
// current diagonal style from Protege
// current diagonal style from Protege
pStream.println(ind(1)+"rewrite "+name()+" {");
pStream.println(ind(1)+"rewrite "+name()+" {");
pStream.println(ind(2)+"when (!isTopElement())");
pStream.println(ind(2)+"when (!isTopElement()
&& getAttribute(0) instanceof RdfId
)");
pStream.println(ind(2)+"to ClassUse {");
pStream.println(ind(2)+"to ClassUse {");
pStream.println(ind(3)+"ClassUse use = new ClassUse();");
pStream.println(ind(3)+"ClassUse use = new ClassUse();");
pStream.println(ind(3)+"use.setOwlIdentifier(new OwlIdentifier(\""+name()+"\"));");
pStream.println(ind(3)+"use.setOwlIdentifier(new OwlIdentifier(\""+name()+"\"));");
pStream.println(ind(3)+"use.setAttributeList(new List().add(new RdfResource(getAttribute(0).getValue())));");
pStream.println(ind(3)+"String id = getAttribute(0).getValue().getSTRING_LITERAL();");
pStream.println(ind(3)+"Value val = new Value(\"\\\"#\"+id.substring(1,id.length()));");
pStream.println(ind(3)+"use.setAttributeList(new List().add(new RdfResource(val)));");
pStream.println(ind(3)+"use.setElementList(new List());");
pStream.println(ind(3)+"use.setElementList(new List());");
pStream.println(ind(3)+"getRdfDecl().addElement(this);");
pStream.println(ind(3)+"getRdfDecl().addElement(this);");
pStream.println(ind(3)+"return use;");
pStream.println(ind(3)+"return use;");
...
...
siaras/Rewrites.jrag
View file @
3eeed532
...
@@ -14,5 +14,20 @@ aspect Qualification {
...
@@ -14,5 +14,20 @@ aspect Qualification {
getAttributeList(),
getAttributeList(),
getElementList());
getElementList());
}
}
when ((name().equals("hasProperty") ||
name().equals("hasIdentifier") ||
name().equals("hasSubskill") ||
name().equals("hasSkill") ||
name().equals("hasSubskill") ||
name().equals("hasEditable") ||
name().equals("isPropertyOf") ||
name().equals("isSkillOf")) &&
getNumElement()==1 &&
getElement(0) instanceof ClassUse)
to ComplexElement {
setAttributeList(new List().add(((ComplexElement) getElement(0)).
getAttribute(0)));
setElementList(new List());
}
}
}
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment