本文整理了Java中org.jdom.output.Format.setOmitDeclaration()
方法的一些代码示例,展示了Format.setOmitDeclaration()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Format.setOmitDeclaration()
方法的具体详情如下:
包路径:org.jdom.output.Format
类名称:Format
方法名:setOmitDeclaration
[英]This will set whether the XML declaration (<?xml version="1.0"?gt;
) will be omitted or not. It is common to omit this in uses such as SOAP and XML-RPC calls.
[中]这将设置是否省略XML声明(<?xml version="1.0"?gt;
)。在SOAP和XML-RPC调用等使用中,通常会忽略这一点。
代码示例来源:origin: pl.edu.icm.synat/synat-oai-server
private String cleanXmlDeclaration(String resultXML) {
try {
final SAXBuilder saxBuilder = new SAXBuilder("org.apache.xerces.parsers.SAXParser");
final Document doc = saxBuilder.build(new StringReader(resultXML));
XMLOutputter xmlOutputter = new XMLOutputter(Format.getPrettyFormat().setOmitDeclaration(true));
String xml = xmlOutputter.outputString(doc);
return xml;
} catch (Exception e) {
return null;
}
}
代码示例来源:origin: org.wildfly.camel/wildfly-camel-itests-common
public static String compactXML(InputStream input) throws Exception {
Document doc = new SAXBuilder().build(input);
XMLOutputter xo = new XMLOutputter();
xo.setFormat(Format.getCompactFormat().setOmitDeclaration(true));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
xo.output(doc, baos);
return new String(baos.toByteArray()).trim();
}
}
代码示例来源:origin: wildfly-extras/wildfly-camel
public static String compactXML(InputStream input) throws Exception {
Document doc = new SAXBuilder().build(input);
XMLOutputter xo = new XMLOutputter();
xo.setFormat(Format.getCompactFormat().setOmitDeclaration(true));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
xo.output(doc, baos);
return new String(baos.toByteArray()).trim();
}
}
代码示例来源:origin: com.mockrunner/mockrunner-jdbc
protected XMLOutputter createJDOMXMLCompareOutputter()
{
Format format = Format.getCompactFormat();
format.setOmitDeclaration(true);
format.setOmitEncoding(true);
return new XMLOutputter(format);
}
代码示例来源:origin: org.biomoby/taverna-biomoby
public static String createMobyDataElementWrapper(String xml,
String queryID, Element serviceNotes) throws MobyException {
if (xml == null)
return null;
Element element = createMobyDataElementWrapper(getDOMDocument(xml)
.getRootElement(), queryID, serviceNotes);
XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat()
.setOmitDeclaration(false));
return (element == null ? null : outputter.outputString(element));
}
代码示例来源:origin: info.magnolia/magnolia-core
public DocumentViewOutputter() {
final Format format = Format.getPrettyFormat();
format.setTextMode(Format.TextMode.NORMALIZE);
format.setOmitDeclaration(true);
setFormat(format);
}
代码示例来源:origin: org.biomoby/taverna-biomoby
/**
*
* @param oldName
* @param newName
* @param type
* @param xml
* @return
* @throws MobyException
*/
public static String renameSimple(String newName, String type, String xml)
throws MobyException {
return new XMLOutputter(Format.getPrettyFormat().setOmitDeclaration(
false)).outputString(renameSimple(newName, type,
getDOMDocument(xml).getRootElement()));
}
代码示例来源:origin: org.biomoby/taverna-biomoby
/**
*
* @param name
* @param xml
* @return
* @throws MobyException
*/
public static String getWrappedCollection(String name, String xml)
throws MobyException {
Element element = getWrappedCollection(name, getDOMDocument(xml)
.getRootElement());
XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat()
.setOmitDeclaration(false));
return outputter.outputString(element);
}
代码示例来源:origin: org.biomoby/taverna-biomoby
/**
*
* @param xmls
* @return
* @throws MobyException
*/
public static String createMultipleInvokations(String[] xmls)
throws MobyException {
Element[] elements = new Element[xmls.length];
for (int i = 0; i < elements.length; i++) {
elements[i] = getDOMDocument(xmls[i]).getRootElement();
}
XMLOutputter output = new XMLOutputter(Format.getPrettyFormat()
.setOmitDeclaration(false));
return output.outputString(createMultipleInvokations(elements));
}
代码示例来源:origin: org.biomoby/taverna-biomoby
/**
*
* @param newName
* the new name for this fully wrapped BioMOBY collection
* @param xml
* the fully wrapped BioMOBY collection
* @return an element 'Collection' representing the renamed collection
* @throws MobyException
* if the BioMOBY message is invalid or the xml is syntatically
* invalid.
*/
public static String renameCollection(String newName, String xml)
throws MobyException {
return new XMLOutputter(Format.getPrettyFormat().setOmitDeclaration(
false)).outputString(renameCollection(newName, getDOMDocument(
xml).getRootElement()));
}
代码示例来源:origin: org.biomoby/taverna-biomoby
/**
*
* @param xml
* a string of xml containing a single invocation message to
* extract the queryID from
* @return the element passed in to the method with the queryID set if the
* message was valid.
* @throws MobyException
* if the String of xml is syntatically invalid or if the
* message is a multiple invocation message
*/
public static String setQueryID(String xml, String id) throws MobyException {
return new XMLOutputter(Format.getPrettyFormat().setOmitDeclaration(
false)).outputString(setQueryID(getDOMDocument(xml)
.getRootElement(), id));
}
代码示例来源:origin: org.biomoby/taverna-biomoby
/**
*
* @param name
* @param xml
* @return
* @throws MobyException
*/
public static String getCollection(String name, String xml)
throws MobyException {
Element element = getDOMDocument(xml).getRootElement();
XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat()
.setOmitDeclaration(false));
Element collection = getCollection(name, element);
if (collection != null)
return outputter.outputString(collection);
return null;
}
代码示例来源:origin: org.biomoby/taverna-biomoby
/**
*
* @param xml
* a full moby message (root element called MOBY) and may be
* prefixed
* @return the serviceNotes element as a string if it exists, null
* otherwise.
*/
public static String getServiceNotes(String xml) {
try {
Element e = getServiceNotes(getDOMDocument(xml).getRootElement());
if (e == null)
return null;
XMLOutputter out = new XMLOutputter(Format.getPrettyFormat()
.setOmitDeclaration(false));
return out.outputString(e);
} catch (MobyException ex) {
return null;
}
}
代码示例来源:origin: org.biomoby/taverna-biomoby
/**
*
* @param name
* the articlename of the simple that you wish to extract
* @param xml
* the xml message
* @return the wrapped simple if it exists
* @throws MobyException
* if the message is a multiple invocation message or if the xml
* is syntatically invalid.
*/
public static String getWrappedSimple(String name, String xml)
throws MobyException {
Element element = getWrappedSimple(name, getDOMDocument(xml)
.getRootElement());
XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat()
.setOmitDeclaration(false));
return outputter.outputString(element);
}
代码示例来源:origin: org.biomoby/taverna-biomoby
/**
*
* @param xml
* @param queryID
* @return
* @throws MobyException
*/
public static String createMobyDataElementWrapper(String xml, String queryID)
throws MobyException {
if (xml == null)
return null;
Element serviceNotes = getServiceNotes(getDOMDocument(xml)
.getRootElement());
Element element = createMobyDataElementWrapper(getDOMDocument(xml)
.getRootElement(), queryID, serviceNotes);
XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat()
.setOmitDeclaration(false));
return (element == null ? null : outputter.outputString(element));
}
代码示例来源:origin: org.biomoby/taverna-biomoby
/**
*
* @param xml
* the message to extract the invocation messages from
* @return an array of String objects each representing a distinct BioMOBY
* invocation message.
* @throws MobyException
* if the moby message is invalid or if the xml is syntatically
* invalid.
*/
public static String[] getSingleInvokationsFromMultipleInvokations(
String xml) throws MobyException {
Element[] elements = getSingleInvokationsFromMultipleInvokations(getDOMDocument(
xml).getRootElement());
String[] strings = new String[elements.length];
XMLOutputter output = new XMLOutputter(Format.getPrettyFormat()
.setOmitDeclaration(false));
for (int i = 0; i < elements.length; i++) {
strings[i] = output.outputString(new Document(elements[i]));
}
return strings;
}
代码示例来源:origin: bcdev/beam
private static String toXMLString(Element metadataElement) {
// following lines uses the old JDOM jar
// xmlOutputter.setIndent(true);
// xmlOutputter.setIndent(" ");
// xmlOutputter.setNewlines(true);
// xmlOutputter.setExpandEmptyElements(false);
// xmlOutputter.setOmitEncoding(true);
// xmlOutputter.setOmitDeclaration(true);
// xmlOutputter.setTextNormalize(false);
final Format prettyFormat = Format.getPrettyFormat();
prettyFormat.setExpandEmptyElements(false);
prettyFormat.setOmitEncoding(true);
prettyFormat.setOmitDeclaration(true);
prettyFormat.setTextMode(Format.TextMode.NORMALIZE);
final XMLOutputter xmlOutputter = new XMLOutputter(prettyFormat);
final String xml = xmlOutputter.outputString(metadataElement);
return xml;
}
}
代码示例来源:origin: bcdev/beam
public String getAsXML() {
// following lines uses the old JDOM jar
// xmlOutputter.setIndent(true);
// xmlOutputter.setIndent(" ");
// xmlOutputter.setNewlines(true);
// xmlOutputter.setExpandEmptyElements(false);
// xmlOutputter.setOmitEncoding(true);
// xmlOutputter.setOmitDeclaration(true);
// xmlOutputter.setTextNormalize(true);
final Format prettyFormat = Format.getPrettyFormat();
prettyFormat.setExpandEmptyElements(false);
prettyFormat.setOmitEncoding(true);
prettyFormat.setOmitDeclaration(true);
prettyFormat.setTextMode(Format.TextMode.NORMALIZE);
final XMLOutputter xmlOutputter = new XMLOutputter(prettyFormat);
return xmlOutputter.outputString(createRootTree("class name list template"));
}
代码示例来源:origin: bcdev/beam
private static String getXML(Element metadataElement) {
// following lines uses the old JDOM jar
// xmlOutputter.setIndent(true);
// xmlOutputter.setIndent(" ");
// xmlOutputter.setNewlines(true);
// xmlOutputter.setExpandEmptyElements(false);
// xmlOutputter.setOmitEncoding(true);
// xmlOutputter.setOmitDeclaration(true);
// xmlOutputter.setTextNormalize(false);
final Format prettyFormat = Format.getPrettyFormat();
prettyFormat.setExpandEmptyElements(false);
prettyFormat.setOmitEncoding(true);
prettyFormat.setOmitDeclaration(true);
prettyFormat.setTextMode(Format.TextMode.PRESERVE);
final XMLOutputter xmlOutputter = new XMLOutputter(prettyFormat);
final String xml = xmlOutputter.outputString(metadataElement);
return xml;
}
代码示例来源:origin: bcdev/beam
@SuppressWarnings({"UnusedDeclaration"})
private void printDocument(Document document) {
final Format prettyFormat = Format.getPrettyFormat();
prettyFormat.setExpandEmptyElements(false);
prettyFormat.setOmitEncoding(true);
prettyFormat.setOmitDeclaration(true);
prettyFormat.setTextMode(Format.TextMode.NORMALIZE);
final XMLOutputter xmlOutputter = new XMLOutputter(prettyFormat);
final String xml = xmlOutputter.outputString(document);
System.out.println(xml);
}
内容来源于网络,如有侵权,请联系作者删除!