Created with colorer-take5 library. Type 'net.sf.colorer.filetype@777255'
0: / *
1: * CREATED ON 2005-4-19
2: *
3: * CopyRight (C) 2005 Julysea
4: * WINDOW - Preferences - Java - Code Style - Code Templates
5: * /
6:
7: / * Apply this log4j log4j.properties configuration file
8: *
9: *############################################### ################################
10: * # categories and levels
11: * ####################################################################### ################################
12: *
13: * log4j.rootcategory = debug, fileapp, conap
14: * log4j.category.de.jayefem = debug, fileapp, conaf
15: *
16: * ################################################### ################################
17: * # appenders
18: * ###################################################################### ################################
19: *
20: * # Conapp is set to be a consoleapplender.
21: * log4j.appender.Conapp = org.apache.log4j.consoleAppender
22: * log4j.Appender.Conapp.target = system.out
23: * log4j.appender.Conapp.Layout = Org.apache.log4j.patternlayout
24: * log4j.Appender.Conapp.Layout.conversionPattern =% D {Absolute}% 5P% C {1}:% L -% M% N
25: *
26: * # fileapp
27: * log4j.Appender.fileapp = org.apache.log4j.rollingfileAppender
28: * log4j.Appender.fileapp.file =. / Log4e.log
29: * log4j.Appender.fileapp.maxfilesize = 500kb
30: * # Keep One Backup File
31: * log4j.Appender.fileapp.maxbackupindex = 1
32: * log4j.Appender.fileapp.Layout = Org.apache.log4j.patternlayout
33: * log4j.Appender.fileapp.Layout.conversionPattern =% D [% T]% -5p% C -% M% N
34: * /
35:
36:
37: / * Apply this XML file to test
38: *
39: *
40: *
41: *
42: *
43: *
44: * ew>
45: * /
46: Package XML;
47:
48: Import java.io.bufferedreader;
49: Import java.io.bufferedwriter;
50: Import java.io.file;
51: Import java.io.fileReader;
52: Import java.io.filewriter;
53: Import java.io.ioException;
54:
55: Import org.apache.log4j.logger;
56: import org.dom4j.attribute;
57: Import Org.dom4j.documentexception;
58: Import org.dom4j.documenthelper;
59: import org.dom4j.element;
60:
61: / **
62: * @Author Julysea
63: *
64: * An example of XML with DOM4J
65: *
66: * /
67: Public class dom4jtest {
68:
69: Private static final logger logger = logger.getlogger (DOM4JTEST.CLASS);
70:
71: public static void main (string [] args) throws oException,
72: DocumentException {
73: BUFFEREDReader Reader = New FileReader (New FileReader ("EW.XML"));
74: String Tempstr;
75: String EWXML = ""
76: While (Tempstr = Reader.Readline ())! = Null) {
77: EWXML = EWXML TEMPSTR;
78: Logger.debug (Tempstr);
79:}
80: Element root = null;
81:
82: root = DocumentHelper.Parstext (EWXML) .getrooteElement ();
83: attribute rootcmd = root.attribute ("cmd");
84: Attribute Rootversion = root.attribute ("Version");
85: logger.debug ("rootnmae =" root.getname ());
86: Logger.debug ("ew'cmd =" rootcmd.getvalue ());
87: logger.debug ("ew'version =" rootversion.getValue ());
88:
89: Element usrname = root.element ("Username"); 90: logger.debug ("ew.username value =" usrname.getTextTrim ());
91:
92: Element Source = Root.Element ("Source");
93: Attribute SourceUns = Source.attribute ("UNS");
94: logger.debug ("ew.source'uns" sourceuns.getValue ());
95: Attribute SourceType = Source.Attribute ("Type");
96: logger.debug ("ew.source 'Type =" SourceType.getValue ());
97:
98:
99: // Create an XML file
100: Element user = DocumentHelper.createElement ("user");
101: User.Addattribute ("Type", "User");
102: User.addeElement ("name"). Addttribute ("Type", "Pinyin"). SetText ("Julysea");
103: User.addelement ("age"). SetText ("29");
104: String Onexml = User.asxml ();
105:
106: BufferedWriter Out = New Filewriter ("OneXml.xml");
107: Out.write (Onexml);
108: Out.close ();
109:}
110:}