本文整理了Java中org.dom4j.io.OutputFormat.setPadText()
方法的一些代码示例,展示了OutputFormat.setPadText()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OutputFormat.setPadText()
方法的具体详情如下:
包路径:org.dom4j.io.OutputFormat
类名称:OutputFormat
方法名:setPadText
[英]Ensure that text immediately preceded by or followed by an element will be "padded" with a single space. This is used to allow make browser-friendly HTML, avoiding trimText's transformation of, e.g., The quick <b>brown</b> fox
into The quick<b>brown</b>fox
(the latter will run the three separate words together into a single word). This setting is not too useful if you haven't also called #setTrimText. The padding string will only be added if the text itself starts or ends with some whitespace characters. Default: false
[中]确保紧跟在元素前面或后面的文本将用单个空格“填充”。这是用来让浏览器友好的HTML,避免trimText的转换,例如,The quick <b>brown</b> fox
到The quick<b>brown</b>fox
(后者将三个单独的单词一起运行成一个单词)。如果您还没有调用#setTrimText,那么这个设置就不太有用。仅当文本本身以一些空白字符开头或结尾时,才会添加填充字符串。默认值:false
代码示例来源:origin: org.dom4j/dom4j
setTrimText(true);
} else if (args[i].equals("-padText")) {
setPadText(true);
} else if (args[i].startsWith("-xhtml")) {
setXHTML(true);
代码示例来源:origin: org.dom4j/dom4j
/**
* A static helper method to create the default pretty printing format. This
* format consists of an indent of 2 spaces, newlines after each element and
* all other whitespace trimmed, and XMTML is false.
*
* @return DOCUMENT ME!
*/
public static OutputFormat createPrettyPrint() {
OutputFormat format = new OutputFormat();
format.setIndentSize(2);
format.setNewlines(true);
format.setTrimText(true);
format.setPadText(true);
return format;
}
代码示例来源:origin: org.mule.modules/mule-module-xml
/**
* @see OutputFormat#getEncoding()
*/
public synchronized void setPadText(boolean padText)
{
outputFormat.setPadText(padText);
}
代码示例来源:origin: dom4j/dom4j
setTrimText(true);
} else if (args[i].equals("-padText")) {
setPadText(true);
} else if (args[i].startsWith("-xhtml")) {
setXHTML(true);
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.dom4j
setTrimText(true);
} else if (args[i].equals("-padText")) {
setPadText(true);
} else if (args[i].startsWith("-xhtml")) {
setXHTML(true);
代码示例来源:origin: com.alibaba.citrus.tool/antx-autoexpand
setTrimText(true);
} else if (args[i].equals("-padText")) {
setPadText(true);
} else if (args[i].startsWith("-xhtml")) {
setXHTML(true);
代码示例来源:origin: dom4j/dom4j
/**
* A static helper method to create the default pretty printing format. This
* format consists of an indent of 2 spaces, newlines after each element and
* all other whitespace trimmed, and XMTML is false.
*
* @return DOCUMENT ME!
*/
public static OutputFormat createPrettyPrint() {
OutputFormat format = new OutputFormat();
format.setIndentSize(2);
format.setNewlines(true);
format.setTrimText(true);
format.setPadText(true);
return format;
}
代码示例来源:origin: org.dom4j/org.motechproject.org.dom4j
/**
* A static helper method to create the default pretty printing format. This
* format consists of an indent of 2 spaces, newlines after each element and
* all other whitespace trimmed, and XMTML is false.
*
* @return DOCUMENT ME!
*/
public static OutputFormat createPrettyPrint() {
OutputFormat format = new OutputFormat();
format.setIndentSize(2);
format.setNewlines(true);
format.setTrimText(true);
format.setPadText(true);
return format;
}
代码示例来源:origin: maven/dom4j
/**
* A static helper method to create the default pretty printing format. This
* format consists of an indent of 2 spaces, newlines after each element and
* all other whitespace trimmed, and XMTML is false.
*
* @return DOCUMENT ME!
*/
public static OutputFormat createPrettyPrint() {
OutputFormat format = new OutputFormat();
format.setIndentSize(2);
format.setNewlines(true);
format.setTrimText(true);
format.setPadText(true);
return format;
}
代码示例来源:origin: org.jenkins-ci.dom4j/dom4j
/**
* A static helper method to create the default pretty printing format. This
* format consists of an indent of 2 spaces, newlines after each element and
* all other whitespace trimmed, and XMTML is false.
*
* @return DOCUMENT ME!
*/
public static OutputFormat createPrettyPrint() {
OutputFormat format = new OutputFormat();
format.setIndentSize(2);
format.setNewlines(true);
format.setTrimText(true);
format.setPadText(true);
return format;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.dom4j
/**
* A static helper method to create the default pretty printing format. This
* format consists of an indent of 2 spaces, newlines after each element and
* all other whitespace trimmed, and XMTML is false.
*
* @return DOCUMENT ME!
*/
public static OutputFormat createPrettyPrint() {
OutputFormat format = new OutputFormat();
format.setIndentSize(2);
format.setNewlines(true);
format.setTrimText(true);
format.setPadText(true);
return format;
}
代码示例来源:origin: org.dom4j/com.springsource.org.dom4j
/**
* A static helper method to create the default pretty printing format. This
* format consists of an indent of 2 spaces, newlines after each element and
* all other whitespace trimmed, and XMTML is false.
*
* @return DOCUMENT ME!
*/
public static OutputFormat createPrettyPrint() {
OutputFormat format = new OutputFormat();
format.setIndentSize(2);
format.setNewlines(true);
format.setTrimText(true);
format.setPadText(true);
return format;
}
代码示例来源:origin: apache/servicemix-bundles
/**
* A static helper method to create the default pretty printing format. This
* format consists of an indent of 2 spaces, newlines after each element and
* all other whitespace trimmed, and XMTML is false.
*
* @return DOCUMENT ME!
*/
public static OutputFormat createPrettyPrint() {
OutputFormat format = new OutputFormat();
format.setIndentSize(2);
format.setNewlines(true);
format.setTrimText(true);
format.setPadText(true);
return format;
}
代码示例来源:origin: com.alibaba.citrus.tool/antx-autoexpand
/**
* A static helper method to create the default pretty printing format. This
* format consists of an indent of 2 spaces, newlines after each element and
* all other whitespace trimmed, and XMTML is false.
*
* @return DOCUMENT ME!
*/
public static OutputFormat createPrettyPrint() {
OutputFormat format = new OutputFormat();
format.setIndentSize(2);
format.setNewlines(true);
format.setTrimText(true);
format.setPadText(true);
return format;
}
代码示例来源:origin: dom4j/dom4j
private void testGitHubIssue26(final Element element) throws IOException {
final OutputFormat format = new OutputFormat(" ", true);
format.setSuppressDeclaration(false);
format.setTrimText(true);
format.setPadText(true);
format.setNewlines(true);
new XMLWriter(new CharArrayWriter(128), format).write(element);
}
代码示例来源:origin: com.intoverflow.booster/booster-core
public static OutputFormat createPrettyPrint() {
// OutputFormat format= OutputFormat.createPrettyPrint();
OutputFormat format = new OutputFormat();
format.setIndentSize(2);
format.setIndent("\t");
format.setNewlines(true);
format.setTrimText(true);
format.setPadText(true);
format.setNewLineAfterDeclaration(false);
return format;
}
代码示例来源:origin: com.intoverflow.base/intoverflow-util
public static OutputFormat createPrettyPrint() {
// OutputFormat format= OutputFormat.createPrettyPrint();
OutputFormat format = new OutputFormat();
format.setIndentSize(2);
format.setIndent("\t");
format.setNewlines(true);
format.setTrimText(true);
format.setPadText(true);
format.setNewLineAfterDeclaration(false);
return format;
}
代码示例来源:origin: dom4j/dom4j
public void testGitHubIssue26_case7() throws IOException {
final Element element = new DOMElement("foo");
element.add(new DOMText(""));
element.add(new DOMElement("elem"));
final OutputFormat format = new OutputFormat(" ", true);
format.setSuppressDeclaration(false);
format.setTrimText(false);
format.setPadText(true);
format.setNewlines(true);
new XMLWriter(new CharArrayWriter(128), format).write(element);
}
代码示例来源:origin: dom4j/dom4j
public void testPadding2() throws Exception {
Document doc = DocumentFactory.getInstance().createDocument();
Element root = doc.addElement("root");
root.addText("prefix");
root.addElement("b");
root.addText("suffix");
OutputFormat format = new OutputFormat("", false);
format.setOmitEncoding(true);
format.setSuppressDeclaration(true);
format.setExpandEmptyElements(true);
format.setPadText(true);
format.setTrimText(true);
StringWriter buffer = new StringWriter();
XMLWriter writer = new XMLWriter(buffer, format);
writer.write(doc);
String xml = buffer.toString();
System.out.println("xml: " + xml);
String expected = "<root>prefix<b></b>suffix</root>";
assertEquals(expected, xml);
}
代码示例来源:origin: dom4j/dom4j
public void testPadding() throws Exception {
Document doc = DocumentFactory.getInstance().createDocument();
Element root = doc.addElement("root");
root.addText("prefix ");
root.addElement("b");
root.addText(" suffix");
OutputFormat format = new OutputFormat("", false);
format.setOmitEncoding(true);
format.setSuppressDeclaration(true);
format.setExpandEmptyElements(true);
format.setPadText(true);
format.setTrimText(true);
StringWriter buffer = new StringWriter();
XMLWriter writer = new XMLWriter(buffer, format);
writer.write(doc);
String xml = buffer.toString();
System.out.println("xml: " + xml);
String expected = "<root>prefix <b></b> suffix</root>";
assertEquals(expected, xml);
}
内容来源于网络,如有侵权,请联系作者删除!