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

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

本文整理了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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public String getString()
  5. throws IOException
  6. {
  7. m_document.setContext( m_context );
  8. CustomXMLOutputProcessor processor = new CustomXMLOutputProcessor();
  9. XMLOutputter output = new XMLOutputter(processor);
  10. StringWriter out = new StringWriter();
  11. Format fmt = Format.getRawFormat();
  12. fmt.setExpandEmptyElements( false );
  13. fmt.setLineSeparator( LINEBREAK );
  14. output.setFormat( fmt );
  15. output.outputElementContent( m_document.getRootElement(), out );
  16. String result = out.toString();
  17. return result;
  18. }
  19. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public String getString()
  5. throws IOException
  6. {
  7. Element rootElement = m_document.getRootElement();
  8. processChildren( rootElement );
  9. m_document.setContext( m_context );
  10. XMLOutputter output = new XMLOutputter();
  11. StringWriter out = new StringWriter();
  12. Format fmt = Format.getRawFormat();
  13. fmt.setExpandEmptyElements( false );
  14. fmt.setLineSeparator( LINEBREAK );
  15. output.setFormat( fmt );
  16. output.outputElementContent( m_document.getRootElement(), out );
  17. return out.toString();
  18. }
  19. }

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

  1. /**
  2. * This constructor is not intended for usage.
  3. *
  4. * @param xml
  5. * An XML string
  6. * @throws JDOMException
  7. * Is thrown when the xml string is invalid
  8. * @throws IOException
  9. * Is thrown when the xml string is invalid
  10. */
  11. public LolStatus(String xml) throws JDOMException, IOException {
  12. outputter
  13. .setFormat(outputter.getFormat().setExpandEmptyElements(false));
  14. final SAXBuilder saxBuilder = new SAXBuilder();
  15. doc = saxBuilder.build(new StringReader(xml));
  16. for (final Element e : doc.getRootElement().getChildren()) {
  17. boolean found = false;
  18. for (final XMLProperty p : XMLProperty.values()) {
  19. if (p.name().equals(e.getName())) {
  20. found = true;
  21. }
  22. }
  23. if (!found) {
  24. System.err.println("XMLProperty \"" + e.getName()
  25. + "\" value: \"" + e.getValue()
  26. + "\" not implemented yet!");
  27. }
  28. }
  29. }

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

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

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

  1. /**
  2. * Generate a default LoLStatus that can later be modified and be used to
  3. * change the current LolStatus ({@link LolChat#setStatus(LolStatus)}).
  4. *
  5. */
  6. public LolStatus() {
  7. outputter
  8. .setFormat(outputter.getFormat().setExpandEmptyElements(false));
  9. doc = new Document(new Element("body"));
  10. for (final XMLProperty p : XMLProperty.values()) {
  11. doc.getRootElement().addContent(new Element(p.toString()));
  12. }
  13. }

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

  1. Format format = Format.getPrettyFormat();
  2. format.setExpandEmptyElements( false );
  3. format.setOmitDeclaration( false );
  4. format.setIndent( "\t" );

相关文章