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


Java XMLSerializer.asContentHandler方法代码示例

本文整理汇总了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());
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:XmlEditsVisitor.java

示例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();
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:18,代码来源:SipSubscriptionManager.java

示例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();
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:18,代码来源:SipSubscriptionManager.java


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