nu.xom.Element.appendChild()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(9.5k)|赞(0)|评价(0)|浏览(147)

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

Element.appendChild介绍

暂无

代码示例

代码示例来源:origin: stanfordnlp/CoreNLP

/**
 * Helper method for addWordInfo().  If the value is not null,
 * creates an element of the given name and namespace and adds it to the
 * tokenElement.
 *
 * @param tokenElement This is the element to which the newly created element will be added
 * @param elemName This is the name for the new XML element
 * @param curNS    The current namespace
 * @param value    This is its value
 */
private static void setSingleElement(Element tokenElement, String elemName, String curNS, String value) {
 if (value != null) {
  Element cur = new Element(elemName, curNS);
  cur.appendChild(value);
  tokenElement.appendChild(cur);
 }
}

代码示例来源:origin: stanfordnlp/CoreNLP

/**
 * Generates the XML content for a constituent tree
 */
private static void addConstituentTreeInfo(Element treeInfo, Tree tree, TreePrint constituentTreePrinter) {
 StringWriter treeStrWriter = new StringWriter();
 constituentTreePrinter.printTree(tree, new PrintWriter(treeStrWriter, true));
 String temp = treeStrWriter.toString();
 //log.info(temp);
 treeInfo.appendChild(temp);
}

代码示例来源:origin: stanfordnlp/CoreNLP

/**
 * Generates the XML content for MachineReading entities.
 */
private static void addEntities(List<EntityMention> entities, Element top, String curNS) {
 for (EntityMention e: entities) {
  Element ee = toXML(e, curNS);
  top.appendChild(ee);
 }
}

代码示例来源:origin: stanfordnlp/CoreNLP

/**
 * Generates the XML content for a list of OpenIE triples.
 */
private static void addTriples(Collection<RelationTriple> openieTriples, Element top, String namespaceUri) {
 for (RelationTriple triple : openieTriples) {
  top.appendChild(toXML(triple, namespaceUri));
 }
}

代码示例来源:origin: com.thoughtworks.xstream/xstream

public void setValue(final String text) {
  top().appendChild(text);
}

代码示例来源:origin: stanfordnlp/CoreNLP

private static Element makeProbabilitiesElement(ExtractionObject object, String curNS) {
 Element probs = new Element("probabilities", curNS);
 if (object.getTypeProbabilities() != null){
  List<Pair<String, Double>> sorted = Counters.toDescendingMagnitudeSortedListWithCounts(object.getTypeProbabilities());
  for(Pair<String, Double> lv: sorted) {
   Element prob = new Element("probability", curNS);
   Element label = new Element("label", curNS);
   label.appendChild(lv.first);
   Element value = new Element("value", curNS);
   value.appendChild(lv.second.toString());
   prob.appendChild(label);
   prob.appendChild(value);
   probs.appendChild(prob);
  }
 }
 return probs;
}

代码示例来源:origin: stanfordnlp/CoreNLP

/**
 * Generates the XML content for MachineReading relations.
 */
private static void addRelations(List<RelationMention> relations, Element top, String curNS, double beam) {
 for (RelationMention r: relations){
  if (r.printableObject(beam)) {
   Element re = toXML(r, curNS);
   top.appendChild(re);
  }
 }
}

代码示例来源:origin: wiztools/rest-client

static Element getAuthElement(Auth auth) {
  Element eAuth = new Element("auth");
  
  if(auth instanceof BasicAuth) {
    eAuth.appendChild(getBasicAuthElement((BasicAuth)auth));
  }
  else if(auth instanceof DigestAuth) {
    eAuth.appendChild(getDigestAuthElement((DigestAuth)auth));
  }
  else if(auth instanceof NtlmAuth) {
    eAuth.appendChild(getNtlmAuthElement((NtlmAuth)auth));
  }
  else if(auth instanceof OAuth2BearerAuth) {
    eAuth.appendChild(getOAuth2BearerElement((OAuth2BearerAuth)auth));
  }
  
  return eAuth;
}

代码示例来源:origin: stanfordnlp/CoreNLP

private static Element toXML(RelationMention relation, String curNS) {
 Element top = new Element("relation", curNS);
 top.addAttribute(new Attribute("id", relation.getObjectId()));
 Element type = new Element("type", curNS);
 type.appendChild(relation.getType());
 top.appendChild(relation.getType());
 if (relation.getSubType() != null){
  Element subtype = new Element("subtype", curNS);
  subtype.appendChild(relation.getSubType());
  top.appendChild(relation.getSubType());
 }
 List<EntityMention> mentions = relation.getEntityMentionArgs();
 Element args = new Element("arguments", curNS);
 for (EntityMention e : mentions) {
  args.appendChild(toXML(e, curNS));
 }
 top.appendChild(args);
 top.appendChild(makeProbabilitiesElement(relation, curNS));
 return top;
}

代码示例来源:origin: wiztools/rest-client

static void populateUsernamePasswordElement(Element eParent, UsernamePasswordAuth auth) {
  if(StringUtil.isNotEmpty(auth.getUsername())) {
    Element eUsername = new Element("username");
    eUsername.appendChild(auth.getUsername());
    eParent.appendChild(eUsername);
  }
  
  if(auth.getPassword() != null && auth.getPassword().length > 0) {
    Element ePassword = new Element("password");
    ePassword.appendChild(Util.base64encode(new String(auth.getPassword())));
    eParent.appendChild(ePassword);
  }
}

代码示例来源:origin: wiztools/rest-client

static Element getOAuth2BearerElement(OAuth2BearerAuth auth) {
  Element e = new Element("oauth2-bearer");
  
  if(StringUtil.isNotEmpty(auth.getOAuth2BearerToken())) {
    Element eToken = new Element("token");
    eToken.appendChild(auth.getOAuth2BearerToken());
    e.appendChild(eToken);
  }
  
  return e;
}

