0

我正在尝试从 RDF 中删除具有多值的属性,而且似乎关于这个 RDF,我应该编写以下代码来删除 includeResource:

<Ontologyowl:StudyList rdf:about="stdl827181">
        <Ontologyowl:title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Basic learning materials</Ontologyowl:title>
        <Ontologyowl:includeResource>
            <Ontologyowl:LearningResource rdf:about="res298830"/>
        </Ontologyowl:includeResource>
        <Ontologyowl:includeResource>
            <Ontologyowl:LearningResource rdf:about="res323717"/>
        </Ontologyowl:includeResource>
    </Ontologyowl:StudyList>

StudyList_ stdl = (StudyList_)rdfDoc.GetIndividual(stdlId, StudyList.Uri, false);
LearningResource[] lrnRes = stdl.includeResources;

        foreach (LearningResource i in lrnRes)
        {
            stdl.RemoveincludeResource(i);
            rdfDoc.RemoveProperty(...);
        }

但我现在不关心 rdfDoc.RemoveProperty(..) 输入。请对此有任何帮助吗?

4

1 回答 1

0

rdfDoc.RemoveProperty(subject, predicate, object) 实际上要求您指定完整的三元组。此方法由您的 stdl.RemoveincludeResource(i) 方法包装。但是,您的包装方法更易于阅读并且是类型安全的。宿主 C# 对象 (stdl) 是主体,方法 (RemoveincludeResource) 表示谓词,输入参数 (i) 将是对象。这些项目在内部传递给 RdfDocument.RemoveProperty 方法。无需调用这两种方法!

于 2009-07-13T07:51:31.533 回答