📄 obj2xmltest.java
字号:
// You can redistribute this software and/or modify it under the terms of// the Ozone Library License version 1 published by ozone-db.org.//// The original code and portions created by SMB are// Copyright (C) 1997-2001 by SMB GmbH. All rights reserved.//// $Id: Obj2XMLTest.java,v 1.1 2003/11/02 17:29:30 per_nyfelt Exp $package test.openxml;import javax.xml.parsers.DocumentBuilder;import javax.xml.parsers.DocumentBuilderFactory;import junit.framework.Test;import junit.framework.TestSuite;import org.apache.xml.serialize.OutputFormat;import org.apache.xml.serialize.XMLSerializer;import org.w3c.dom.Document;import org.w3c.dom.Node;import org.xml.sax.ContentHandler;import org.xml.sax.helpers.DefaultHandler;/** * @author <a href="http://www.softwarebuero.de/">SMB</a> * @version $Revision: 1.1 $Date: 2003/11/02 17:29:30 $ */public class Obj2XMLTest extends OpenXmlTestCase { static DocumentBuilderFactory builderFactory = new org.apache.xerces.jaxp.DocumentBuilderFactoryImpl(); public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(Obj2XMLTest.class); return suite; } public Obj2XMLTest(String name) { super(name); } public void testSAX() throws Exception { Data data = (Data) db.createObject(DataImpl.class.getName()); data.setup(); ContentHandler handler = new DefaultHandler(); db.xmlForObject(data, handler); //XMLSerializer serializer = new XMLSerializer(System.out, new OutputFormat("xml", "UTF-8", true)); //db.xmlForObject(data, serializer.asContentHandler()); } public void testDOM() throws Exception { Data data = (Data) db.createObject(DataImpl.class.getName()); data.setup(); DocumentBuilder documentBuilder = builderFactory.newDocumentBuilder(); Document doc = documentBuilder.newDocument(); Node node = db.xmlForObject(data, doc); assertNotNull(node); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -