1

I am trying to compare two OntModels and checking if any class of model1 is missing in model2 then add a tag on model1 class that tells the time when it is deleted from model2. My code detects the missing classes correctly but does not append tag. How can I add tag/ class on the detected class?

            for (Iterator i=model1.listClasses(); i.hasNext(); )
        {
            OntClass c=(OntClass)i.next();
            if (model2.contains(c, null)) 
            {
                System.out.println("Contains :  "+c.asClass());
            }
            else
            {
                System.out.println(time+"   Does not contain :  "+c.asClass());
                final OntClass a = model1.createClass( URI+"DeletedOn"+time );
                a.addSuperClass(c.getSuperClass());
                c.addSuperClass(a);
            }
        }
Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
  • What do you mean by "tag"? An OntModel contains a set of statements. What doesn't work here? The `else` branch of your code adds a superclass to an existing class. By the way, this is strange. Why don't you add a property RDF statement with the class as subject and a literal value as object? – UninformedUser Feb 28 '18 at 12:39
  • 1
    Here "Tag" means class or something which can be used to apply time-stamping on deleted classes. I am not sure what to use. When a class is missing in model2 I want something like that for the class in model1. – zeeshaniazi Feb 28 '18 at 13:38
  • What you're showing here is XML. That's not part of RDF. There is just an XML serialization of RDF, but you can't add any XML attribute to a tag by RDF graph modification operations. RDF data consists of a set of RDF triples, thus, you have to add an RDF triple. Or use reification to make statements about statements. – UninformedUser Feb 28 '18 at 16:39

0 Answers0