当前位置: 首页>>代码示例>>Java>>正文


Java XMLOutputter.outputString方法代码示例

本文整理汇总了Java中org.jdom2.output.XMLOutputter.outputString方法的典型用法代码示例。如果您正苦于以下问题:Java XMLOutputter.outputString方法的具体用法?Java XMLOutputter.outputString怎么用?Java XMLOutputter.outputString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jdom2.output.XMLOutputter的用法示例。


在下文中一共展示了XMLOutputter.outputString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getStringFromElement

import org.jdom2.output.XMLOutputter; //导入方法依赖的package包/类
/**
 * 
 * @param element
 * @param encoding
 * @return
 */
public static String getStringFromElement(Element element, String encoding) {
    if (element == null) {
        throw new IllegalArgumentException("element may not be null");
    }
    if (encoding == null) {
        encoding = DEFAULT_ENCODING;
    }
    Format format = Format.getRawFormat();
    XMLOutputter outputter = new XMLOutputter(format);
    Format xmlFormat = outputter.getFormat();
    if (StringUtils.isNotEmpty(encoding)) {
        xmlFormat.setEncoding(encoding);
    }
    xmlFormat.setExpandEmptyElements(true);
    outputter.setFormat(xmlFormat);
    String docString = outputter.outputString(element);

    return docString;
}
 
开发者ID:intranda,项目名称:goobi-viewer-indexer,代码行数:26,代码来源:TextHelper.java

示例2: writeMuleXmlFile

import org.jdom2.output.XMLOutputter; //导入方法依赖的package包/类
private void writeMuleXmlFile(Element element, VirtualFile muleConfig) {

        XMLOutputter xout = new XMLOutputter(Format.getPrettyFormat());
        InputStream inputStream = null;
        try {
            String outputString = xout.outputString(element);
            logger.debug("*** OUTPUT STRING IS " + outputString);
            OutputStreamWriter writer = new OutputStreamWriter(muleConfig.getOutputStream(this));
            writer.write(outputString);
            writer.flush();
            writer.close();
        } catch (Exception e) {
            logger.error("Unable to write file: " + e);
            e.printStackTrace();
        } finally {
            IOUtils.closeQuietly(inputStream);
        }
    }
 
开发者ID:machaval,项目名称:mule-intellij-plugins,代码行数:19,代码来源:SOAPKitScaffoldingAction.java

示例3: parseString

import org.jdom2.output.XMLOutputter; //导入方法依赖的package包/类
/**
 * Parses a JDom2 Object into a string
 * @param e
 *            Object (Element, Text, Document or Attribute)
 * @return String
 * @author sholzer (11.05.2015)
 */
public String parseString(Object e) {
    XMLOutputter element2String = new XMLOutputter();
    if (e instanceof Element) {
        return element2String.outputString((Element) e);
    }
    if (e instanceof Text) {
        return element2String.outputString((Text) e);
    }
    if (e instanceof Document) {
        return element2String.outputString((Document) e);
    }
    if (e instanceof org.jdom2.Attribute) {
        Attribute a = (org.jdom2.Attribute) e;
        return a.getName() + "=\"" + a.getValue() + "\"";
    }
    return e.toString();
}
 
开发者ID:maybeec,项目名称:lexeme,代码行数:25,代码来源:JDom2Util.java

示例4: getBackXMLTypeText

import org.jdom2.output.XMLOutputter; //导入方法依赖的package包/类
/**
 * 纯文本回复
 * @param toName
 * @param fromName
 * @param content
 * @return
 */
public  String getBackXMLTypeText(String toName, String fromName,
		String content) {
	String returnStr = "";
	SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
	String times = format.format(new Date());
	Element rootXML = new Element("xml");
	rootXML.addContent(new Element("ToUserName").setText(toName));
	rootXML.addContent(new Element("FromUserName").setText(fromName));
	rootXML.addContent(new Element("CreateTime").setText(times));
	rootXML.addContent(new Element("MsgType").setText("text"));
	rootXML.addContent(new Element("Content").setText(content));
	Document doc = new Document(rootXML);
	XMLOutputter XMLOut = new XMLOutputter();
	returnStr = XMLOut.outputString(doc);
	System.out.println(returnStr);
	return returnStr;
}
 
开发者ID:jialiuyang,项目名称:appBack,代码行数:25,代码来源:dom2Xml.java

示例5: createOPFResource

import org.jdom2.output.XMLOutputter; //导入方法依赖的package包/类
public static XMLResource createOPFResource(Book book) throws IllegalArgumentException, IllegalStateException
{
    Document opfDocument = write(book);

    XMLOutputter outputter = new XMLOutputter();
    Format xmlFormat = Format.getPrettyFormat();
    outputter.setFormat(xmlFormat);
    String text = outputter.outputString(opfDocument);

    XMLResource resource = null;
    try
    {
        resource = new XMLResource("opf", text.getBytes(Constants.CHARACTER_ENCODING), "OEBPS/content.opf", MediaType.OPF);
    }
    catch (UnsupportedEncodingException e)
    {
        //should never happens
    }
    return resource;
}
 
