数据集和目录之间的冲突

问题描述

我正在尝试在XML的数据集定义内添加一些标签。根据欧洲数据门户网站de结构,我必须遵循该标签

<foaf:Agent rdf:about="URI/Of/the/publisher">
   <foaf:name xml:lang="es"> Name of the publisher</foaf:name>
</foaf:Agent>

<dct:publisher rdf:resource=”URI/Of/the/publisher”>

现在在我的dcat:Dataset内部,我只能添加dct:publisher,而缺少另外两个标签

在我的代码中,我已经将该名称分配为文字,而URI则分配了URIref,因为它必须是RDF的值。


g = self.g
g.add((dataset_ref,RDF.type,DCAT.Dataset))
publishers = dataset_dict.get(dhc.EXPORT_AVAILABLE_PUBLISHERS,{})
organization_id = dataset_dict.get('publisher')
if organization_id in publishers:
    publisher = publishers.get(organization_id)
else:
    publisher = []
    org = h.get_organization(organization_id,False)
    publisher = [org.get('title'),None,None]
    if org and org['extras']:
        for extra in org.get('extras'):
            if extra and 'key' in extra and extra['key'] == dhc.ORG_ID_:
                notation = extra.get('value')
                publisher[1] = dhc.PUBLISHER_PREFIX + notation
                publisher[2] = notation
            publishers[organization_id] = publisher
            dataset_dict[dhc.EXPORT_AVAILABLE_PUBLISHERS] = publishers
        if publisher:
            # self._add_resource_list_triple(dataset_ref,DCT.publisher,publisher[1],publisher[0],publisher[2]) 
            EDP_publisher = URIRef(publisher[1])
            g.add((dataset_ref,EDP_publisher))
            g.add((dataset_ref,FOAF.Agent,EDP_publisher))
            g.add((EDP_publisher,FOAF.name,Literal(publisher[0])))

因此,每次我将g.add与FOAF.name和FOAF.Agent一起使用时,它会将我的标签从数据集标签(dcat:Dataset)中发送出去,并将其从大约转换为资源定义。 我感觉这可能是代码冲突。我在哪里可能做出错误的定义?

已更新: 经过更多尝试后,我发现由于结构主体为g.add((dataset_ref,DCAT.Dataset))而使用“ RDF.type”定义,因此为不进入“主标记”的结构而发出的冲突是一个冲突。当我尝试为其创建父标签和子标签时,父标签与主标签重复,因为它具有相同的值,因为我在文档中发现,如果子结构在父标签上找不到“ RDF.type” ”,它将通过将其命名为“ rdf:Description”自动生成

尽管我只是设法使遵循的结构化,但这不是我所需要的。

      <dcat:Dataset rdf:about="URI-ref">
        <dct:description xml:lang="es"> Description of the dataset </dct:description>
        <dct:title xml:lang="en">Title of dataset</dct:title>
        <dct:publisher rdf:resource="URI-ref"/>
      </dcat:Dataset>
  <foaf:Agent rdf:about="URI-ref">
    <foaf:name>Name of the publisher</foaf:name>
  </foaf:Agent>

我无法在dcat:Dataset中添加Foaf:Agent和foaf:name。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)