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

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

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

Element.copy介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

  1. public static org.w3c.dom.Document xomToDom(Element elem) {
  2. try {
  3. elem = (Element)elem.copy();
  4. return
  5. DOMConverter.convert(new Document(elem),
  6. DocumentBuilderFactory.newInstance().newDocumentBuilder().getDOMImplementation());
  7. } catch (ParserConfigurationException e) {
  8. throw new RuntimeException(e);
  9. }
  10. }

代码示例来源:origin: org.concordion/concordion

  1. public Element deepClone() {
  2. return new Element((nu.xom.Element) xomElement.copy());
  3. }
  4. }

代码示例来源:origin: concordion/concordion

  1. public Element deepClone() {
  2. return new Element((nu.xom.Element) xomElement.copy());
  3. }
  4. }

代码示例来源:origin: se.vgregion.pubsubhubbub/pubsubhubbub-hub-composite-pubsub

  1. public static Element stringToXml(String xml) {
  2. if(xml == null) return null;
  3. try {
  4. Document doc = PARSER.build(new StringReader(xml));
  5. Element elm = doc.getRootElement();
  6. return (Element) elm.copy();
  7. } catch (Exception e) {
  8. throw new RuntimeException(e);
  9. }
  10. }

代码示例来源:origin: se.vgregion.pubsubhubbub/pubsubhubbub-hub-composite-pubsub

  1. public static String xmlToString(Element elm) {
  2. // TODO ugly hack to retain namespaces
  3. return new Document((Element) elm.copy()).toXML().replaceFirst("<.+>", "");
  4. }

代码示例来源:origin: com.io7m.kstructural/io7m-kstructural-frontend

  1. private KSBrandAppender(
  2. final Optional<Element> in_brand_top,
  3. final Optional<Element> in_brand_bottom)
  4. {
  5. this.brand_start = NullCheck.notNull(in_brand_top);
  6. this.brand_end = NullCheck.notNull(in_brand_bottom);
  7. this.appender_start = (e) -> {
  8. if (this.brand_start.isPresent()) {
  9. e.insertChild(this.brand_start.get().copy(), 0);
  10. }
  11. };
  12. this.appender_end = (e) -> {
  13. if (this.brand_end.isPresent()) {
  14. e.insertChild(this.brand_end.get().copy(), 0);
  15. }
  16. };
  17. }

代码示例来源:origin: org.xml-cml/cmlxom

  1. /**
  2. * write XML for an element node. copies elements so it doesn't have a
  3. * document parent
  4. *
  5. * @param elem
  6. * @return the XML String
  7. */
  8. public String getXML(Element elem) {
  9. Element clone = (Element) elem.copy();
  10. Document doc = new Document(clone);
  11. return getXML(doc);
  12. }

代码示例来源:origin: io.snappydata/gemfire-core

  1. public static Node createNode(String xmlDefintion) {
  2. Node node = null;
  3. try {
  4. node = builder2.build(new StringReader(xmlDefintion)).getRootElement().copy();
  5. } catch (ValidityException e) {
  6. e.printStackTrace();
  7. } catch (ParsingException e) {
  8. e.printStackTrace();
  9. } catch (IOException e) {
  10. e.printStackTrace();
  11. }
  12. return node;
  13. }

代码示例来源:origin: zanata/zanata-platform

  1. public static ImmutableList<Element> getChildren(HasTMMetadata fromEntity) {
  2. try {
  3. String metadataString =
  4. fromEntity.getMetadata(TMMetadataType.TMX14);
  5. if (metadataString == null) {
  6. return ImmutableList.of();
  7. }
  8. @SuppressWarnings("unchecked")
  9. Map<String, Object> metadata =
  10. jsonMapper.readValue(metadataString, Map.class);
  11. List<String> children = getChildrenXml(metadata);
  12. Builder<Element> result = ImmutableList.builder();
  13. for (String childXml : children) {
  14. Document doc = new nu.xom.Builder().build(childXml, null);
  15. Element elem = (Element) doc.getRootElement().copy();
  16. result.add(elem);
  17. }
  18. return result.build();
  19. } catch (Exception e) {
  20. // error parsing XML or json, which "shouldn't happen"
  21. throw new RuntimeException(e);
  22. }
  23. }

代码示例来源:origin: zanata/zanata-platform

  1. /**
  2. * Supported children are currently {@code <prop>} and {@code <note>}.
  3. *
  4. * @param child
  5. * @param childrenXml
  6. */
  7. private static void addChildIfSupported(Element child,
  8. Builder<String> childrenXml) {
  9. String uri = child.getNamespaceURI();
  10. String name = child.getLocalName();
  11. if (inTmxNamespace(uri)
  12. && (name.equals("prop") || name.equals("note"))) {
  13. Element copy = (Element) child.copy();
  14. copy.setNamespacePrefix("");
  15. copy.setNamespaceURI("");
  16. childrenXml.add(copy.toXML());
  17. }
  18. }

代码示例来源:origin: org.xml-cml/cmlxom

  1. /**
  2. * Utility method that allows for convenient conversion of
  3. * <a href="http://www.cafeconleche.org/XOM/apidocs/index.html">XOM</a> elements to
  4. * CML elements if necessary.
  5. * always makes a copy
  6. *
  7. * @param xml a valid CMLElement
  8. * @return the {@link CMLElement}
  9. */
  10. public static CMLElement ensureCML(Element xml) {
  11. if (xml == null) {
  12. throw new RuntimeException("null cml");
  13. }
  14. if (xml instanceof CMLElement) {
  15. return (CMLElement) xml.copy();
  16. } else {
  17. Document doc = new Document((Element) xml.copy());
  18. try {
  19. Document doc2 = new CMLBuilder().build(doc.toXML(), doc.getBaseURI());
  20. CMLElement cmlElement = (CMLElement) doc2.getRootElement();
  21. return cmlElement;
  22. } catch (Exception e) {
  23. CMLUtil.debug(xml, "ensureCMLProblem "+e);
  24. throw new RuntimeException("ensureCMLProblem", e);
  25. }
  26. }
  27. }

代码示例来源:origin: com.io7m.jstructural/io7m-jstructural-tools

  1. @Override
  2. public void onBodyEnd(
  3. final Element body)
  4. {
  5. if (inserts.getBodyEnd().isSome()) {
  6. final Some<Element> some = (Some<Element>) inserts.getBodyEnd();
  7. body.appendChild(some.get().copy());
  8. }
  9. }

代码示例来源:origin: se.vgregion.pubsubhubbub/pubsubhubbub-hub-composite-pubsub

  1. Element elm = (Element) doc.getRootElement().copy();
  2. for(Field attrField : field.getFields()) {
  3. String ns = attrField.getNamespace();

代码示例来源:origin: com.io7m.jstructural/io7m-jstructural-tools

  1. @Override
  2. public
  3. @Nullable
  4. Element onBodyStart(
  5. final Element body)
  6. {
  7. if (inserts.getBodyStart().isSome()) {
  8. final Some<Element> some = (Some<Element>) inserts.getBodyStart();
  9. body.appendChild(some.get().copy());
  10. }
  11. return null;
  12. }

相关文章