开发者ID:finanzer,项目名称:epubfx,代码行数:21,代码来源:PackageDocumentWriter.java

示例6: repair

import org.jdom2.output.XMLOutputter; //导入方法依赖的package包/类
public static String repair(String originalHtml)
{
    String content = null;
    try
    {
        HtmlCleaner cleaner = createHtmlCleaner();

        //wir probieren es erstmal mit UTF-8
        TagNode rootNode = cleaner.clean(originalHtml);
        Document jdomDocument = new JDomSerializer(cleaner.getProperties(), false).createJDom(rootNode);
        jdomDocument.setDocType(Constants.DOCTYPE_XHTML.clone());

        XMLOutputter outputter = new XMLOutputter();
        Format xmlFormat = Format.getPrettyFormat();
        outputter.setFormat(xmlFormat);
        outputter.setXMLOutputProcessor(new XHTMLOutputProcessor());
        content = outputter.outputString(jdomDocument);
    }
    catch (IllegalAddException e)
    {
        logger.error("", e);
    }
    return content;
}
 
开发者ID:finanzer,项目名称:epubfx,代码行数:25,代码来源:XHTMLUtils.java

示例7: parseTextConstructToString

import org.jdom2.output.XMLOutputter; //导入方法依赖的package包/类
private String parseTextConstructToString(Element e) {
    String value = null;
    String type = getAttributeValue(e, "type");
    type = (type!=null) ? type : Content.TEXT;
    if (type.equals(Content.XHTML) || (type.indexOf("/xml")) != -1 || (type.indexOf("+xml")) != -1) {
        // XHTML content needs special handling
        XMLOutputter outputter = new XMLOutputter();
        List eContent = e.getContent();
        Iterator i = eContent.iterator();
        while (i.hasNext()) {
            org.jdom2.Content c = (org.jdom2.Content) i.next();
            if (c instanceof Element) {
                Element eC = (Element) c;
                if (eC.getNamespace().equals(getAtomNamespace())) {
                    ((Element)c).setNamespace(Namespace.NO_NAMESPACE);
                }
            }
        }
        value = outputter.outputString(eContent);
    } else {
        // Everything else comes in verbatim
        value = e.getText();
    }
    return value;
}
 
开发者ID:apache,项目名称:marmotta,代码行数:26,代码来源:Atom10Parser.java

示例8: getXHELM2

import org.jdom2.output.XMLOutputter; //导入方法依赖的package包/类
/**
 * method to get xhelm for the helm2 notation with the new functionality
 *
 * @param helm2notation, HELM2Notation object
 * @return xhelm
 * @throws MonomerException if monomer is not valid
 * @throws JDOMException jdome error
 * @throws IOException IO error
 * @throws ChemistryException if chemistry engine can not be initialized
 */
public static String getXHELM2(HELM2Notation helm2notation) throws MonomerException, IOException, JDOMException, ChemistryException {
  set = new HashSet<Monomer>();
  Element root = new Element(xHelmNotationExporter.XHELM_ELEMENT);

  Document doc = new Document(root);

  Element helmElement = new Element(xHelmNotationExporter.HELM_NOTATION_ELEMENT);
  helmElement.setText(helm2notation.toHELM2());

  root.addContent(helmElement);

  Element monomerListElement = new Element(xHelmNotationExporter.MONOMER_LIST_ELEMENT);

  /* save all adhocMonomers */
  for (MonomerNotation monomernotation : MethodsMonomerUtils.getListOfMonomerNotation(helm2notation.getListOfPolymers())) {
    /* get all elements of an rna */
    if (monomernotation instanceof MonomerNotationUnitRNA) {
      for (MonomerNotationUnit unit : ((MonomerNotationUnitRNA) monomernotation).getContents()) {
        addAdHocMonomer(unit);
      }
    } else {
      addAdHocMonomer(monomernotation);

    }

  }
  /* give the adhocMonomer's information */
  for (Monomer distinctmonomer : set) {
    Element monomerElement = MonomerParser.getMonomerElement(distinctmonomer);
    monomerListElement.getChildren().add(monomerElement);
  }

  root.addContent(monomerListElement);
  XMLOutputter xmlOutput = new XMLOutputter();
  // display nice
  xmlOutput.setFormat(Format.getPrettyFormat());
  return xmlOutput.outputString(doc);
}
 
开发者ID:PistoiaHELM,项目名称:HELM2NotationToolkit,代码行数:49,代码来源:xHelmNotationExporter.java

示例9: kafToStr

import org.jdom2.output.XMLOutputter; //导入方法依赖的package包/类
/**
     * Returns a string containing the XML content of a KAFDocument object.
     */
    static String kafToStr(KAFDocument kaf) {
        XMLOutputter out = new XMLOutputter(Format.getPrettyFormat().setLineSeparator(LineSeparator.UNIX));
//		out.getFormat().setTextMode(Format.TextMode.PRESERVE);
        Document jdom = KAFToDOM(kaf);
        return out.outputString(jdom);
    }
 
开发者ID:dkmfbk,项目名称:pikes,代码行数:10,代码来源:ReadWriteManager.java

示例10: assertEqualDocumentSerialization

import org.jdom2.output.XMLOutputter; //导入方法依赖的package包/类
public static void assertEqualDocumentSerialization(Document expected, Document actual) {
    XMLOutputter outputter = new XMLOutputter();
    outputter.setFormat(Format.getPrettyFormat());
    String expectedAsString = outputter.outputString(expected);
    String actualAsString = outputter.outputString(actual);
    assertEquals(expectedAsString, actualAsString);
}
 
开发者ID:uniba-dsg,项目名称:BPMNspector,代码行数:8,代码来源:DocHandlingHelper.java

示例11: toXML

import org.jdom2.output.XMLOutputter; //导入方法依赖的package包/类
public String toXML()
{
	Element root = new Element("morph");
	Document doc = new Document(root);
	
	doc.getRootElement().addContent(new Element("name").setText( getName() ));
	
	XMLOutputter xmlOut = new XMLOutputter();
	xmlOut.setFormat(Format.getPrettyFormat().setOmitDeclaration(true));
	
	return xmlOut.outputString(doc);	
}
 
开发者ID:DistantEye,项目名称:EP_Utilities,代码行数:13,代码来源:Morph.java

示例12: toXML

import org.jdom2.output.XMLOutputter; //导入方法依赖的package包/类
public String toXML()
{
	Element root = new Element("rep");
	Document doc = new Document(root);
	
	doc.getRootElement().addContent(new Element("name").setText( getName() ));
	doc.getRootElement().addContent(new Element("value").setText( ""+getValue() ));
	
	XMLOutputter xmlOut = new XMLOutputter();
	xmlOut.setFormat(Format.getPrettyFormat().setOmitDeclaration(true));
	
	return xmlOut.outputString(doc);
}
 
开发者ID:DistantEye,项目名称:EP_Utilities,代码行数:14,代码来源:Rep.java

示例13: toXML

import org.jdom2.output.XMLOutputter; //导入方法依赖的package包/类
public String toXML()
{
	Element root = new Element("stat");
	Document doc = new Document(root);
	
	doc.getRootElement().addContent(new Element("name").setText( name ));
	doc.getRootElement().addContent(new Element("value").setText( ""+value ));
	
	XMLOutputter xmlOut = new XMLOutputter();
	xmlOut.setFormat(Format.getPrettyFormat().setOmitDeclaration(true));
	
	return xmlOut.outputString(doc);
}
 
开发者ID:DistantEye,项目名称:EP_Utilities,代码行数:14,代码来源:Stat.java

示例14: toXML

import org.jdom2.output.XMLOutputter; //导入方法依赖的package包/类
public String toXML()
{
	Element root = new Element("trait");
	Document doc = new Document(root);
	
	doc.getRootElement().addContent(new Element("name").setText( getName() ));
	doc.getRootElement().addContent(new Element("level").setText( ""+getLevel() ));
	
	XMLOutputter xmlOut = new XMLOutputter();
	xmlOut.setFormat(Format.getPrettyFormat().setOmitDeclaration(true));
	
	return xmlOut.outputString(doc);
}
 
开发者ID:DistantEye,项目名称:EP_Utilities,代码行数:14,代码来源:Trait.java

示例15: createNCXResource

import org.jdom2.output.XMLOutputter; //导入方法依赖的package包/类
public static Resource createNCXResource(List<Identifier> identifiers, String title, List<Author> authors, TableOfContents tableOfContents) throws IllegalArgumentException, IllegalStateException, IOException
{
    Document ncxDocument = write(identifiers, title, authors, tableOfContents);

    XMLOutputter outputter = new XMLOutputter();
    Format xmlFormat = Format.getPrettyFormat();
    outputter.setFormat(xmlFormat);
    String text = outputter.outputString(ncxDocument);

    Resource resource = MediaType.NCX.getResourceFactory().createResource(NCX_ITEM_ID, text.getBytes(Constants.CHARACTER_ENCODING), DEFAULT_NCX_HREF, MediaType.NCX);
    return resource;
}
 
开发者ID:finanzer,项目名称:epubfx,代码行数:13,代码来源:NCXDocument.java


注:本文中的org.jdom2.output.XMLOutputter.outputString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。