org.dom4j.dom.DOMDocument.setRootElement()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(2.3k)|赞(0)|评价(0)|浏览(137)

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

DOMDocument.setRootElement介绍

暂无

代码示例

代码示例来源:origin: skyscreamer/yoga

public static void write( Element rootElement, OutputStream outputStream ) throws IOException
  {
    DOMDocument domDocument = new DOMDocument();
    domDocument.setRootElement( rootElement );
    OutputStreamWriter out = new OutputStreamWriter( outputStream );
    domDocument.write( out );
    out.flush();
    out.close();
  }
}

代码示例来源:origin: com.atlassian.jira/jira-core

public String toXML(final IndexDocumentConfiguration indexDocumentConfiguration)
{
  final DOMDocument document = new DOMDocument();
  final Element configurationElement = new DOMElement(INDEX_DOCUMENT_CONFIGURATION_ROOT);
  configurationElement.add(new DOMAttribute(QName.get(INDEX_DOCUMENT_ENTITY_KEY_ATTRIBUTE), indexDocumentConfiguration.getEntityKey()));
  document.setRootElement(configurationElement);
  for (final KeyConfiguration keyConfiguration : indexDocumentConfiguration.getKeyConfigurations())
  {
    final Element keyConfigurationElement = new DOMElement(INDEX_DOCUMENT_KEY_ELEMENT);
    keyConfigurationElement.add(new DOMAttribute(QName.get(INDEX_DOCUMENT_KEY_PROPERTY_KEY_ATTRIBUTE), keyConfiguration.getPropertyKey()));
    for (final ExtractConfiguration extractConfiguration : keyConfiguration.getExtractorConfigurations())
    {
      final Element extractConfigurationElement = new DOMElement(INDEX_DOCUMENT_EXTRACT_ELEMENT);
      extractConfigurationElement.add(new DOMAttribute(QName.get(INDEX_DOCUMENT_EXTRACT_PATH_ATTRIBUTE), extractConfiguration.getPath()));
      extractConfigurationElement.add(new DOMAttribute(QName.get(INDEX_DOCUMENT_EXTRACT_TYPE_ATTRIBUTE), extractConfiguration.getType().name()));
      extractConfiguration.getAlias().foreach(new Effect<String>()
      {
        @Override
        public void apply(final String alias)
        {
          extractConfigurationElement.add(new DOMAttribute(QName.get(INDEX_DOCUMENT_EXTRACT_ALIAS_ATTRIBUTE), alias));
        }
      });
      extractConfiguration.getPluginName().ifPresent((pluginName) -> extractConfigurationElement.addAttribute(QName.get(INDEX_DOCUMENT_EXTRACT_CONFLICTING_PLUGIN_NAME), pluginName));
      keyConfigurationElement.add(extractConfigurationElement);
    }
    configurationElement.add(keyConfigurationElement);
  }
  return document.asXML();
}

相关文章