org.jdom2.output.Format.setExpandEmptyElements()方法的使用及代码示例

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

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

Format.setExpandEmptyElements介绍

[英]This will set whether empty elements are expanded from <tagName/> to <tagName></tagName>.
[中]这将设置是否将空元素从<tagName/>扩展到<tagName></tagName>

代码示例

代码示例来源:origin: org.apache.jspwiki/jspwiki-main

/**
   *  {@inheritDoc}
   */
  public String getString()
    throws IOException
  {
    m_document.setContext( m_context );

    CustomXMLOutputProcessor processor = new CustomXMLOutputProcessor();
    XMLOutputter output = new XMLOutputter(processor);

    StringWriter out = new StringWriter();

    Format fmt = Format.getRawFormat();
    fmt.setExpandEmptyElements( false );
    fmt.setLineSeparator( LINEBREAK );

    output.setFormat( fmt );
    output.outputElementContent( m_document.getRootElement(), out );

    String result = out.toString();
    return result;
  }
}

代码示例来源:origin: org.apache.jspwiki/jspwiki-main

/**
   *  {@inheritDoc}
   */
  public String getString()
    throws IOException
  {
    Element rootElement = m_document.getRootElement();
    processChildren( rootElement );

    m_document.setContext( m_context );

    XMLOutputter output = new XMLOutputter();

    StringWriter out = new StringWriter();

    Format fmt = Format.getRawFormat();
    fmt.setExpandEmptyElements( false );
    fmt.setLineSeparator( LINEBREAK );

    output.setFormat( fmt );
    output.outputElementContent( m_document.getRootElement(), out );

    return out.toString();
  }
}

代码示例来源:origin: TheHolyWaffle/League-of-Legends-XMPP-Chat-Library

/**
 * This constructor is not intended for usage.
 * 
 * @param xml
 *            An XML string
 * @throws JDOMException
 *             Is thrown when the xml string is invalid
 * @throws IOException
 *             Is thrown when the xml string is invalid
 */
public LolStatus(String xml) throws JDOMException, IOException {
  outputter
      .setFormat(outputter.getFormat().setExpandEmptyElements(false));
  final SAXBuilder saxBuilder = new SAXBuilder();
  doc = saxBuilder.build(new StringReader(xml));
  for (final Element e : doc.getRootElement().getChildren()) {
    boolean found = false;
    for (final XMLProperty p : XMLProperty.values()) {
      if (p.name().equals(e.getName())) {
        found = true;
      }
    }
    if (!found) {
      System.err.println("XMLProperty \"" + e.getName()
          + "\" value: \"" + e.getValue()
          + "\" not implemented yet!");
    }
  }
}

代码示例来源:origin: Vhati/Slipstream-Mod-Manager

format.setExpandEmptyElements( false );
format.setOmitDeclaration( false );
format.setIndent( "\t" );

代码示例来源:origin: TheHolyWaffle/League-of-Legends-XMPP-Chat-Library

/**
 * Generate a default LoLStatus that can later be modified and be used to
 * change the current LolStatus ({@link LolChat#setStatus(LolStatus)}).
 * 
 */
public LolStatus() {
  outputter
      .setFormat(outputter.getFormat().setExpandEmptyElements(false));
  doc = new Document(new Element("body"));
  for (final XMLProperty p : XMLProperty.values()) {
    doc.getRootElement().addContent(new Element(p.toString()));
  }
}

代码示例来源:origin: Vhati/Slipstream-Mod-Manager

Format format = Format.getPrettyFormat();
format.setExpandEmptyElements( false );
format.setOmitDeclaration( false );
format.setIndent( "\t" );

相关文章