當前位置: 首頁>>代碼示例>>Java>>正文


Java XMLSerializer.asContentHandler方法代碼示例

本文整理匯總了Java中com.sun.org.apache.xml.internal.serialize.XMLSerializer.asContentHandler方法的典型用法代碼示例。如果您正苦於以下問題:Java XMLSerializer.asContentHandler方法的具體用法?Java XMLSerializer.asContentHandler怎麽用?Java XMLSerializer.asContentHandler使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.sun.org.apache.xml.internal.serialize.XMLSerializer的用法示例。


在下文中一共展示了XMLSerializer.asContentHandler方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: XmlEditsVisitor

import com.sun.org.apache.xml.internal.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:Nextzero,項目名稱:hadoop-2.6.0-cdh5.4.3,代碼行數:24,代碼來源:XmlEditsVisitor.java

示例2: openResultFile

import com.sun.org.apache.xml.internal.serialize.XMLSerializer; //導入方法依賴的package包/類
private void openResultFile(File outputFile) throws SAXException
{
   try
   {
      out = new FileOutputStream(outputFile);

      OutputFormat of = new OutputFormat("XML", FILE_ENCODING, true);
      of.setIndent(1);
      of.setIndenting(true);
      XMLSerializer serializer = new XMLSerializer(out, of);

      writer = serializer.asContentHandler();
      writer.startDocument();

      startElement(XML_ROOT, NO_ATTRIBS);
   }
   catch (IOException io)
   {
      logger.error(ERROR_WRITE_RESULTS, io);
      close();
   }
}
 
開發者ID:dheraclio,項目名稱:dependometer,代碼行數:23,代碼來源:XMLWriter.java

示例3: BackupDbCassandra

import com.sun.org.apache.xml.internal.serialize.XMLSerializer; //導入方法依賴的package包/類
BackupDbCassandra(Keyspace keyspace, ColumnFamilyDefinition cfd, File outfile) throws Exception {
	quotedprintablecodec = new QuotedPrintableCodec("UTF-8");
	String cfname = cfd.getName();
	
	/**
	 * Preparation
	 */
	fileoutputstream = new FileOutputStream(outfile);
	
	OutputFormat of = new OutputFormat();
	of.setMethod("xml");
	of.setEncoding("UTF-8");
	of.setVersion("1.0");
	of.setIndenting(BackupDb.mode_debug);
	if (BackupDb.mode_debug) {
		of.setIndent(2);
	}
	
	XMLSerializer serializer = new XMLSerializer(fileoutputstream, of);
	content = serializer.asContentHandler();
	content.startDocument();
	
	/**
	 * Headers
	 */
	AttributesImpl atts = new AttributesImpl();
	atts.addAttribute("", "", "keyspace", "CDATA", CassandraDb.default_keyspacename);
	atts.addAttribute("", "", "name", "CDATA", cfname);
	atts.addAttribute("", "", "created", "CDATA", String.valueOf(System.currentTimeMillis()));
	if (BackupDb.mode_debug) {
		atts.addAttribute("", "", "created_date", "CDATA", (new Date()).toString());
	}
	content.startElement("", "", "columnfamily", atts);
	
	/**
	 * Import description
	 */
	List<ColumnDefinition> l_cd = cfd.getColumnDefinitionList();
	for (int pos = 0; pos < l_cd.size(); pos++) {
		atts.clear();
		atts.addAttribute("", "", "name", "CDATA", l_cd.get(pos).getName());
		atts.addAttribute("", "", "indexname", "CDATA", l_cd.get(pos).getIndexName());
		atts.addAttribute("", "", "validationclass", "CDATA", l_cd.get(pos).getValidationClass());
		content.startElement("", "", "coldef", atts);
		content.endElement("", "", "coldef");
	}
}
 
開發者ID:hdsdi3g,項目名稱:MyDMAM,代碼行數:48,代碼來源:BackupDbCassandra.java


注:本文中的com.sun.org.apache.xml.internal.serialize.XMLSerializer.asContentHandler方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。