代码示例来源:origin: stanfordnlp/CoreNLP

private static void addDependencyInfo(Element depInfo, String rel, boolean isExtra, int source, String sourceWord, Integer sourceCopy, int target, String targetWord, Integer targetCopy, String curNS) {
 Element depElem = new Element("dep", curNS);
 depElem.addAttribute(new Attribute("type", rel));
 if (isExtra) {
  depElem.addAttribute(new Attribute("extra", "true"));
 }
 Element govElem = new Element("governor", curNS);
 govElem.addAttribute(new Attribute("idx", Integer.toString(source)));
 govElem.appendChild(sourceWord);
 if (sourceCopy != null && sourceCopy > 0) {
  govElem.addAttribute(new Attribute("copy", Integer.toString(sourceCopy)));
 }
 depElem.appendChild(govElem);
 Element dependElem = new Element("dependent", curNS);
 dependElem.addAttribute(new Attribute("idx", Integer.toString(target)));
 dependElem.appendChild(targetWord);
 if (targetCopy != null && targetCopy > 0) {
  dependElem.addAttribute(new Attribute("copy", Integer.toString(targetCopy)));
 }
 depElem.appendChild(dependElem);
 depInfo.appendChild(depElem);
}

代码示例来源:origin: stanfordnlp/CoreNLP

private static Element toXML(EntityMention entity, String curNS) {
 Element top = new Element("entity", curNS);
 top.addAttribute(new Attribute("id", entity.getObjectId()));
 Element type = new Element("type", curNS);
 type.appendChild(entity.getType());
 top.appendChild(entity.getType());
 if (entity.getNormalizedName() != null){
  Element nm = new Element("normalized", curNS);
  nm.appendChild(entity.getNormalizedName());
  top.appendChild(nm);
 }
 if (entity.getSubType() != null){
  Element subtype = new Element("subtype", curNS);
  subtype.appendChild(entity.getSubType());
  top.appendChild(subtype);
 }
 Element span = new Element("span", curNS);
 span.addAttribute(new Attribute("start", Integer.toString(entity.getHeadTokenStart())));
 span.addAttribute(new Attribute("end", Integer.toString(entity.getHeadTokenEnd())));
 top.appendChild(span);
 top.appendChild(makeProbabilitiesElement(entity, curNS));
 return top;
}

代码示例来源:origin: wiztools/rest-client

static Element getNtlmAuthElement(NtlmAuth auth) {
  Element e = new Element("ntlm");
  
  if(StringUtil.isNotEmpty(auth.getDomain())) {
    Element eDomain = new Element("domain");
    eDomain.appendChild(auth.getDomain());
    e.appendChild(eDomain);
  }
  
  if(StringUtil.isNotEmpty(auth.getWorkstation())) {
    Element eWorkstation = new Element("workstation");
    eWorkstation.appendChild(auth.getWorkstation());
    e.appendChild(eWorkstation);
  }
  
  populateUsernamePasswordElement(e, auth);
  
  return e;
}

代码示例来源:origin: wiztools/rest-client

protected Document request2XML(final Request bean)
    throws XMLException {
  Element reqRootElement = getRootElement();
  reqRootElement.appendChild(getRequestElement(bean));
  Document xomDocument = new Document(reqRootElement);
  return xomDocument;
}

代码示例来源:origin: wiztools/rest-client

protected Document response2XML(final Response bean)
    throws XMLException {
  Element respRootElement = getRootElement();
  respRootElement.appendChild(getResponseElement(bean));
  Document xomDocument = new Document(respRootElement);
  return xomDocument;
}

代码示例来源:origin: stanfordnlp/CoreNLP

/**
 * Generates the XML content for the coreference chain object.
 */
private static boolean addCorefGraphInfo
 (Options options, Element corefInfo, List<CoreMap> sentences, Map<Integer, CorefChain> corefChains, String curNS) {
 boolean foundCoref = false;
 for (CorefChain chain : corefChains.values()) {
  if (!options.printSingletons && chain.getMentionsInTextualOrder().size() <= 1)
   continue;
  foundCoref = true;
  Element chainElem = new Element("coreference", curNS);
  CorefChain.CorefMention source = chain.getRepresentativeMention();
  addCorefMention(options, chainElem, curNS, sentences, source, true);
  for (CorefChain.CorefMention mention : chain.getMentionsInTextualOrder()) {
   if (mention == source)
    continue;
   addCorefMention(options, chainElem, curNS, sentences, mention, false);
  }
  corefInfo.appendChild(chainElem);
 }
 return foundCoref;
}

代码示例来源:origin: com.thoughtworks.xstream/xstream

protected Object createNode(final String name) {
  final Element newNode = new Element(encodeNode(name));
  final Element top = top();
  if (top != null){
    top().appendChild(newNode);
  }
  return newNode;
}

代码示例来源:origin: stanfordnlp/CoreNLP

chainElem.appendChild(mentionElem);

代码示例来源:origin: wiztools/rest-client

public static void writeRequestCollectionXML(final List<Request> requests, final File f)
    throws IOException, XMLException {
  XmlPersistenceWrite xUtl = new XmlPersistenceWrite();
  
  Element eRoot = new Element("request-collection");
  eRoot.addAttribute(new Attribute("version", Versions.CURRENT));
  for(Request req: requests) {
    Element e = xUtl.getRequestElement(req);
    eRoot.appendChild(e);
  }
  Document doc = new Document(eRoot);
  xUtl.writeXML(doc, f);
}

相关文章