本文整理了Java中nu.xom.Element.addAttribute()
方法的一些代码示例,展示了Element.addAttribute()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.addAttribute()
方法的具体详情如下:
包路径:nu.xom.Element
类名称:Element
方法名:addAttribute
暂无
代码示例来源:origin: wiztools/rest-client
private Element getRootElement() {
Element eRoot = new Element("rest-client");
// set version attributes to rest-client root tag
eRoot.addAttribute(new Attribute("version", Versions.CURRENT));
return eRoot;
}
代码示例来源: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: wiztools/rest-client
private static void addContentTypeCharsetAttribute(ContentType c, Element e) {
if(c != null) {
e.addAttribute(new Attribute("content-type", c.getContentType()));
if(c.getCharset() != null) {
e.addAttribute(new Attribute("charset", c.getCharset().name()));
}
}
}
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
public void addAttribute(final String name, final String value) {
top().addAttribute(new Attribute(encodeAttribute(name), value));
}
代码示例来源:origin: stanfordnlp/CoreNLP
Element mentionElem = new Element("mention", curNS);
if (representative) {
mentionElem.addAttribute(new Attribute("representative", "true"));
代码示例来源:origin: stanfordnlp/CoreNLP
private static Element toXML(RelationTriple triple, String curNS) {
Element top = new Element("triple", curNS);
top.addAttribute(new Attribute("confidence", triple.confidenceGloss()));
subject.addAttribute(new Attribute("begin", Integer.toString(triple.subjectTokenSpan().first)));
subject.addAttribute(new Attribute("end", Integer.toString(triple.subjectTokenSpan().second)));
Element text = new Element("text", curNS);
text.appendChild(triple.subjectGloss());
relation.addAttribute(new Attribute("begin", Integer.toString(triple.relationTokenSpan().first)));
relation.addAttribute(new Attribute("end", Integer.toString(triple.relationTokenSpan().second)));
text = new Element("text", curNS);
text.appendChild(triple.relationGloss());
object.addAttribute(new Attribute("begin", Integer.toString(triple.objectTokenSpan().first)));
object.addAttribute(new Attribute("end", Integer.toString(triple.objectTokenSpan().second)));
text = new Element("text", curNS);
text.appendChild(triple.objectGloss());
代码示例来源:origin: wiztools/rest-client
e.addAttribute(new Attribute("type", req.getKeyStore().getType().name()));
e.addAttribute(new Attribute("file", req.getKeyStore().getFile().getAbsolutePath()));
e.addAttribute(new Attribute("password", Util.base64encode(new String(req.getKeyStore().getPassword()))));
eSsl.appendChild(e);
e.addAttribute(new Attribute("type", req.getTrustStore().getType().name()));
e.addAttribute(new Attribute("file", req.getTrustStore().getFile().getAbsolutePath()));
e.addAttribute(new Attribute("password", Util.base64encode(new String(req.getTrustStore().getPassword()))));
eSsl.appendChild(e);
代码示例来源: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);
}
代码示例来源: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: stanfordnlp/CoreNLP
private static Element buildDependencyTreeInfo(String dependencyType, SemanticGraph graph, List<CoreLabel> tokens, String curNS) {
if(graph != null) {
Element depInfo = new Element("dependencies", curNS);
depInfo.addAttribute(new Attribute("type", dependencyType));
代码示例来源:origin: stanfordnlp/CoreNLP
private static void addWordInfo(Element wordInfo, CoreMap token, int id, String curNS) {
wordInfo.addAttribute(new Attribute("id", Integer.toString(id)));
Timex timex = token.get(TimeAnnotations.TimexAnnotation.class);
Element timexElem = new Element("Timex", curNS);
timexElem.addAttribute(new Attribute("tid", timex.tid()));
timexElem.addAttribute(new Attribute("type", timex.timexType()));
timexElem.appendChild(timex.value());
wordInfo.appendChild(timexElem);
代码示例来源:origin: wiztools/rest-client
for(String value: headers.get(key)) {
Element ee = new Element("header");
ee.addAttribute(new Attribute("key", key));
ee.addAttribute(new Attribute("value", value));
e.appendChild(ee);
ee.addAttribute(new Attribute("name", cookie.getName()));
ee.addAttribute(new Attribute("value", cookie.getValue()));
ee.addAttribute(new Attribute("version", String.valueOf(cookie.getVersion())));
e.appendChild(ee);
代码示例来源:origin: wiztools/rest-client
eMultipart.addAttribute(
new Attribute("subtype", entity.getSubtype().name()));
eMultipart.addAttribute(
new Attribute("mode", entity.getMode().name()));
ePart.addAttribute(new Attribute("name", p.getName()));
ePart.addAttribute(new Attribute("name", p.getName()));
ePart.addAttribute(new Attribute("filename", p.getFilename()));
ePart.addAttribute(new Attribute("filename", p.getPart().getName()));
代码示例来源:origin: stanfordnlp/CoreNLP
for (CoreMap sentence: annotation.get(CoreAnnotations.SentencesAnnotation.class)) {
Element sentElem = new Element("sentence", NAMESPACE_URI);
sentElem.addAttribute(new Attribute("id", Integer.toString(sentCount)));
Integer lineNumber = sentence.get(CoreAnnotations.LineNumberAnnotation.class);
if (lineNumber != null) {
sentElem.addAttribute(new Attribute("line", Integer.toString(lineNumber)));
if (sentimentTree != null) {
int sentiment = RNNCoreAnnotations.getPredictedClass(sentimentTree);
sentElem.addAttribute(new Attribute("sentimentValue", Integer.toString(sentiment)));
String sentimentClass = sentence.get(SentimentCoreAnnotations.SentimentClass.class);
sentElem.addAttribute(new Attribute("sentiment", sentimentClass.replaceAll(" ", "")));
代码示例来源: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
respChildSubElement.addAttribute(codeAttributes);
respChildSubElement.appendChild(bean.getStatusLine());
respElement.appendChild(respChildSubElement);
keyAttribute = new Attribute("key", key);
valueAttribute = new Attribute("value", value);
respChildSubSubElement.addAttribute(keyAttribute);
respChildSubSubElement.addAttribute(valueAttribute);
respChildSubElement.appendChild(respChildSubSubElement);
代码示例来源:origin: resteasy/Resteasy
public static byte[] createPermissionsXml(Permission... permissions) {
final Element permissionsElement = new Element("permissions");
permissionsElement.setNamespaceURI("http://xmlns.jcp.org/xml/ns/javaee");
permissionsElement.addAttribute(new Attribute("version", "7"));
for (Permission permission : permissions) {
final Element permissionElement = new Element("permission");
代码示例来源:origin: org.concordion/concordion
public void moveAttributesTo(Element element) {
for (int i=0; i<xomElement.getAttributeCount(); i++) {
Attribute attribute = xomElement.getAttribute(i);
xomElement.removeAttribute(attribute);
element.xomElement.addAttribute(attribute);
}
}
代码示例来源:origin: org.concordion/concordion
public void beforeProcessingSpecification(SpecificationProcessingEvent event) {
Resource resource = event.getResource();
//work around with setValue() necessary for Concordion.NET
Attribute hrefAttribute = new Attribute("href", "");
hrefAttribute.setValue(resource.getRelativePath(stylesheetResource));
link.addAttribute(hrefAttribute);
}
代码示例来源:origin: org.concordion/concordion
public void beforeProcessingSpecification(SpecificationProcessingEvent event) {
Resource resource = event.getResource();
//work around with setValue() necessary for Concordion.NET
Attribute srcAttribute = new Attribute("src", "");
srcAttribute.setValue(resource.getRelativePath(javaScriptResource));
script.addAttribute(srcAttribute);
}
内容来源于网络,如有侵权,请联系作者删除!