Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
131 lines (111 loc) · 4.01 KB

File metadata and controls

131 lines (111 loc) · 4.01 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package PamController;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.StringWriter;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
//import com.sun.org.apache.xerces.internal.dom.DocumentImpl;
//import com.sun.org.apache.xerces.internal.parsers.SAXParser;
//import com.sun.org.apache.xml.internal.serialize.OutputFormat;
//import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
import PamUtils.XMLUtils;
public class XMLTest {
/**
* @param args
*/
public static void main(String[] args) {
XMLTest t = new XMLTest();
t.xmlTest();
}
void xmlTest() {
// XMLReader parser = new SAXParser();
// System.out.println(parser.toString());
// new xmldocument
Element el;
Document doc = XMLUtils.createBlankDoc();
Element root = doc.createElement("Modules");
Element module = doc.createElement("Module");
module.setAttribute("Name", "Click Detector");
module.setAttribute("JavaClass", "something.else.clickControl");
module.appendChild(el = doc.createElement("Trigger"));
el.setAttribute("Threshold", ((Double) Math.PI).toString());
el.setAttribute("SHORTFILTER", ((Double) .1).toString());
el.setAttribute("LONGFILTER", ((Double) .000001).toString());
el.setAttribute("LONGFILTER2", ((Double) .000001).toString());
module.appendChild(el = doc.createElement("PreFilter"));
el.setAttribute("Type", "Butterworth");
el.setAttribute("Band", "BANDPASS");
el.setAttribute("LOFREQ", ((Double) 1.245).toString());
el.setAttribute("HIFREQ", ((Double) 1.245).toString());
el.setAttribute("ORDER", ((Integer) 3).toString());
el.setAttribute("RIPPLE", ((Double) 3.).toString());
// Object tstc = new TestClass();
// XMLEncoder en = new xm
// Node n = new
root.appendChild(module);
doc.appendChild(root);
// FileOutputStream fos = null;
// try {
// fos = new FileOutputStream("test.xml");
// } catch (FileNotFoundException e1) {
// // TODO Auto-generated catch block
// e1.printStackTrace();
// }
//
//
// XERCES 1 or 2 additionnal classes.
// OutputFormat of = new OutputFormat("XML","ISO-8859-1",true);
// of.setIndent(1);
// of.setLineSeparator("\r\n");
// of.setIndenting(true);
// of.setDoctype(null,"pamguard.dtd");
// XMLSerializer serializer = new XMLSerializer(fos,of);
// // As a DOM Serializer
// try {
// serializer.asDOMSerializer();
// serializer.serialize( doc.getDocumentElement() );
// fos.close();
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
try {
DOMSource domSource = new DOMSource(doc);
StringWriter writer = new StringWriter();
StreamResult result = new StreamResult(writer);
TransformerFactory tf = TransformerFactory.newInstance();
Transformer transformer = tf.newTransformer();
transformer.setOutputProperty(OutputKeys.METHOD, "xml");
transformer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1");
// transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
// transformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, null);
transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, "pamguard.dtd");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
transformer.transform(domSource, result);
String asString = writer.toString();
if (asString!=null) {
BufferedWriter out = new BufferedWriter(new FileWriter("testXML-new.xml", false));
out.write(asString);
out.close();
}
} catch (TransformerException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
class TestClass {
double a = 1.0;
int b = 2;
String c = "catfish";
double[] smallArray = {2., 5., 6., 8.};
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.