org.openprovenance.prov.model.Namespace.extendWith()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(3.1k)|赞(0)|评价(0)|浏览(98)

本文整理了Java中org.openprovenance.prov.model.Namespace.extendWith()方法的一些代码示例,展示了Namespace.extendWith()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Namespace.extendWith()方法的具体详情如下:
包路径:org.openprovenance.prov.model.Namespace
类名称:Namespace
方法名:extendWith

Namespace.extendWith介绍

[英]Extends this Namespace with all the prefix/namespace registration of the Namespace received as argument.
[中]使用作为参数接收的名称空间的所有前缀/名称空间注册扩展此名称空间。

代码示例

代码示例来源:origin: org.openprovenance.prov/prov-model

/** 
 * Accumulate all namespace declarations in a single {@link Namespace} instance. 
 * This includes the Document-level {@link Namespace} but also all Bundle-level {@link Namespace}s.
 * 
 * <p>This method is particular useful before serialization to XML since JAXB doesn't offer us the 
 * means to generate prefix declaration in inner Elements. Hence, all namespaces need to be declared 
 * at the root of the xml document.
 * 
 * @param document Document from which Namespaces are accumulated
 * @return a new instance of {@link Namespace}
 */
static public Namespace accumulateAllNamespaces(Document document) {
Namespace res=new Namespace(document.getNamespace());
for (Bundle b: pu.getNamedBundle(document)) {
  Namespace ns=b.getNamespace();
  if (ns!=null) res.extendWith(ns);
}
return res;
}

代码示例来源:origin: lucmoreau/ProvToolbox

/** 
 * Accumulate all namespace declarations in a single {@link Namespace} instance. 
 * This includes the Document-level {@link Namespace} but also all Bundle-level {@link Namespace}s.
 * 
 * <p>This method is particular useful before serialization to XML since JAXB doesn't offer us the 
 * means to generate prefix declaration in inner Elements. Hence, all namespaces need to be declared 
 * at the root of the xml document.
 * 
 * @param document Document from which Namespaces are accumulated
 * @return a new instance of {@link Namespace}
 */
static public Namespace accumulateAllNamespaces(Document document) {
Namespace res=new Namespace(document.getNamespace());
for (Bundle b: pu.getNamedBundle(document)) {
  Namespace ns=b.getNamespace();
  if (ns!=null) res.extendWith(ns);
}
return res;
}

代码示例来源:origin: lucmoreau/ProvToolbox

public Document makePC1GraphAndSpecialization(ProvFactory pFactory) {
Document graph = pFactory.newDocument();
String bName = "b123"; // needs to be generated
Bundle bun = makePC1FullGraph(pFactory, bName);
graph.getStatementOrBundle().add(bun);

bun.setNamespace(Namespace.gatherNamespaces(bun));
Hashtable<String, String> namespaces = new Hashtable<String, String>();
// currently, no prefix used, all qnames map to PC1_NS
namespaces.put("_", EX_NS); // new default namespace
namespaces.put("xsd", NamespacePrefixMapper.XSD_NS);
namespaces.put(EX_PREFIX, EX_NS);
namespaces.put(DOT_PREFIX, DOT_NS);
Entity bunEntity = pFactory.newEntity(bun.getId());
Entity a = pFactory.newEntity(new org.openprovenance.prov.xml.QualifiedName(EX_NS, globalA1.getId().getLocalPart(),null));
MentionOf ctx = pFactory.newMentionOf(a.getId(), globalA1.getId(), bunEntity.getId());
a.getOther().add(pFactory.newOther(DOT_NS, DOT_PREFIX, "color", "blue", name.XSD_STRING));
graph.getStatementOrBundle().add(bunEntity);
graph.getStatementOrBundle().add(a);
graph.getStatementOrBundle().add(ctx);

graph.setNamespace(Namespace.gatherNamespaces(graph));
graph.getNamespace().extendWith(bun.getNamespace());

return graph;
}

相关文章