本文整理了Java中nu.xom.Element.copy()
方法的一些代码示例,展示了Element.copy()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.copy()
方法的具体详情如下:
包路径:nu.xom.Element
类名称:Element
方法名:copy
暂无
代码示例来源:origin: stackoverflow.com
public static org.w3c.dom.Document xomToDom(Element elem) {
try {
elem = (Element)elem.copy();
return
DOMConverter.convert(new Document(elem),
DocumentBuilderFactory.newInstance().newDocumentBuilder().getDOMImplementation());
} catch (ParserConfigurationException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: org.concordion/concordion
public Element deepClone() {
return new Element((nu.xom.Element) xomElement.copy());
}
}
代码示例来源:origin: concordion/concordion
public Element deepClone() {
return new Element((nu.xom.Element) xomElement.copy());
}
}
代码示例来源:origin: se.vgregion.pubsubhubbub/pubsubhubbub-hub-composite-pubsub
public static Element stringToXml(String xml) {
if(xml == null) return null;
try {
Document doc = PARSER.build(new StringReader(xml));
Element elm = doc.getRootElement();
return (Element) elm.copy();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: se.vgregion.pubsubhubbub/pubsubhubbub-hub-composite-pubsub
public static String xmlToString(Element elm) {
// TODO ugly hack to retain namespaces
return new Document((Element) elm.copy()).toXML().replaceFirst("<.+>", "");
}
代码示例来源:origin: com.io7m.kstructural/io7m-kstructural-frontend
private KSBrandAppender(
final Optional<Element> in_brand_top,
final Optional<Element> in_brand_bottom)
{
this.brand_start = NullCheck.notNull(in_brand_top);
this.brand_end = NullCheck.notNull(in_brand_bottom);
this.appender_start = (e) -> {
if (this.brand_start.isPresent()) {
e.insertChild(this.brand_start.get().copy(), 0);
}
};
this.appender_end = (e) -> {
if (this.brand_end.isPresent()) {
e.insertChild(this.brand_end.get().copy(), 0);
}
};
}
代码示例来源:origin: org.xml-cml/cmlxom
/**
* write XML for an element node. copies elements so it doesn't have a
* document parent
*
* @param elem
* @return the XML String
*/
public String getXML(Element elem) {
Element clone = (Element) elem.copy();
Document doc = new Document(clone);
return getXML(doc);
}
代码示例来源:origin: io.snappydata/gemfire-core
public static Node createNode(String xmlDefintion) {
Node node = null;
try {
node = builder2.build(new StringReader(xmlDefintion)).getRootElement().copy();
} catch (ValidityException e) {
e.printStackTrace();
} catch (ParsingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return node;
}
代码示例来源:origin: zanata/zanata-platform
public static ImmutableList<Element> getChildren(HasTMMetadata fromEntity) {
try {
String metadataString =
fromEntity.getMetadata(TMMetadataType.TMX14);
if (metadataString == null) {
return ImmutableList.of();
}
@SuppressWarnings("unchecked")
Map<String, Object> metadata =
jsonMapper.readValue(metadataString, Map.class);
List<String> children = getChildrenXml(metadata);
Builder<Element> result = ImmutableList.builder();
for (String childXml : children) {
Document doc = new nu.xom.Builder().build(childXml, null);
Element elem = (Element) doc.getRootElement().copy();
result.add(elem);
}
return result.build();
} catch (Exception e) {
// error parsing XML or json, which "shouldn't happen"
throw new RuntimeException(e);
}
}
代码示例来源:origin: zanata/zanata-platform
/**
* Supported children are currently {@code <prop>} and {@code <note>}.
*
* @param child
* @param childrenXml
*/
private static void addChildIfSupported(Element child,
Builder<String> childrenXml) {
String uri = child.getNamespaceURI();
String name = child.getLocalName();
if (inTmxNamespace(uri)
&& (name.equals("prop") || name.equals("note"))) {
Element copy = (Element) child.copy();
copy.setNamespacePrefix("");
copy.setNamespaceURI("");
childrenXml.add(copy.toXML());
}
}
代码示例来源:origin: org.xml-cml/cmlxom
/**
* Utility method that allows for convenient conversion of
* <a href="http://www.cafeconleche.org/XOM/apidocs/index.html">XOM</a> elements to
* CML elements if necessary.
* always makes a copy
*
* @param xml a valid CMLElement
* @return the {@link CMLElement}
*/
public static CMLElement ensureCML(Element xml) {
if (xml == null) {
throw new RuntimeException("null cml");
}
if (xml instanceof CMLElement) {
return (CMLElement) xml.copy();
} else {
Document doc = new Document((Element) xml.copy());
try {
Document doc2 = new CMLBuilder().build(doc.toXML(), doc.getBaseURI());
CMLElement cmlElement = (CMLElement) doc2.getRootElement();
return cmlElement;
} catch (Exception e) {
CMLUtil.debug(xml, "ensureCMLProblem "+e);
throw new RuntimeException("ensureCMLProblem", e);
}
}
}
代码示例来源:origin: com.io7m.jstructural/io7m-jstructural-tools
@Override
public void onBodyEnd(
final Element body)
{
if (inserts.getBodyEnd().isSome()) {
final Some<Element> some = (Some<Element>) inserts.getBodyEnd();
body.appendChild(some.get().copy());
}
}
代码示例来源:origin: se.vgregion.pubsubhubbub/pubsubhubbub-hub-composite-pubsub
Element elm = (Element) doc.getRootElement().copy();
for(Field attrField : field.getFields()) {
String ns = attrField.getNamespace();
代码示例来源:origin: com.io7m.jstructural/io7m-jstructural-tools
@Override
public
@Nullable
Element onBodyStart(
final Element body)
{
if (inserts.getBodyStart().isSome()) {
final Some<Element> some = (Some<Element>) inserts.getBodyStart();
body.appendChild(some.get().copy());
}
return null;
}
内容来源于网络,如有侵权,请联系作者删除!