From 3eeed532e712baff045893570ec454226416a76f Mon Sep 17 00:00:00 2001 From: Anders Nilsson <anders.nilsson@cs.lth.se> Date: Mon, 29 Jan 2007 14:38:16 +0100 Subject: [PATCH] Seems to be able to generate ontology with instances which do not make Protege scream in agony. --- CompilerGeneration.jrag | 28 +++++++++++++++------------- siaras/Rewrites.jrag | 15 +++++++++++++++ 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/CompilerGeneration.jrag b/CompilerGeneration.jrag index cc11611..65d5f65 100644 --- a/CompilerGeneration.jrag +++ b/CompilerGeneration.jrag @@ -236,17 +236,17 @@ aspect GenRewrites { // Rewrite isSkillOf/hasSkill/hasProperty/isPropertyOf to ClassUse. // Should probably be auto-generated instead. pStream.println(ind(1)+"rewrite ComplexElement {"); - pStream.println(ind(2)+"when ((name().equals(\"hasSkill\")"); - pStream.println(ind(2)+"|| name().equals(\"hasProperty\"))"); - pStream.println("&& getNumAttribute() > 0 && getAttribute(0) instanceof RdfResource)"); - pStream.println(ind(2)+"to ClassUse {"); - pStream.println(ind(3)+"ClassUse use = new ClassUse();"); - 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.setAttributeList(getAttributeList());"); - pStream.println(ind(3)+"use.setElementList(new List());"); - pStream.println(ind(3)+"return use;"); - pStream.println(ind(2)+"}"); +// pStream.println(ind(2)+"when ((name().equals(\"hasSkill\")"); +// pStream.println(ind(2)+"|| name().equals(\"hasProperty\"))"); +// pStream.println("&& getNumAttribute() > 0 && getAttribute(0) instanceof RdfResource)"); +// pStream.println(ind(2)+"to ClassUse {"); +// pStream.println(ind(3)+"ClassUse use = new ClassUse();"); +// 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.setAttributeList(getAttributeList());"); +// pStream.println(ind(3)+"use.setElementList(new List());"); +// pStream.println(ind(3)+"return use;"); +// pStream.println(ind(2)+"}"); pStream.println(ind(2)+"when (name().equals(\"rdf:RDF\") && !(this instanceof RdfDeclaration))"); pStream.println(ind(2)+"to RdfDeclaration {"); pStream.println(ind(3)+"return new RdfDeclaration(getOwlIdentifier(),getAttributeList(),getElementList());"); @@ -316,11 +316,13 @@ aspect GenRewrites { // Rearrange device nodes on the AST to get away from the // current diagonal style from Protege 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(3)+"ClassUse use = new ClassUse();"); 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)+"getRdfDecl().addElement(this);"); pStream.println(ind(3)+"return use;"); diff --git a/siaras/Rewrites.jrag b/siaras/Rewrites.jrag index 0624817..509d1ff 100644 --- a/siaras/Rewrites.jrag +++ b/siaras/Rewrites.jrag @@ -14,5 +14,20 @@ aspect Qualification { getAttributeList(), 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()); + } } } -- GitLab