本文整理了Java中org.apache.xml.serialize.OutputFormat.setCDataElements()
方法的一些代码示例,展示了OutputFormat.setCDataElements()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OutputFormat.setCDataElements()
方法的具体详情如下:
包路径:org.apache.xml.serialize.OutputFormat
类名称:OutputFormat
方法名:setCDataElements
[英]Sets the list of elements for which text node children should be output as CDATA.
[中]设置文本节点子节点应输出为CDATA的元素列表。
代码示例来源:origin: jersey/jersey
private static XMLSerializer getXMLSerializer(final OutputStream os, final String[] cdataElements)
throws InstantiationException,
IllegalAccessException, ClassNotFoundException {
// configure an OutputFormat to handle CDATA
final OutputFormat of = new OutputFormat();
// specify which of your elements you want to be handled as CDATA.
// The use of the '^' between the namespaceURI and the localname
// seems to be an implementation detail of the xerces code.
// When processing xml that doesn't use namespaces, simply omit the
// namespace prefix as shown in the third CDataElement below.
of.setCDataElements(cdataElements);
// set any other options you'd like
of.setPreserveSpace(true);
of.setIndenting(true);
// create the serializer
final XMLSerializer serializer = new XMLSerializer(of);
serializer.setOutputByteStream(os);
return serializer;
}
代码示例来源:origin: pentaho/pentaho-platform
private static XMLSerializer getXMLSerializer( OutputStream os )
throws InstantiationException, IllegalAccessException, ClassNotFoundException {
OutputFormat of = new OutputFormat();
of.setCDataElements( new String[] { "ns1^commentText", "ns2^commentText", "^commentText" } );
XMLSerializer serializer = new XMLSerializer( of );
serializer.setOutputByteStream( os );
return serializer;
}
代码示例来源:origin: com.atlassian.jersey/atlassian-jersey-restdoc
private static XMLSerializer getXMLSerializer( OutputStream os, String[] cdataElements ) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
// configure an OutputFormat to handle CDATA
OutputFormat of = new OutputFormat();
// specify which of your elements you want to be handled as CDATA.
// The use of the '^' between the namespaceURI and the localname
// seems to be an implementation detail of the xerces code.
// When processing xml that doesn't use namespaces, simply omit the
// namespace prefix as shown in the third CDataElement below.
of.setCDataElements( cdataElements );
// set any other options you'd like
of.setPreserveSpace(true);
of.setIndenting(true);
// create the serializer
XMLSerializer serializer = new XMLSerializer(of);
serializer.setOutputByteStream( os );
return serializer;
}
内容来源于网络,如有侵权,请联系作者删除!