本文整理汇总了Java中org.apache.xml.serialize.XMLSerializer.asContentHandler方法的典型用法代码示例。如果您正苦于以下问题:Java XMLSerializer.asContentHandler方法的具体用法?Java XMLSerializer.asContentHandler怎么用?Java XMLSerializer.asContentHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.xml.serialize.XMLSerializer
的用法示例。
在下文中一共展示了XMLSerializer.asContentHandler方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: XmlEditsVisitor
import org.apache.xml.serialize.XMLSerializer; //导入方法依赖的package包/类
/**
* Create a processor that writes to the file named and may or may not
* also output to the screen, as specified.
*
* @param filename Name of file to write output to
* @param printToScreen Mirror output to screen?
*/
public XmlEditsVisitor(OutputStream out)
throws IOException {
this.out = out;
OutputFormat outFormat = new OutputFormat("XML", "UTF-8", true);
outFormat.setIndenting(true);
outFormat.setIndent(2);
outFormat.setDoctype(null, null);
XMLSerializer serializer = new XMLSerializer(out, outFormat);
contentHandler = serializer.asContentHandler();
try {
contentHandler.startDocument();
contentHandler.startElement("", "", "EDITS", new AttributesImpl());
} catch (SAXException e) {
throw new IOException("SAX error: " + e.getMessage());
}
}
示例2: saveSubscription
import org.apache.xml.serialize.XMLSerializer; //导入方法依赖的package包/类
public static void saveSubscription(SipSubscription sub) throws IOException, SAXException
{
String filename = spoolPath + "/subscriptions/" + ((SipURI) sub.localParty.getURI()).getUser() + "_" + sub.callId;
FileOutputStream fs = new FileOutputStream(new File(filename));
OutputFormat of = new OutputFormat("XML", "ISO-8859-1", true);
of.setIndent(1);
of.setIndenting(true);
XMLSerializer serializer = new XMLSerializer(fs, of);
ContentHandler hd = serializer.asContentHandler();
hd.startDocument();
hd.startElement("", "", "SUBSCRIPTION", null);
sub.buildSubscriptionXML(hd);
hd.endElement("", "", "SUBSCRIPTION");
hd.endDocument();
fs.close();
}
示例3: saveWatcher
import org.apache.xml.serialize.XMLSerializer; //导入方法依赖的package包/类
public static void saveWatcher(SipSubscription sub) throws IOException, SAXException
{
String filename = spoolPath + "/watchers/" + ((SipURI) sub.localParty.getURI()).getUser() + "_" + sub.callId;
FileOutputStream fs = new FileOutputStream(new File(filename));
OutputFormat of = new OutputFormat("XML", "ISO-8859-1", true);
of.setIndent(1);
of.setIndenting(true);
XMLSerializer serializer = new XMLSerializer(fs, of);
ContentHandler hd = serializer.asContentHandler();
hd.startDocument();
hd.startElement("", "", "SUBSCRIPTION", null);
sub.buildSubscriptionXML(hd);
hd.endElement("", "", "SUBSCRIPTION");
hd.endDocument();
fs.close();
}