如果我有有两个不同的特性,但是这两个类具有相同名称:

[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; }
}

和尝试将它们序列化到RDF并用 http://www.w3.org验证它们/ RDF /识别/ 服务。一切都是好的,他们是正确的。 但之后,我尝试从与OntologyExtractor.exe工具这些类生成的OWL文件我得到的消息: “本体提取失败。 http://test.org/1.0#title 被分配到多个类型。” 这是奇怪的消息作为上层是正确的,也有具有与具有相同命名的属性不同类别相同的情况下一些RDF规范。

有帮助吗?

解决方案

我希望它是在ROWLEX的错误。你的情况是有效的,但我认为我并没有为它做准备时,我写OntologyExtractor。我会尝试尽快发布一个修复成为可能。

修改:/:ROWLEX2.1被释放,你可以从 HTTP下载/rowlex.nc3a.nato.int 。 2.1版(等等)现在支持共享属性功能。在这个问题的确切代码仍然会导致同样的错误!为了克服这一点,你必须改变你的代码的装修如下:

[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; } 
} 

使用OntologyExtractor.exe,这个代码将导致的与作为Type1和Type2的UNION匿名域类OWL属性。结果 尽管这在技术上是完全正确的解决方案,在属性设置域限制其未来可能的重用。作为一个解决方案,您可能要替换本地限制属性域。可以实现的是,如下所示:

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

应该离开UseLocalRestrictionInsteadOfDomain没有设置,ROWLEX选择域,并根据当前上下文本地限制之间。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top