kenai_tools 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,77 @@
1
+ # $Id: Makefile,v 1.3 2001/11/21 00:49:34 dbrownell Exp $
2
+ #
3
+ # This Makefile is in the Public Domain.
4
+ #
5
+
6
+
7
+ DOCTITLE="SAX: Simple API for XML"
8
+
9
+ SOURCES := $(shell find src/org -name '*.java' -print)
10
+ PACKAGE_INFO := $(shell find src/org -name '*.html' -print)
11
+ ALL_SRC := $(PACKAGE_INFO) $(SOURCES)
12
+
13
+ all: sax.jar javadoc
14
+
15
+ sax.jar: $(SOURCES)
16
+ ifneq ($(findstring 1.1, $(JDK)),1.1)
17
+ mkdir -p classes
18
+ javac -d classes $(SOURCES)
19
+ cd classes; jar cf ../sax.jar org
20
+ else
21
+ @echo "SAX needs JDK 1.2 features to compile."
22
+ @echo "However, it works with JDK 1.1 runtime environments."
23
+ @exit 1
24
+ endif
25
+
26
+ #
27
+ # Javadoc
28
+ #
29
+ # -overview doc/overview.html
30
+
31
+ javadoc: $(ALL_SRC) # doc/overview.html
32
+ ifneq ($(findstring 1.1, $(JDK)),1.1)
33
+ mkdir -p apidoc
34
+ javadoc -d apidoc \
35
+ -J-Xmx64M -J-Xms64M \
36
+ -windowtitle $(DOCTITLE) \
37
+ -nodeprecatedlist -use \
38
+ -bottom "<em>SAX is in the PUBLIC DOMAIN.</em> \
39
+ <br>See <a href="http://www.saxproject.org"> \
40
+ http://www.saxproject.org</a> for information and source \
41
+ code. <br>This documentation was derived from that\
42
+ source code on `date "+%e-%b-%Y"`.\
43
+ " \
44
+ -classpath "$(CPATH)$(SEP)src" \
45
+ org.xml.sax org.xml.sax.helpers org.xml.sax.ext
46
+ else
47
+ @echo "Requires JDK 1.2 (or later) javadoc."
48
+ @exit 1
49
+ endif
50
+
51
+ #
52
+ # Release Engineering: "full" release has source, jarfile, javadoc.
53
+ #
54
+
55
+ # override in environment, with "make -e"
56
+ DIST_DIR = sax2dev
57
+
58
+ EXTRA := README Makefile COPYING ChangeLog
59
+
60
+ sax2dist.jar: sax.jar javadoc $(EXTRA) $(ALL_SRC)
61
+ mkdir -p $(DIST_DIR)
62
+ for F in $(EXTRA) $(ALL_SRC) ;\
63
+ do \
64
+ mkdir -p `dirname $(DIST_DIR)/$$F` ;\
65
+ cp $$F $(DIST_DIR)/$$F ;\
66
+ done
67
+ cp -r apidoc sax.jar $(DIST_DIR)
68
+ # jar cMf sax2dist.jar $(DIST_DIR)
69
+ zip -qr9 sax2dist.jar $(DIST_DIR)
70
+ rm -rf $(DIST_DIR)
71
+
72
+ #
73
+ # housekeeping
74
+ #
75
+ clean:
76
+ rm -rf classes *.jar apidoc
77
+ find . '(' -name '*~' -o -name '.#*' ')' -exec rm -f '{}' ';'
@@ -0,0 +1,62 @@
1
+ SAX 2.0.2 (sax2r3)
2
+ 2004-04-27
3
+
4
+ This is another bugfix release for SAX2. It makes minimal changes
5
+ (mostly in features and properties) to make SAX2 compliant with the
6
+ new XML 1.1 and Namespaces 1.1 recommendations, including Unicode
7
+ normalization. The changes are minor and should not affect most
8
+ applications.
9
+
10
+ One significant point is that this release flags a conflict (which
11
+ already existed) between the JavaDoc for fatalError() and the JavaDoc
12
+ for endDocument(). It is not currently clear whether a SAX
13
+ implementation must invoke the endDocument() callback after reporting
14
+ a fatal error, and the documentation simply mentions this fact and
15
+ advises application writers not to rely on either behaviour until the
16
+ ambiguity is resolved in the next major release.
17
+
18
+ See CHANGES and ChangeLog for more details.
19
+
20
+
21
+ - David Megginson (temporarily filling in for David Brownell)
22
+
23
+
24
+ SAX 2.0.1 (sax2r2)
25
+ 29-January-2002
26
+
27
+ NOTE: you're looking at a version which extends SAX 2.0.1 with a test
28
+ version of the "SAX2 Extensions 1.1" interfaces, in the org.xml.sax.ext
29
+ package. It also includes some new feature flags.
30
+
31
+ This is a bugfix release for SAX2, the second generation of the Simple
32
+ API for XML. Changes from the SAX 2.0 release can be summarized as:
33
+ - Numerous documentation improvements and clarifications.
34
+ - Bundling the optional "SAX2 Extensions 1.0" support.
35
+ - Bugfixes:
36
+ * Bugfixed classes include ParserAdapter, AttributesImpl
37
+ * Factory classes use the correct class loader (JDK 1.2 and later)
38
+ * Some exceptions were missing default constructors
39
+ * DefaultHandler was missing an exception spec
40
+ * Resetting handlers to their default values is legal
41
+ - Slightly less memory use in NamespaceSupport, AttributesImpl.
42
+ - Better configurability for the default XMLReader.
43
+ - NamespaceSupport enforces its declare-before-use constraint
44
+
45
+ Other than bugfixes, the APIs have not been changed. This is intended to
46
+ be a drop-in replacement for the previous SAX2 release. API-conformant
47
+ code will not notice any differences.
48
+
49
+ If you are using JDK 1.4, you should be able to copy "sax.jar" into
50
+ the $JAVA_HOME/jre/lib/endorsed directory to have it replace the older
51
+ version of SAX2 that is distributed with that JVM. If you're using
52
+ JRE 1.4, that path won't include the "jre".
53
+
54
+ For more information, see the current home for SAX on the web:
55
+
56
+ http://www.saxproject.org
57
+
58
+ As a SourceForge project, SAX now has public CVS access, a database
59
+ for bugs and RFEs, mailing lists, and a web site.
60
+
61
+ - David Brownell
62
+ dbrownell@users.sourceforge.net
@@ -0,0 +1,68 @@
1
+ <?xml version="1.0"?>
2
+ <project name="sax2" default="jar" basedir=".">
3
+
4
+ <property name="src" value="src"/>
5
+ <property name="classes" value="classes"/>
6
+ <property name="jarfile" value="sax2.jar"/>
7
+ <property name="docs" value="docs"/>
8
+ <property name="javadoc" value="${docs}/javadoc"/>
9
+ <property name="version" value="sax2r3"/>
10
+ <property name="work" value="${version}"/>
11
+ <property name="zipfile" value="${version}.zip"/>
12
+
13
+ <target name="init">
14
+ <tstamp/>
15
+ </target>
16
+
17
+ <target name="prepare" depends="init">
18
+ <mkdir dir="${classes}"/>
19
+ <mkdir dir="${javadoc}"/>
20
+ </target>
21
+
22
+ <target name="compile" depends="prepare">
23
+ <javac srcdir="${src}" destdir="${classes}"/>
24
+ </target>
25
+
26
+ <target name="jar" depends="compile">
27
+ <jar jarfile="${jarfile}" basedir="${classes}"/>
28
+ </target>
29
+
30
+ <target name="javadoc" depends="prepare">
31
+ <javadoc sourcepath="${src}"
32
+ destdir="${javadoc}"
33
+ version="yes">
34
+ <package name="org.xml.sax"/>
35
+ <package name="org.xml.sax.ext"/>
36
+ <package name="org.xml.sax.helpers"/>
37
+ </javadoc>
38
+ </target>
39
+
40
+ <target name="dist" depends="jar,javadoc">
41
+ <delete dir="${work}"/>
42
+ <mkdir dir="${work}"/>
43
+ <copy todir="${work}">
44
+ <fileset dir=".">
45
+ <include name="BUGS"/>
46
+ <include name="build.xml"/>
47
+ <include name="ChangeLog"/>
48
+ <include name="README"/>
49
+ <include name="${jarfile}"/>
50
+ </fileset>
51
+ <fileset dir="${src}" excludes="**/Makefile"/>
52
+ <fileset dir="${classes}"/>
53
+ <fileset dir="${docs}"/>
54
+ <fileset dir="${javadoc}"/>
55
+ </copy>
56
+ <zip zipfile="${zipfile}"
57
+ basedir="."
58
+ includes="${work}/**"/>
59
+ <delete dir="${work}"/>
60
+ </target>
61
+
62
+ <target name="clean" depends="init">
63
+ <delete dir="${classes}"/>
64
+ <delete dir="${javadoc}"/>
65
+ <delete file="${jarfile}"/>
66
+ </target>
67
+
68
+ </project>
@@ -0,0 +1,238 @@
1
+ import org.xml.sax.*;
2
+ import org.xml.sax.ext.*;
3
+ import org.xml.sax.helpers.*;
4
+
5
+
6
+ /**
7
+ * Poke at parsers and find out what features and properties
8
+ * they support, using the SAX2 (+extensions) standard list.
9
+ *
10
+ * @author David Brownell
11
+ * @version $Id: SAXDump.java,v 1.3 2002/07/29 23:07:40 dbrownell Exp $
12
+ */
13
+ public class SAXDump
14
+ {
15
+ private SAXDump () { }
16
+
17
+ /**
18
+ * Pass a list of parser classes; each will be scanned.
19
+ * If not, parsers from a built-in list are scanned.
20
+ */
21
+ public static void main (String argv [])
22
+ {
23
+ if (argv.length == 0)
24
+ argv = new String [] {
25
+ "com.jclark.xml.sax.SAX2Driver",
26
+ "gnu.xml.aelfred2.SAXDriver",
27
+ "gnu.xml.aelfred2.XmlReader",
28
+ "gnu.xml.util.DomParser",
29
+ "oracle.xml.parser.v2.SAXParser",
30
+ "org.apache.crimson.parser.XMLReaderImpl",
31
+ "org.apache.xerces.parsers.SAXParser",
32
+ };
33
+
34
+ for (int i = 0; i < argv.length; i++)
35
+ checkParser (argv [i]);
36
+ }
37
+
38
+ private static final String FEATURE_URI
39
+ = "http://xml.org/sax/features/";
40
+
41
+ private static final String PROPERTY_URI
42
+ = "http://xml.org/sax/properties/";
43
+
44
+ //////////////////////////////////////////////////////////////////
45
+
46
+ private static void
47
+ checkFeature (String id, XMLReader producer)
48
+ {
49
+ int state = 0;
50
+
51
+ try {
52
+ boolean value;
53
+
54
+ // align to longest id...
55
+ final int align = 35;
56
+
57
+ for (int i = align - id.length (); i > 0; i--)
58
+ System.out.print (' ');
59
+ System.out.print (id);
60
+ System.out.print (": ");
61
+
62
+ id = FEATURE_URI + id;
63
+
64
+ value = producer.getFeature (id);
65
+ System.out.print (value);
66
+ System.out.print (", ");
67
+ state = 1;
68
+
69
+ producer.setFeature (id, value);
70
+ state = 2;
71
+
72
+ producer.setFeature (id, !value);
73
+ System.out.println ("read and write");
74
+
75
+ // changes value and leaves it
76
+
77
+ } catch (SAXNotSupportedException e) {
78
+ switch (state) {
79
+ case 0: System.out.println ("(can't read now)"); break;
80
+ /* bogus_1 means can't reassign the default;
81
+ * probably intended to be read/write
82
+ */
83
+ case 1: System.out.println ("bogus_1"); break;
84
+ case 2: System.out.println ("readonly"); break;
85
+ }
86
+
87
+ } catch (SAXNotRecognizedException e) {
88
+ if (state == 0)
89
+ System.out.println ("(unrecognized)");
90
+ else
91
+ /* bogus_2 means the wrong exception was thrown */
92
+ System.out.println ("bogus_2");
93
+ }
94
+ }
95
+
96
+ private static void
97
+ showFeatures (XMLReader producer)
98
+ {
99
+ System.out.println ("FEATURES for "
100
+ + producer.getClass ().getName ());
101
+
102
+ // must-have, default=false
103
+ checkFeature ("namespace-prefixes", producer);
104
+ // must-have, default=true
105
+ checkFeature ("namespaces", producer);
106
+
107
+ // lots of optional features
108
+ checkFeature ("external-general-entities", producer);
109
+ checkFeature ("external-parameter-entities", producer);
110
+ checkFeature ("is-standalone", producer);
111
+ checkFeature ("lexical-handler/parameter-entities", producer);
112
+ checkFeature ("resolve-dtd-uris", producer);
113
+ checkFeature ("string-interning", producer);
114
+ checkFeature ("use-attributes2", producer);
115
+ checkFeature ("use-locator2", producer);
116
+ checkFeature ("validation", producer);
117
+ }
118
+
119
+ //////////////////////////////////////////////////////////////////
120
+
121
+ private static void
122
+ checkProperty (String id, XMLReader producer, Object newValue)
123
+ {
124
+ int state = 0;
125
+
126
+ try {
127
+ Object value;
128
+
129
+ // align to longest id...
130
+ final int align = 20;
131
+
132
+ for (int i = align - id.length (); i > 0; i--)
133
+ System.out.print (' ');
134
+ System.out.print (id);
135
+ System.out.print (": ");
136
+
137
+ id = PROPERTY_URI + id;
138
+
139
+ value = producer.getProperty (id);
140
+ System.out.print (value);
141
+ System.out.print (", ");
142
+ state = 1;
143
+
144
+ producer.setProperty (id, value);
145
+ state = 2;
146
+
147
+ producer.setProperty (id, newValue);
148
+ System.out.println ("read and write");
149
+
150
+ // changes value and leaves it
151
+
152
+ } catch (SAXNotSupportedException e) {
153
+ switch (state) {
154
+ case 0: System.out.println ("(can't read now)"); break;
155
+ /* bogus_1 means can't reassign the default;
156
+ * probably intended to be read/write
157
+ */
158
+ case 1: System.out.println ("bogus_1"); break;
159
+ case 2: System.out.println ("readonly"); break;
160
+ }
161
+
162
+ } catch (SAXNotRecognizedException e) {
163
+ if (state == 0)
164
+ System.out.println ("(unrecognized)");
165
+ else
166
+ /* bogus_2 means the wrong exception was thrown */
167
+ System.out.println ("bogus_2");
168
+ }
169
+ }
170
+
171
+ private static void
172
+ showProperties (XMLReader producer)
173
+ {
174
+ System.out.println ("PROPERTIES for "
175
+ + producer.getClass ().getName ());
176
+
177
+ DefaultHandler2 handler = new DefaultHandler2 ();
178
+
179
+ // all properties are optional
180
+ checkProperty ("declaration-handler", producer, handler);
181
+
182
+ // To check the dom-node property, we need an instance
183
+ // of an org.w3c.dom.Node. Any one will do; but since
184
+ // we don't know what is installed, we try four likely
185
+ // suspects.
186
+
187
+ String[] domClassNames = {
188
+ "org.apache.crimson.tree.XmlDocument",
189
+ "org.apache.xerces.dom.DocumentImpl",
190
+ "gnu.xml.dom.DomDocument",
191
+ "oracle.xml.parser.v2.XMLDocument",
192
+ };
193
+ org.w3c.dom.Node node = null;
194
+ for (int i = 0; i < domClassNames.length; i++) {
195
+ try {
196
+ Class domClass = Class.forName(domClassNames[i]);
197
+ node = (org.w3c.dom.Node) domClass.newInstance();
198
+ }
199
+ catch (ClassNotFoundException e) { continue; }
200
+ catch (InstantiationException e) { continue; }
201
+ catch (IllegalAccessException e) { continue; }
202
+ catch (ClassCastException e) { continue; }
203
+ }
204
+
205
+ // If none of the classes yielded a workable instance,
206
+ // just skip the test.
207
+ if (node != null) {
208
+ checkProperty ("dom-node", producer, node);
209
+ }
210
+
211
+ checkProperty ("lexical-handler", producer, handler);
212
+ checkProperty ("xml-string", producer, "<root/>");
213
+ }
214
+
215
+ //////////////////////////////////////////////////////////////////
216
+
217
+ private static void
218
+ checkParser (String classname)
219
+ {
220
+ XMLReader producer = null;
221
+
222
+ try {
223
+ producer = XMLReaderFactory.createXMLReader (classname);
224
+
225
+ showFeatures (producer);
226
+ System.out.println ("");
227
+ showProperties (producer);
228
+
229
+ } catch (Exception e) {
230
+ if (producer == null)
231
+ System.err.println ("(can't create " + classname + ")");
232
+ else
233
+ e.printStackTrace ();
234
+ } finally {
235
+ System.out.println ("");
236
+ }
237
+ }
238
+ }