views:

87

answers:

1

If I have those two classes that have two different properties but with the same name:

[RdfSerializable]
public class Type1
{
    [RdfProperty(true), Name = "title"]
    public string Title { get; set; }
}

[RdfSerializable]
public class Type2
{
    [RdfProperty(true), Name = "title"]
    public string Title { get; set; }
}

and try to serialize them to RDF and validate them with http://www.w3.org/RDF/Validator/ service. Everything is Okay and they are correct. But after I try to generate OWL files from those classes with OntologyExtractor.exe tool I get that message: "Ontology extraction failed. http://test.org/1.0#title is assigned to more than one type." This is strange message as the upper classes are correct and there are some RDF specifications that has same situation with different classes that have same named properties.

+1  A: 

I expect it is a bug in ROWLEX. Your case is a valid one, but I assume I did not prepare for it when I wrote OntologyExtractor. I will try to release a fix as soon as possible.

EDIT: ROWLEX2.1 is released, you can download it from http://rowlex.nc3a.nato.int. Version 2.1 (among others) supports now the shared property functionality. The exact code in the question would still result the same error! To overcome that, you should alter the decoration of your code as follows:

[RdfSerializable] 
public class Type1 
{ 
    [RdfProperty(true, Name = "title", ExcludeFromOntology=true)] 
    public string Title { get; set; } 
} 

[RdfSerializable] 
public class Type2 
{ 
    [RdfProperty(true, Name = "title", 
               DomainAsType = new Type[]{typeof(Type1), typeof(Type2)})] 
    public string Title { get; set; } 
} 

Using the OntologyExtractor.exe, this code will result a OWL property of with an anonymous domain class that is the UNION of Type1 and Type2.
While this is technically perfectly correct solution, setting domains on properties limit their possible future reuse. As a solution, you might want to substitute the property domain with local restrictions. You can achieve that as follows:

[RdfSerializable] 
public class Type2 
{ 
    [RdfProperty(true, Name = "title", 
               DomainAsType = new Type[]{typeof(Type1), typeof(Type2)},
               UseLocalRestrictionInsteadOfDomain = true)] 
    public string Title { get; set; } 
} 

Should you leave UseLocalRestrictionInsteadOfDomain not set, ROWLEX chooses between domain and local restriction according to the current context.

ROWLEX Admin
Great! Thanks! I'll validate it after that.
The_Ghost