You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by sa...@apache.org on 2001/11/13 21:34:15 UTC
cvs commit: xml-xerces/java/samples/xni Counter.java DocumentTracer.java Writer.java
sandygao 01/11/13 12:34:15
Modified: java/samples/dom Counter.java GetElementsByTagName.java
Writer.java
java/samples/sax Counter.java DocumentTracer.java
Writer.java
java/samples/socket DelayedInput.java
java/samples/xni Counter.java DocumentTracer.java
Writer.java
Log:
A new feature is added "validation/schema-full-checking" (as in Xerces-J),
which controls whether the 3 special constraints are checked against schema:
Unique Particle Attribution, Particle Derivation, Element Consistent.
Revision Changes Path
1.3 +35 -14 xml-xerces/java/samples/dom/Counter.java
Index: Counter.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/samples/dom/Counter.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Counter.java 2001/08/23 00:35:17 1.2
+++ Counter.java 2001/11/13 20:34:14 1.3
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -10,7 +10,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -18,7 +18,7 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
+ * if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
@@ -26,7 +26,7 @@
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
- * software without prior written permission. For written
+ * software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
@@ -80,14 +80,14 @@
* it is important to note that the first parse time of a parser
* will include both VM class load time and parser initialization
* that would not be present in subsequent parses with the same
- * file.
+ * file.
* <p>
* <strong>Note:</strong> The results produced by this program
* should never be accepted as true performance measurements.
*
* @author Andy Clark, IBM
*
- * @version $Id: Counter.java,v 1.2 2001/08/23 00:35:17 lehors Exp $
+ * @version $Id: Counter.java,v 1.3 2001/11/13 20:34:14 sandygao Exp $
*/
public class Counter {
@@ -99,13 +99,16 @@
/** Namespaces feature id (http://xml.org/sax/features/namespaces). */
protected static final String NAMESPACES_FEATURE_ID = "http://xml.org/sax/features/namespaces";
-
+
/** Validation feature id (http://xml.org/sax/features/validation). */
protected static final String VALIDATION_FEATURE_ID = "http://xml.org/sax/features/validation";
/** Schema validation feature id (http://apache.org/xml/features/validation/schema). */
protected static final String SCHEMA_VALIDATION_FEATURE_ID = "http://apache.org/xml/features/validation/schema";
+ /** Schema full checking feature id (http://apache.org/xml/features/validation/schema-full-checking). */
+ protected static final String SCHEMA_FULL_CHECKING_FEATURE_ID = "http://apache.org/xml/features/validation/schema-full-checking";
+
// default settings
/** Default parser name (dom.wrappers.Xerces). */
@@ -122,10 +125,13 @@
/** Default validation support (false). */
protected static final boolean DEFAULT_VALIDATION = false;
-
+
/** Default Schema validation support (true). */
protected static final boolean DEFAULT_SCHEMA_VALIDATION = true;
+ /** Default Schema full checking support (false). */
+ protected static final boolean DEFAULT_SCHEMA_FULL_CHECKING = false;
+
//
// Data
//
@@ -215,7 +221,7 @@
} // count(Node)
/** Prints the results. */
- public void printResults(PrintWriter out, String uri,
+ public void printResults(PrintWriter out, String uri,
long parse, long traverse1, long traverse2,
int repetition) {
@@ -256,7 +262,7 @@
/** Main program entry point. */
public static void main(String argv[]) {
-
+
// is there anything to do?
if (argv.length == 0) {
printUsage();
@@ -271,7 +277,8 @@
boolean namespaces = DEFAULT_NAMESPACES;
boolean validation = DEFAULT_VALIDATION;
boolean schemaValidation = DEFAULT_SCHEMA_VALIDATION;
-
+ boolean schemaFullChecking = DEFAULT_SCHEMA_FULL_CHECKING;
+
// process arguments
for (int i = 0; i < argv.length; i++) {
String arg = argv[i];
@@ -325,6 +332,10 @@
schemaValidation = option.equals("s");
continue;
}
+ if (option.equalsIgnoreCase("f")) {
+ schemaFullChecking = option.equals("f");
+ continue;
+ }
if (option.equals("h")) {
printUsage();
continue;
@@ -343,7 +354,7 @@
continue;
}
}
-
+
// set parser features
try {
parser.setFeature(NAMESPACES_FEATURE_ID, namespaces);
@@ -363,6 +374,12 @@
catch (SAXException e) {
System.err.println("warning: Parser does not support feature ("+SCHEMA_VALIDATION_FEATURE_ID+")");
}
+ try {
+ parser.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, schemaFullChecking);
+ }
+ catch (SAXException e) {
+ System.err.println("warning: Parser does not support feature ("+SCHEMA_FULL_CHECKING_FEATURE_ID+")");
+ }
// parse file
try {
@@ -401,7 +418,7 @@
if (se != null)
se.printStackTrace(System.err);
else
- e.printStackTrace(System.err);
+ e.printStackTrace(System.err);
}
}
@@ -416,7 +433,7 @@
System.err.println("usage: java dom.Counter (options) uri ...");
System.err.println();
-
+
System.err.println("options:");
System.err.println(" -p name Select parser by name.");
System.err.println(" -x number Select number of repetitions.");
@@ -426,6 +443,8 @@
System.err.println(" -v | -V Turn on/off validation.");
System.err.println(" -s | -S Turn on/off Schema validation support.");
System.err.println(" NOTE: Not supported by all parsers.");
+ System.err.println(" -f | -F Turn on/off Schema full checking.");
+ System.err.println(" NOTE: Requires use of -s and not supported by all parsers.");
System.err.println(" -h This help screen.");
System.err.println();
@@ -440,6 +459,8 @@
System.err.println(DEFAULT_VALIDATION ? "on" : "off");
System.err.print(" Schema: ");
System.err.println(DEFAULT_SCHEMA_VALIDATION ? "on" : "off");
+ System.err.print(" Schema full checking: ");
+ System.err.println(DEFAULT_SCHEMA_FULL_CHECKING ? "on" : "off");
} // printUsage()
1.3 +37 -16 xml-xerces/java/samples/dom/GetElementsByTagName.java
Index: GetElementsByTagName.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/samples/dom/GetElementsByTagName.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- GetElementsByTagName.java 2001/08/23 00:35:17 1.2
+++ GetElementsByTagName.java 2001/11/13 20:34:14 1.3
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights
+ * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -10,7 +10,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -18,7 +18,7 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
+ * if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
@@ -26,7 +26,7 @@
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
- * software without prior written permission. For written
+ * software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
@@ -55,8 +55,8 @@
* <http://www.apache.org/>.
*/
-package dom;
-
+package dom;
+
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
@@ -75,13 +75,13 @@
/**
* A sample DOM filter. This sample program illustrates how to
- * use the Document#getElementsByTagName() method to quickly
+ * use the Document#getElementsByTagName() method to quickly
* and easily locate elements by name.
*
* @author Jeffrey Rodriguez, IBM
* @author Andy Clark, IBM
*
- * @version $Id: GetElementsByTagName.java,v 1.2 2001/08/23 00:35:17 lehors Exp $
+ * @version $Id: GetElementsByTagName.java,v 1.3 2001/11/13 20:34:14 sandygao Exp $
*/
public class GetElementsByTagName {
@@ -93,13 +93,16 @@
/** Namespaces feature id (http://xml.org/sax/features/namespaces). */
protected static final String NAMESPACES_FEATURE_ID = "http://xml.org/sax/features/namespaces";
-
+
/** Validation feature id (http://xml.org/sax/features/validation). */
protected static final String VALIDATION_FEATURE_ID = "http://xml.org/sax/features/validation";
/** Schema validation feature id (http://apache.org/xml/features/validation/schema). */
protected static final String SCHEMA_VALIDATION_FEATURE_ID = "http://apache.org/xml/features/validation/schema";
+ /** Schema full checking feature id (http://apache.org/xml/features/validation/schema-full-checking). */
+ protected static final String SCHEMA_FULL_CHECKING_FEATURE_ID = "http://apache.org/xml/features/validation/schema-full-checking";
+
// default settings
/** Default parser name (dom.wrappers.Xerces). */
@@ -113,16 +116,19 @@
/** Default validation support (false). */
protected static final boolean DEFAULT_VALIDATION = false;
-
+
/** Default Schema validation support (true). */
protected static final boolean DEFAULT_SCHEMA_VALIDATION = true;
+ /** Default Schema full checking support (false). */
+ protected static final boolean DEFAULT_SCHEMA_FULL_CHECKING = false;
+
//
// Public static methods
//
/** Prints the specified elements in the given document. */
- public static void print(PrintWriter out, Document document,
+ public static void print(PrintWriter out, Document document,
String elementName, String attributeName) {
// get elements that match
@@ -161,7 +167,7 @@
//
/** Prints the specified element. */
- protected static void print(PrintWriter out,
+ protected static void print(PrintWriter out,
Element element, NamedNodeMap attributes) {
out.print('<');
@@ -229,7 +235,7 @@
/** Main program entry point. */
public static void main(String argv[]) {
-
+
// is there anything to do?
if (argv.length == 0) {
printUsage();
@@ -245,7 +251,8 @@
boolean namespaces = DEFAULT_NAMESPACES;
boolean validation = DEFAULT_VALIDATION;
boolean schemaValidation = DEFAULT_SCHEMA_VALIDATION;
-
+ boolean schemaFullChecking = DEFAULT_SCHEMA_FULL_CHECKING;
+
// process arguments
for (int i = 0; i < argv.length; i++) {
String arg = argv[i];
@@ -294,6 +301,10 @@
schemaValidation = option.equals("s");
continue;
}
+ if (option.equalsIgnoreCase("f")) {
+ schemaFullChecking = option.equals("f");
+ continue;
+ }
if (option.equals("h")) {
printUsage();
continue;
@@ -312,7 +323,7 @@
continue;
}
}
-
+
// set parser features
try {
parser.setFeature(NAMESPACES_FEATURE_ID, namespaces);
@@ -332,6 +343,12 @@
catch (SAXException e) {
System.err.println("warning: Parser does not support feature ("+SCHEMA_VALIDATION_FEATURE_ID+")");
}
+ try {
+ parser.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, schemaFullChecking);
+ }
+ catch (SAXException e) {
+ System.err.println("warning: Parser does not support feature ("+SCHEMA_FULL_CHECKING_FEATURE_ID+")");
+ }
// parse file
try {
@@ -361,7 +378,7 @@
System.err.println("usage: java dom.GetElementsByTagName (options) uri ...");
System.err.println();
-
+
System.err.println("options:");
System.err.println(" -p name Select parser by name.");
System.err.println(" -e name Specify element name for search.");
@@ -370,6 +387,8 @@
System.err.println(" -v | -V Turn on/off validation.");
System.err.println(" -s | -S Turn on/off Schema validation support.");
System.err.println(" NOTE: Not supported by all parsers.");
+ System.err.println(" -f | -F Turn on/off Schema full checking.");
+ System.err.println(" NOTE: Requires use of -s and not supported by all parsers.");
System.err.println(" -h This help screen.");
System.err.println();
@@ -382,6 +401,8 @@
System.err.println(DEFAULT_VALIDATION ? "on" : "off");
System.out.print(" Schema: ");
System.err.println(DEFAULT_SCHEMA_VALIDATION ? "on" : "off");
+ System.err.print(" Schema full checking: ");
+ System.err.println(DEFAULT_SCHEMA_FULL_CHECKING ? "on" : "off");
} // printUsage()
1.3 +36 -15 xml-xerces/java/samples/dom/Writer.java
Index: Writer.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/samples/dom/Writer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Writer.java 2001/08/23 00:35:17 1.2
+++ Writer.java 2001/11/13 20:34:14 1.3
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights
+ * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -10,7 +10,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -18,7 +18,7 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
+ * if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
@@ -26,7 +26,7 @@
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
- * software without prior written permission. For written
+ * software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
@@ -77,7 +77,7 @@
*
* @author Andy Clark, IBM
*
- * @version $Id: Writer.java,v 1.2 2001/08/23 00:35:17 lehors Exp $
+ * @version $Id: Writer.java,v 1.3 2001/11/13 20:34:14 sandygao Exp $
*/
public class Writer {
@@ -89,13 +89,16 @@
/** Namespaces feature id (http://xml.org/sax/features/namespaces). */
protected static final String NAMESPACES_FEATURE_ID = "http://xml.org/sax/features/namespaces";
-
+
/** Validation feature id (http://xml.org/sax/features/validation). */
protected static final String VALIDATION_FEATURE_ID = "http://xml.org/sax/features/validation";
/** Schema validation feature id (http://apache.org/xml/features/validation/schema). */
protected static final String SCHEMA_VALIDATION_FEATURE_ID = "http://apache.org/xml/features/validation/schema";
+ /** Schema full checking feature id (http://apache.org/xml/features/validation/schema-full-checking). */
+ protected static final String SCHEMA_FULL_CHECKING_FEATURE_ID = "http://apache.org/xml/features/validation/schema-full-checking";
+
// property ids
/** Lexical handler property id (http://xml.org/sax/properties/lexical-handler). */
@@ -111,10 +114,13 @@
/** Default validation support (false). */
protected static final boolean DEFAULT_VALIDATION = false;
-
+
/** Default Schema validation support (true). */
protected static final boolean DEFAULT_SCHEMA_VALIDATION = true;
+ /** Default Schema full checking support (false). */
+ protected static final boolean DEFAULT_SCHEMA_FULL_CHECKING = false;
+
/** Default canonical output (false). */
protected static final boolean DEFAULT_CANONICAL = false;
@@ -164,7 +170,7 @@
/** Sets the output writer. */
public void setOutput(java.io.Writer writer) {
-
+
fOut = writer instanceof PrintWriter
? (PrintWriter)writer : new PrintWriter(writer);
@@ -185,7 +191,7 @@
fOut.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
fOut.flush();
}
-
+
Document document = (Document)node;
write(document.getDocumentElement());
break;
@@ -221,7 +227,7 @@
write(child);
child = child.getNextSibling();
}
- }
+ }
else {
fOut.print('&');
fOut.print(node.getNodeName());
@@ -234,7 +240,7 @@
case Node.CDATA_SECTION_NODE: {
if (fCanonical) {
normalizeAndPrint(node.getNodeValue());
- }
+ }
else {
fOut.print("<![CDATA[");
fOut.print(node.getNodeValue());
@@ -360,7 +366,7 @@
/** Main program entry point. */
public static void main(String argv[]) {
-
+
// is there anything to do?
if (argv.length == 0) {
printUsage();
@@ -373,8 +379,9 @@
boolean namespaces = DEFAULT_NAMESPACES;
boolean validation = DEFAULT_VALIDATION;
boolean schemaValidation = DEFAULT_SCHEMA_VALIDATION;
+ boolean schemaFullChecking = DEFAULT_SCHEMA_FULL_CHECKING;
boolean canonical = DEFAULT_CANONICAL;
-
+
// process arguments
for (int i = 0; i < argv.length; i++) {
String arg = argv[i];
@@ -409,6 +416,10 @@
schemaValidation = option.equals("s");
continue;
}
+ if (option.equalsIgnoreCase("f")) {
+ schemaFullChecking = option.equals("f");
+ continue;
+ }
if (option.equalsIgnoreCase("c")) {
canonical = option.equals("c");
continue;
@@ -431,7 +442,7 @@
continue;
}
}
-
+
// set parser features
try {
parser.setFeature(NAMESPACES_FEATURE_ID, namespaces);
@@ -451,6 +462,12 @@
catch (SAXException e) {
System.err.println("warning: Parser does not support feature ("+SCHEMA_VALIDATION_FEATURE_ID+")");
}
+ try {
+ parser.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, schemaFullChecking);
+ }
+ catch (SAXException e) {
+ System.err.println("warning: Parser does not support feature ("+SCHEMA_FULL_CHECKING_FEATURE_ID+")");
+ }
// setup writer
if (writer == null) {
@@ -493,13 +510,15 @@
System.err.println("usage: java dom.Writer (options) uri ...");
System.err.println();
-
+
System.err.println("options:");
System.err.println(" -p name Select parser by name.");
System.err.println(" -n | -N Turn on/off namespace processing.");
System.err.println(" -v | -V Turn on/off validation.");
System.err.println(" -s | -S Turn on/off Schema validation support.");
System.err.println(" NOTE: Not supported by all parsers.");
+ System.err.println(" -f | -F Turn on/off Schema full checking.");
+ System.err.println(" NOTE: Requires use of -s and not supported by all parsers.");
System.err.println(" -c | -C Turn on/off Canonical XML output.");
System.err.println(" NOTE: This is not W3C canonical output.");
System.err.println(" -h This help screen.");
@@ -513,6 +532,8 @@
System.err.println(DEFAULT_VALIDATION ? "on" : "off");
System.err.print(" Schema: ");
System.err.println(DEFAULT_SCHEMA_VALIDATION ? "on" : "off");
+ System.err.print(" Schema full checking: ");
+ System.err.println(DEFAULT_SCHEMA_FULL_CHECKING ? "on" : "off");
System.err.print(" Canonical: ");
System.err.println(DEFAULT_CANONICAL ? "on" : "off");
1.4 +46 -22 xml-xerces/java/samples/sax/Counter.java
Index: Counter.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/samples/sax/Counter.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Counter.java 2001/08/23 06:15:43 1.3
+++ Counter.java 2001/11/13 20:34:14 1.4
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -10,7 +10,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -18,7 +18,7 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
+ * if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
@@ -26,7 +26,7 @@
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
- * software without prior written permission. For written
+ * software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
@@ -55,7 +55,7 @@
* <http://www.apache.org/>.
*/
-package sax;
+package sax;
import java.io.PrintWriter;
@@ -75,22 +75,22 @@
* A sample SAX2 counter. This sample program illustrates how to
* register a SAX2 ContentHandler and receive the callbacks in
* order to print information about the document. The output of
- * this program shows the time and count of elements, attributes,
- * ignorable whitespaces, and characters appearing in the document.
+ * this program shows the time and count of elements, attributes,
+ * ignorable whitespaces, and characters appearing in the document.
* <p>
* This class is useful as a "poor-man's" performance tester to
* compare the speed and accuracy of various SAX parsers. However,
* it is important to note that the first parse time of a parser
* will include both VM class load time and parser initialization
* that would not be present in subsequent parses with the same
- * file.
+ * file.
* <p>
* <strong>Note:</strong> The results produced by this program
* should never be accepted as true performance measurements.
*
* @author Andy Clark, IBM
*
- * @version $Id: Counter.java,v 1.3 2001/08/23 06:15:43 andyc Exp $
+ * @version $Id: Counter.java,v 1.4 2001/11/13 20:34:14 sandygao Exp $
*/
public class Counter
extends DefaultHandler {
@@ -103,7 +103,7 @@
/** Namespaces feature id (http://xml.org/sax/features/namespaces). */
protected static final String NAMESPACES_FEATURE_ID = "http://xml.org/sax/features/namespaces";
-
+
/** Namespace prefixes feature id (http://xml.org/sax/features/namespace-prefixes). */
protected static final String NAMESPACE_PREFIXES_FEATURE_ID = "http://xml.org/sax/features/namespace-prefixes";
@@ -113,6 +113,9 @@
/** Schema validation feature id (http://apache.org/xml/features/validation/schema). */
protected static final String SCHEMA_VALIDATION_FEATURE_ID = "http://apache.org/xml/features/validation/schema";
+ /** Schema full checking feature id (http://apache.org/xml/features/validation/schema-full-checking). */
+ protected static final String SCHEMA_FULL_CHECKING_FEATURE_ID = "http://apache.org/xml/features/validation/schema-full-checking";
+
/** Dynamic validation feature id (http://apache.org/xml/features/validation/dynamic). */
protected static final String DYNAMIC_VALIDATION_FEATURE_ID = "http://apache.org/xml/features/validation/dynamic";
@@ -132,10 +135,13 @@
/** Default validation support (false). */
protected static final boolean DEFAULT_VALIDATION = false;
-
+
/** Default Schema validation support (true). */
protected static final boolean DEFAULT_SCHEMA_VALIDATION = true;
+ /** Default Schema full checking support (false). */
+ protected static final boolean DEFAULT_SCHEMA_FULL_CHECKING = false;
+
/** Default dynamic validation support (false). */
protected static final boolean DEFAULT_DYNAMIC_VALIDATION = false;
@@ -180,7 +186,7 @@
//
/** Prints the results. */
- public void printResults(PrintWriter out, String uri, long time,
+ public void printResults(PrintWriter out, String uri, long time,
long memory, boolean tagginess,
int repetition) {
@@ -241,7 +247,7 @@
} // startDocument()
/** Start element. */
- public void startElement(String uri, String local, String raw,
+ public void startElement(String uri, String local, String raw,
Attributes attrs) throws SAXException {
fElements++;
@@ -264,7 +270,7 @@
} // startElement(String,String,StringAttributes)
/** Characters. */
- public void characters(char ch[], int start, int length)
+ public void characters(char ch[], int start, int length)
throws SAXException {
fCharacters += length;
@@ -272,7 +278,7 @@
} // characters(char[],int,int);
/** Ignorable whitespace. */
- public void ignorableWhitespace(char ch[], int start, int length)
+ public void ignorableWhitespace(char ch[], int start, int length)
throws SAXException {
fIgnorableWhitespace += length;
@@ -348,7 +354,7 @@
/** Main program entry point. */
public static void main(String argv[]) {
-
+
// is there anything to do?
if (argv.length == 0) {
printUsage();
@@ -364,10 +370,11 @@
boolean namespacePrefixes = DEFAULT_NAMESPACE_PREFIXES;
boolean validation = DEFAULT_VALIDATION;
boolean schemaValidation = DEFAULT_SCHEMA_VALIDATION;
+ boolean schemaFullChecking = DEFAULT_SCHEMA_FULL_CHECKING;
boolean dynamicValidation = DEFAULT_DYNAMIC_VALIDATION;
boolean memoryUsage = DEFAULT_MEMORY_USAGE;
boolean tagginess = DEFAULT_TAGGINESS;
-
+
// process arguments
for (int i = 0; i < argv.length; i++) {
String arg = argv[i];
@@ -433,6 +440,10 @@
schemaValidation = option.equals("s");
continue;
}
+ if (option.equalsIgnoreCase("f")) {
+ schemaFullChecking = option.equals("f");
+ continue;
+ }
if (option.equalsIgnoreCase("dv")) {
dynamicValidation = option.equals("dv");
continue;
@@ -474,7 +485,7 @@
continue;
}
}
-
+
// set parser features
try {
parser.setFeature(NAMESPACES_FEATURE_ID, namespaces);
@@ -504,6 +515,15 @@
System.err.println("warning: Parser does not support feature ("+SCHEMA_VALIDATION_FEATURE_ID+")");
}
try {
+ parser.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, schemaFullChecking);
+ }
+ catch (SAXNotRecognizedException e) {
+ // ignore
+ }
+ catch (SAXNotSupportedException e) {
+ System.err.println("warning: Parser does not support feature ("+SCHEMA_FULL_CHECKING_FEATURE_ID+")");
+ }
+ try {
parser.setFeature(DYNAMIC_VALIDATION_FEATURE_ID, dynamicValidation);
}
catch (SAXNotRecognizedException e) {
@@ -524,9 +544,9 @@
}
long memoryAfter = Runtime.getRuntime().freeMemory();
long timeAfter = System.currentTimeMillis();
-
+
long time = timeAfter - timeBefore;
- long memory = memoryUsage
+ long memory = memoryUsage
? memoryBefore - memoryAfter : Long.MIN_VALUE;
counter.printResults(out, arg, time, memory, tagginess,
repetition);
@@ -544,7 +564,7 @@
se.printStackTrace(System.err);
else
e.printStackTrace(System.err);
-
+
}
}
@@ -559,7 +579,7 @@
System.err.println("usage: java sax.Counter (options) uri ...");
System.err.println();
-
+
System.err.println("options:");
System.err.println(" -p name Select parser by name.");
System.err.println(" -x number Select number of repetitions.");
@@ -569,6 +589,8 @@
System.err.println(" -v | -V Turn on/off validation.");
System.err.println(" -s | -S Turn on/off Schema validation support.");
System.err.println(" NOTE: Not supported by all parsers.");
+ System.err.println(" -f | -F Turn on/off Schema full checking.");
+ System.err.println(" NOTE: Requires use of -s and not supported by all parsers.");
System.err.println(" -dv | -DV Turn on/off dynamic validation.");
System.err.println(" NOTE: Requires use of -v and not supported by all parsers.");
System.err.println(" -m | -M Turn on/off memory usage report");
@@ -588,6 +610,8 @@
System.err.println(DEFAULT_VALIDATION ? "on" : "off");
System.err.print(" Schema: ");
System.err.println(DEFAULT_SCHEMA_VALIDATION ? "on" : "off");
+ System.err.print(" Schema full checking: ");
+ System.err.println(DEFAULT_SCHEMA_FULL_CHECKING ? "on" : "off");
System.err.print(" Dynamic: ");
System.err.println(DEFAULT_DYNAMIC_VALIDATION ? "on" : "off");
System.err.print(" Memory: ");
1.5 +53 -29 xml-xerces/java/samples/sax/DocumentTracer.java
Index: DocumentTracer.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/samples/sax/DocumentTracer.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DocumentTracer.java 2001/08/23 00:35:17 1.4
+++ DocumentTracer.java 2001/11/13 20:34:14 1.5
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -10,7 +10,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -18,7 +18,7 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
+ * if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
@@ -26,7 +26,7 @@
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
- * software without prior written permission. For written
+ * software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
@@ -91,9 +91,9 @@
* @author Andy Clark, IBM
* @author Arnaud Le Hors, IBM
*
- * @version $Id: DocumentTracer.java,v 1.4 2001/08/23 00:35:17 lehors Exp $
+ * @version $Id: DocumentTracer.java,v 1.5 2001/11/13 20:34:14 sandygao Exp $
*/
-public class DocumentTracer
+public class DocumentTracer
extends DefaultHandler
implements ContentHandler, DTDHandler, ErrorHandler, // SAX2
DeclHandler, LexicalHandler, // SAX2 extensions
@@ -108,13 +108,16 @@
/** Namespaces feature id (http://xml.org/sax/features/namespaces). */
protected static final String NAMESPACES_FEATURE_ID = "http://xml.org/sax/features/namespaces";
-
+
/** Validation feature id (http://xml.org/sax/features/validation). */
protected static final String VALIDATION_FEATURE_ID = "http://xml.org/sax/features/validation";
/** Schema validation feature id (http://apache.org/xml/features/validation/schema). */
protected static final String SCHEMA_VALIDATION_FEATURE_ID = "http://apache.org/xml/features/validation/schema";
+ /** Schema full checking feature id (http://apache.org/xml/features/validation/schema-full-checking). */
+ protected static final String SCHEMA_FULL_CHECKING_FEATURE_ID = "http://apache.org/xml/features/validation/schema-full-checking";
+
// property ids
/** Lexical handler property id (http://xml.org/sax/properties/lexical-handler). */
@@ -130,10 +133,13 @@
/** Default validation support (false). */
protected static final boolean DEFAULT_VALIDATION = false;
-
+
/** Default Schema validation support (true). */
protected static final boolean DEFAULT_SCHEMA_VALIDATION = true;
+ /** Default Schema full checking support (false). */
+ protected static final boolean DEFAULT_SCHEMA_FULL_CHECKING = false;
+
//
// Data
//
@@ -172,7 +178,7 @@
/** Sets the output writer. */
public void setOutput(Writer writer) {
-
+
fOut = writer instanceof PrintWriter
? (PrintWriter)writer : new PrintWriter(writer);
@@ -184,7 +190,7 @@
/** Set document locator. */
public void setDocumentLocator(Locator locator) {
-
+
printIndent();
fOut.print("setDocumentLocator(");
fOut.print("locator=");
@@ -196,7 +202,7 @@
/** Start document. */
public void startDocument() throws SAXException {
-
+
fIndent = 0;
printIndent();
fOut.println("startDocument()");
@@ -208,7 +214,7 @@
/** Processing instruction. */
public void processingInstruction(String target, String data)
throws SAXException {
-
+
printIndent();
fOut.print("processingInstruction(");
fOut.print("target=");
@@ -222,7 +228,7 @@
} // processingInstruction(String,String)
/** Characters. */
- public void characters(char[] ch, int offset, int length)
+ public void characters(char[] ch, int offset, int length)
throws SAXException {
printIndent();
@@ -235,7 +241,7 @@
} // characters(char[],int,int)
/** Ignorable whitespace. */
- public void ignorableWhitespace(char[] ch, int offset, int length)
+ public void ignorableWhitespace(char[] ch, int offset, int length)
throws SAXException {
printIndent();
@@ -278,7 +284,7 @@
} // startPrefixMapping(String,String)
/** Start element. */
- public void startElement(String uri, String localName, String qname,
+ public void startElement(String uri, String localName, String qname,
Attributes attributes) throws SAXException {
printIndent();
@@ -334,7 +340,7 @@
} // startElement(String,String,String,Attributes)
/** End element. */
- public void endElement(String uri, String localName, String qname)
+ public void endElement(String uri, String localName, String qname)
throws SAXException {
fIndent--;
@@ -382,7 +388,7 @@
//
/** Start element. */
- public void startElement(String name, AttributeList attributes)
+ public void startElement(String name, AttributeList attributes)
throws SAXException {
printIndent();
@@ -441,7 +447,7 @@
//
/** Notation declaration. */
- public void notationDecl(String name, String publicId, String systemId)
+ public void notationDecl(String name, String publicId, String systemId)
throws SAXException {
printIndent();
@@ -460,8 +466,8 @@
} // notationDecl(String,String,String)
/** Unparsed entity declaration. */
- public void unparsedEntityDecl(String name,
- String publicId, String systemId,
+ public void unparsedEntityDecl(String name,
+ String publicId, String systemId,
String notationName) throws SAXException {
printIndent();
fOut.print("unparsedEntityDecl(");
@@ -539,7 +545,7 @@
} // endCDATA()
/** Comment. */
- public void comment(char[] ch, int offset, int length)
+ public void comment(char[] ch, int offset, int length)
throws SAXException {
printIndent();
@@ -594,8 +600,8 @@
} // elementDecl(String,String)
/** Attribute declaration. */
- public void attributeDecl(String elementName, String attributeName,
- String type, String valueDefault,
+ public void attributeDecl(String elementName, String attributeName,
+ String type, String valueDefault,
String value) throws SAXException {
printIndent();
@@ -636,7 +642,7 @@
} // internalEntityDecl(String,String)
/** External entity declaration. */
- public void externalEntityDecl(String name,
+ public void externalEntityDecl(String name,
String publicId, String systemId)
throws SAXException {
@@ -776,7 +782,7 @@
/** Main. */
public static void main(String[] argv) throws Exception {
-
+
// is there anything to do?
if (argv.length == 0) {
printUsage();
@@ -790,7 +796,8 @@
boolean namespaces = DEFAULT_NAMESPACES;
boolean validation = DEFAULT_VALIDATION;
boolean schemaValidation = DEFAULT_SCHEMA_VALIDATION;
-
+ boolean schemaFullChecking = DEFAULT_SCHEMA_FULL_CHECKING;
+
// process arguments
for (int i = 0; i < argv.length; i++) {
String arg = argv[i];
@@ -832,6 +839,10 @@
schemaValidation = option.equals("s");
continue;
}
+ if (option.equalsIgnoreCase("f")) {
+ schemaFullChecking = option.equals("f");
+ continue;
+ }
if (option.equals("h")) {
printUsage();
continue;
@@ -872,8 +883,17 @@
}
catch (SAXNotSupportedException e) {
System.err.println("warning: Parser does not support feature ("+SCHEMA_VALIDATION_FEATURE_ID+")");
+ }
+ try {
+ parser.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, schemaFullChecking);
+ }
+ catch (SAXNotRecognizedException e) {
+ // ignore
}
-
+ catch (SAXNotSupportedException e) {
+ System.err.println("warning: Parser does not support feature ("+SCHEMA_FULL_CHECKING_FEATURE_ID+")");
+ }
+
// set handlers
parser.setDTDHandler(tracer);
parser.setErrorHandler(tracer);
@@ -895,7 +915,7 @@
else {
((Parser)parser).setDocumentHandler(tracer);
}
-
+
// parse file
try {
parser.parse(arg);
@@ -923,13 +943,15 @@
System.err.println("usage: java sax.DocumentTracer (options) uri ...");
System.err.println();
-
+
System.err.println("options:");
System.err.println(" -p name Select parser by name.");
System.err.println(" -n | -N Turn on/off namespace processing.");
System.err.println(" -v | -V Turn on/off validation.");
System.err.println(" -s | -S Turn on/off Schema validation support.");
System.err.println(" NOTE: Not supported by all parsers.");
+ System.err.println(" -f | -F Turn on/off Schema full checking.");
+ System.err.println(" NOTE: Requires use of -s and not supported by all parsers.");
System.err.println(" -h This help screen.");
System.err.println();
@@ -941,6 +963,8 @@
System.err.println(DEFAULT_VALIDATION ? "on" : "off");
System.err.print(" Schema: ");
System.err.println(DEFAULT_SCHEMA_VALIDATION ? "on" : "off");
+ System.err.print(" Schema full checking: ");
+ System.err.println(DEFAULT_SCHEMA_FULL_CHECKING ? "on" : "off");
} // printUsage()
1.3 +48 -24 xml-xerces/java/samples/sax/Writer.java
Index: Writer.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/samples/sax/Writer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Writer.java 2001/08/23 00:35:18 1.2
+++ Writer.java 2001/11/13 20:34:14 1.3
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -10,7 +10,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -18,7 +18,7 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
+ * if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
@@ -26,7 +26,7 @@
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
- * software without prior written permission. For written
+ * software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
@@ -55,8 +55,8 @@
* <http://www.apache.org/>.
*/
-package sax;
-
+package sax;
+
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
@@ -84,9 +84,9 @@
*
* @author Andy Clark, IBM
*
- * @version $Id: Writer.java,v 1.2 2001/08/23 00:35:18 lehors Exp $
+ * @version $Id: Writer.java,v 1.3 2001/11/13 20:34:14 sandygao Exp $
*/
-public class Writer
+public class Writer
extends DefaultHandler
implements LexicalHandler {
@@ -98,13 +98,16 @@
/** Namespaces feature id (http://xml.org/sax/features/namespaces). */
protected static final String NAMESPACES_FEATURE_ID = "http://xml.org/sax/features/namespaces";
-
+
/** Validation feature id (http://xml.org/sax/features/validation). */
protected static final String VALIDATION_FEATURE_ID = "http://xml.org/sax/features/validation";
/** Schema validation feature id (http://apache.org/xml/features/validation/schema). */
protected static final String SCHEMA_VALIDATION_FEATURE_ID = "http://apache.org/xml/features/validation/schema";
+ /** Schema full checking feature id (http://apache.org/xml/features/validation/schema-full-checking). */
+ protected static final String SCHEMA_FULL_CHECKING_FEATURE_ID = "http://apache.org/xml/features/validation/schema-full-checking";
+
// property ids
/** Lexical handler property id (http://xml.org/sax/properties/lexical-handler). */
@@ -120,10 +123,13 @@
/** Default validation support (false). */
protected static final boolean DEFAULT_VALIDATION = false;
-
+
/** Default Schema validation support (true). */
protected static final boolean DEFAULT_SCHEMA_VALIDATION = true;
+ /** Default Schema full checking support (false). */
+ protected static final boolean DEFAULT_SCHEMA_FULL_CHECKING = false;
+
/** Default canonical output (false). */
protected static final boolean DEFAULT_CANONICAL = false;
@@ -172,7 +178,7 @@
/** Sets the output writer. */
public void setOutput(java.io.Writer writer) {
-
+
fOut = writer instanceof PrintWriter
? (PrintWriter)writer : new PrintWriter(writer);
@@ -195,7 +201,7 @@
} // startDocument()
/** Processing instruction. */
- public void processingInstruction(String target, String data)
+ public void processingInstruction(String target, String data)
throws SAXException {
if (fElementDepth > 0) {
@@ -212,7 +218,7 @@
} // processingInstruction(String,String)
/** Start element. */
- public void startElement(String uri, String local, String raw,
+ public void startElement(String uri, String local, String raw,
Attributes attrs) throws SAXException {
fElementDepth++;
@@ -235,7 +241,7 @@
} // startElement(String,String,String,Attributes)
/** Characters. */
- public void characters(char ch[], int start, int length)
+ public void characters(char ch[], int start, int length)
throws SAXException {
normalizeAndPrint(ch, start, length);
@@ -244,7 +250,7 @@
} // characters(char[],int,int);
/** Ignorable whitespace. */
- public void ignorableWhitespace(char ch[], int start, int length)
+ public void ignorableWhitespace(char ch[], int start, int length)
throws SAXException {
characters(ch, start, length);
@@ -253,7 +259,7 @@
} // ignorableWhitespace(char[],int,int);
/** End element. */
- public void endElement(String uri, String local, String raw)
+ public void endElement(String uri, String local, String raw)
throws SAXException {
fElementDepth--;
@@ -290,7 +296,7 @@
/** Start DTD. */
public void startDTD(String name, String publicId, String systemId)
- throws SAXException {
+ throws SAXException {
} // startDTD(String,String,String)
/** End DTD. */
@@ -343,7 +349,7 @@
}
j++;
}
- attributes.insertAttributeAt(j, name, attrs.getType(i),
+ attributes.insertAttributeAt(j, name, attrs.getType(i),
attrs.getValue(i));
}
@@ -368,7 +374,7 @@
normalizeAndPrint(ch[offset + i]);
}
} // normalizeAndPrint(char[],int,int)
-
+
/** Normalizes and print the given character. */
protected void normalizeAndPrint(char c) {
@@ -436,7 +442,7 @@
/** Main program entry point. */
public static void main(String argv[]) {
-
+
// is there anything to do?
if (argv.length == 0) {
printUsage();
@@ -449,8 +455,9 @@
boolean namespaces = DEFAULT_NAMESPACES;
boolean validation = DEFAULT_VALIDATION;
boolean schemaValidation = DEFAULT_SCHEMA_VALIDATION;
+ boolean schemaFullChecking = DEFAULT_SCHEMA_FULL_CHECKING;
boolean canonical = DEFAULT_CANONICAL;
-
+
// process arguments
for (int i = 0; i < argv.length; i++) {
String arg = argv[i];
@@ -492,6 +499,10 @@
schemaValidation = option.equals("s");
continue;
}
+ if (option.equalsIgnoreCase("f")) {
+ schemaFullChecking = option.equals("f");
+ continue;
+ }
if (option.equalsIgnoreCase("c")) {
canonical = option.equals("c");
continue;
@@ -514,7 +525,7 @@
continue;
}
}
-
+
// set parser features
try {
parser.setFeature(NAMESPACES_FEATURE_ID, namespaces);
@@ -537,6 +548,15 @@
catch (SAXNotSupportedException e) {
System.err.println("warning: Parser does not support feature ("+SCHEMA_VALIDATION_FEATURE_ID+")");
}
+ try {
+ parser.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, schemaFullChecking);
+ }
+ catch (SAXNotRecognizedException e) {
+ // ignore
+ }
+ catch (SAXNotSupportedException e) {
+ System.err.println("warning: Parser does not support feature ("+SCHEMA_FULL_CHECKING_FEATURE_ID+")");
+ }
// setup writer
if (writer == null) {
@@ -559,7 +579,7 @@
catch (SAXException e) {
// ignore
}
-
+
// parse file
writer.setCanonical(canonical);
try {
@@ -588,13 +608,15 @@
System.err.println("usage: java sax.Writer (options) uri ...");
System.err.println();
-
+
System.err.println("options:");
System.err.println(" -p name Select parser by name.");
System.err.println(" -n | -N Turn on/off namespace processing.");
System.err.println(" -v | -V Turn on/off validation.");
System.err.println(" -s | -S Turn on/off Schema validation support.");
System.err.println(" NOTE: Not supported by all parsers.");
+ System.err.println(" -f | -F Turn on/off Schema full checking.");
+ System.err.println(" NOTE: Requires use of -s and not supported by all parsers.");
System.err.println(" -c | -C Turn on/off Canonical XML output.");
System.err.println(" NOTE: This is not W3C canonical output.");
System.err.println(" -h This help screen.");
@@ -608,6 +630,8 @@
System.err.println(DEFAULT_VALIDATION ? "on" : "off");
System.err.print(" Schema: ");
System.err.println(DEFAULT_SCHEMA_VALIDATION ? "on" : "off");
+ System.err.print(" Schema full checking: ");
+ System.err.println(DEFAULT_SCHEMA_FULL_CHECKING ? "on" : "off");
System.err.print(" Canonical: ");
System.err.println(DEFAULT_CANONICAL ? "on" : "off");
1.3 +34 -16 xml-xerces/java/samples/socket/DelayedInput.java
Index: DelayedInput.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/samples/socket/DelayedInput.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DelayedInput.java 2001/08/23 00:35:18 1.2
+++ DelayedInput.java 2001/11/13 20:34:14 1.3
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2000,2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2000,2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -10,7 +10,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -18,7 +18,7 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
+ * if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
@@ -26,7 +26,7 @@
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
- * software without prior written permission. For written
+ * software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
@@ -92,7 +92,7 @@
*
* @author Andy Clark, IBM
*
- * @version $Id: DelayedInput.java,v 1.2 2001/08/23 00:35:18 lehors Exp $
+ * @version $Id: DelayedInput.java,v 1.3 2001/11/13 20:34:14 sandygao Exp $
*/
public class DelayedInput
extends DefaultHandler {
@@ -105,13 +105,16 @@
/** Namespaces feature id (http://xml.org/sax/features/namespaces). */
protected static final String NAMESPACES_FEATURE_ID = "http://xml.org/sax/features/namespaces";
-
+
/** Validation feature id (http://xml.org/sax/features/validation). */
protected static final String VALIDATION_FEATURE_ID = "http://xml.org/sax/features/validation";
/** Schema validation feature id (http://apache.org/xml/features/validation/schema). */
protected static final String SCHEMA_VALIDATION_FEATURE_ID = "http://apache.org/xml/features/validation/schema";
+ /** Schema full checking feature id (http://apache.org/xml/features/validation/schema-full-checking). */
+ protected static final String SCHEMA_FULL_CHECKING_FEATURE_ID = "http://apache.org/xml/features/validation/schema-full-checking";
+
// default settings
/** Default parser name. */
@@ -122,10 +125,13 @@
/** Default validation support (false). */
protected static final boolean DEFAULT_VALIDATION = false;
-
+
/** Default Schema validation support (true). */
protected static final boolean DEFAULT_SCHEMA_VALIDATION = true;
+ /** Default Schema full checking support (false). */
+ protected static final boolean DEFAULT_SCHEMA_FULL_CHECKING = false;
+
//
// Data
//
@@ -158,7 +164,7 @@
} // startElement(String,String,String,Attributes)
/** End element. */
- public void endElement(String uri, String localpart, String rawname)
+ public void endElement(String uri, String localpart, String rawname)
throws SAXException {
System.out.println(")"+rawname);
} // endElement(String,String,String)
@@ -319,7 +325,7 @@
/** Main program entry point. */
public static void main(String argv[]) {
-
+
// is there anything to do?
if (argv.length == 0) {
printUsage();
@@ -333,7 +339,8 @@
boolean namespaces = DEFAULT_NAMESPACES;
boolean validation = DEFAULT_VALIDATION;
boolean schemaValidation = DEFAULT_SCHEMA_VALIDATION;
-
+ boolean schemaFullChecking = DEFAULT_SCHEMA_FULL_CHECKING;
+
// process arguments
for (int i = 0; i < argv.length; i++) {
String arg = argv[i];
@@ -375,6 +382,10 @@
schemaValidation = option.equals("s");
continue;
}
+ if (option.equalsIgnoreCase("f")) {
+ schemaFullChecking = option.equals("f");
+ continue;
+ }
if (option.equals("h")) {
printUsage();
continue;
@@ -393,7 +404,7 @@
continue;
}
}
-
+
// set parser features
try {
parser.setFeature(NAMESPACES_FEATURE_ID, namespaces);
@@ -410,12 +421,15 @@
try {
parser.setFeature(SCHEMA_VALIDATION_FEATURE_ID, schemaValidation);
}
- catch (SAXNotRecognizedException e) {
- // ignore
- }
- catch (SAXNotSupportedException e) {
+ catch (SAXException e) {
System.err.println("warning: Parser does not support feature ("+SCHEMA_VALIDATION_FEATURE_ID+")");
}
+ try {
+ parser.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, schemaFullChecking);
+ }
+ catch (SAXException e) {
+ System.err.println("warning: Parser does not support feature ("+SCHEMA_FULL_CHECKING_FEATURE_ID+")");
+ }
// parse file
parser.setContentHandler(handler);
@@ -450,13 +464,15 @@
System.err.println("usage: java socket.DelayedInput (options) filename ...");
System.err.println();
-
+
System.err.println("options:");
System.err.println(" -p name Select parser by name.");
System.err.println(" -n | -N Turn on/off namespace processing.");
System.err.println(" -v | -V Turn on/off validation.");
System.err.println(" -s | -S Turn on/off Schema validation support.");
System.err.println(" NOTE: Not supported by all parsers.");
+ System.err.println(" -f | -F Turn on/off Schema full checking.");
+ System.err.println(" NOTE: Requires use of -s and not supported by all parsers.");
System.err.println(" -h This help screen.");
System.err.println();
@@ -468,6 +484,8 @@
System.err.println(DEFAULT_VALIDATION ? "on" : "off");
System.err.print(" Schema: ");
System.err.println(DEFAULT_SCHEMA_VALIDATION ? "on" : "off");
+ System.err.print(" Schema full checking: ");
+ System.err.println(DEFAULT_SCHEMA_FULL_CHECKING ? "on" : "off");
} // printUsage()
1.3 +58 -34 xml-xerces/java/samples/xni/Counter.java
Index: Counter.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/samples/xni/Counter.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Counter.java 2001/08/23 00:35:18 1.2
+++ Counter.java 2001/11/13 20:34:14 1.3
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -10,7 +10,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -18,7 +18,7 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
+ * if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
@@ -26,7 +26,7 @@
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
- * software without prior written permission. For written
+ * software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
@@ -55,7 +55,7 @@
* <http://www.apache.org/>.
*/
-package xni;
+package xni;
import java.io.PrintWriter;
@@ -73,25 +73,25 @@
/**
* A sample XNI counter. The output of this program shows the time
- * and count of elements, attributes, ignorable whitespaces, and
- * characters appearing in the document.
+ * and count of elements, attributes, ignorable whitespaces, and
+ * characters appearing in the document.
* <p>
* This class is useful as a "poor-man's" performance tester to
- * compare the speed and accuracy of various parser configurations.
+ * compare the speed and accuracy of various parser configurations.
* However, it is important to note that the first parse time of a
- * parser will include both VM class load time and parser
- * initialization that would not be present in subsequent parses
- * with the same file.
+ * parser will include both VM class load time and parser
+ * initialization that would not be present in subsequent parses
+ * with the same file.
* <p>
* <strong>Note:</strong> The results produced by this program
* should never be accepted as true performance measurements.
*
* @author Andy Clark, IBM
*
- * @version $Id: Counter.java,v 1.2 2001/08/23 00:35:18 lehors Exp $
+ * @version $Id: Counter.java,v 1.3 2001/11/13 20:34:14 sandygao Exp $
*/
public class Counter
- extends XMLDocumentParser
+ extends XMLDocumentParser
implements XMLErrorHandler {
//
@@ -101,25 +101,29 @@
// feature ids
/** Namespaces feature id (http://xml.org/sax/features/namespaces). */
- protected static final String NAMESPACES_FEATURE_ID =
+ protected static final String NAMESPACES_FEATURE_ID =
"http://xml.org/sax/features/namespaces";
-
+
/** Namespace prefixes feature id (http://xml.org/sax/features/namespace-prefixes). */
- protected static final String NAMESPACE_PREFIXES_FEATURE_ID =
+ protected static final String NAMESPACE_PREFIXES_FEATURE_ID =
"http://xml.org/sax/features/namespace-prefixes";
/** Validation feature id (http://xml.org/sax/features/validation). */
- protected static final String VALIDATION_FEATURE_ID =
+ protected static final String VALIDATION_FEATURE_ID =
"http://xml.org/sax/features/validation";
/** Schema validation feature id (http://apache.org/xml/features/validation/schema). */
- protected static final String SCHEMA_VALIDATION_FEATURE_ID =
+ protected static final String SCHEMA_VALIDATION_FEATURE_ID =
"http://apache.org/xml/features/validation/schema";
+ /** Schema full checking feature id (http://apache.org/xml/features/validation/schema-full-checking). */
+ protected static final String SCHEMA_FULL_CHECKING_FEATURE_ID =
+ "http://apache.org/xml/features/validation/schema-full-checking";
+
// default settings
/** Default parser configuration (org.apache.xerces.parsers.StandardParserConfiguration). */
- protected static final String DEFAULT_PARSER_CONFIG =
+ protected static final String DEFAULT_PARSER_CONFIG =
"org.apache.xerces.parsers.StandardParserConfiguration";
/** Default repetition (1). */
@@ -133,10 +137,13 @@
/** Default validation support (false). */
protected static final boolean DEFAULT_VALIDATION = false;
-
+
/** Default Schema validation support (true). */
protected static final boolean DEFAULT_SCHEMA_VALIDATION = true;
+ /** Default Schema full checking support (false). */
+ protected static final boolean DEFAULT_SCHEMA_FULL_CHECKING = false;
+
/** Default memory usage report (false). */
protected static final boolean DEFAULT_MEMORY_USAGE = false;
@@ -180,7 +187,7 @@
//
/** Prints the results. */
- public void printResults(PrintWriter out, String uri, long time,
+ public void printResults(PrintWriter out, String uri, long time,
long memory, boolean tagginess,
int repetition) {
@@ -230,7 +237,7 @@
//
/** Start document. */
- public void startDocument(XMLLocator locator, String encoding)
+ public void startDocument(XMLLocator locator, String encoding)
throws XNIException {
fElements = 0;
@@ -243,7 +250,7 @@
} // startDocument(XMLLocator,String)
/** Start element. */
- public void startElement(QName element, XMLAttributes attrs)
+ public void startElement(QName element, XMLAttributes attrs)
throws XNIException {
fElements++;
@@ -266,7 +273,7 @@
} // startElement(QName,XMLAttributes)
/** Empty element. */
- public void emptyElement(QName element, XMLAttributes attrs)
+ public void emptyElement(QName element, XMLAttributes attrs)
throws XNIException {
fElements++;
@@ -320,13 +327,13 @@
//
/** Warning. */
- public void warning(String domain, String key, XMLParseException ex)
+ public void warning(String domain, String key, XMLParseException ex)
throws XNIException {
printError("Warning", ex);
} // warning(String,String,XMLParseException)
/** Error. */
- public void error(String domain, String key, XMLParseException ex)
+ public void error(String domain, String key, XMLParseException ex)
throws XNIException {
printError("Error", ex);
} // error(String,String,XMLParseException)
@@ -372,7 +379,7 @@
/** Main program entry point. */
public static void main(String argv[]) {
-
+
// is there anything to do?
if (argv.length == 0) {
printUsage();
@@ -388,9 +395,10 @@
boolean namespacePrefixes = DEFAULT_NAMESPACE_PREFIXES;
boolean validation = DEFAULT_VALIDATION;
boolean schemaValidation = DEFAULT_SCHEMA_VALIDATION;
+ boolean schemaFullChecking = DEFAULT_SCHEMA_FULL_CHECKING;
boolean memoryUsage = DEFAULT_MEMORY_USAGE;
boolean tagginess = DEFAULT_TAGGINESS;
-
+
// process arguments
for (int i = 0; i < argv.length; i++) {
String arg = argv[i];
@@ -453,6 +461,10 @@
schemaValidation = option.equals("s");
continue;
}
+ if (option.equalsIgnoreCase("f")) {
+ schemaFullChecking = option.equals("f");
+ continue;
+ }
if (option.equalsIgnoreCase("m")) {
memoryUsage = option.equals("m");
continue;
@@ -493,7 +505,7 @@
continue;
}
}
-
+
// set parser features
if (parser == null) {
parser = new Counter(parserConfig);
@@ -518,7 +530,15 @@
System.err.println("warning: Parser does not support feature ("+SCHEMA_VALIDATION_FEATURE_ID+")");
}
}
-
+ try {
+ parserConfig.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, schemaFullChecking);
+ }
+ catch (XMLConfigurationException e) {
+ if (e.getType() == XMLConfigurationException.NOT_SUPPORTED) {
+ System.err.println("warning: Parser does not support feature ("+SCHEMA_FULL_CHECKING_FEATURE_ID+")");
+ }
+ }
+
// parse file
try {
long timeBefore = System.currentTimeMillis();
@@ -528,11 +548,11 @@
}
long memoryAfter = Runtime.getRuntime().freeMemory();
long timeAfter = System.currentTimeMillis();
-
+
long time = timeAfter - timeBefore;
- long memory = memoryUsage
+ long memory = memoryUsage
? memoryBefore - memoryAfter : Long.MIN_VALUE;
- ((Counter)parser).printResults(out, arg, time,
+ ((Counter)parser).printResults(out, arg, time,
memory, tagginess,
repetition);
}
@@ -559,7 +579,7 @@
System.err.println("usage: java xni.Counter (options) uri ...");
System.err.println();
-
+
System.err.println("options:");
System.err.println(" -p name Select parser configuration by name.");
System.err.println(" -x number Select number of repetitions.");
@@ -569,6 +589,8 @@
System.err.println(" -v | -V Turn on/off validation.");
System.err.println(" -s | -S Turn on/off Schema validation support.");
System.err.println(" NOTE: Not supported by all parser configurations.");
+ System.err.println(" -f | -F Turn on/off Schema full checking.");
+ System.err.println(" NOTE: Requires use of -s and not supported by all parsers.");
System.err.println(" -m | -M Turn on/off memory usage report.");
System.err.println(" -t | -T Turn on/off \"tagginess\" report.");
System.err.println(" --rem text Output user defined comment before next parse.");
@@ -586,6 +608,8 @@
System.err.println(DEFAULT_VALIDATION ? "on" : "off");
System.err.print(" Schema: ");
System.err.println(DEFAULT_SCHEMA_VALIDATION ? "on" : "off");
+ System.err.print(" Schema full checking: ");
+ System.err.println(DEFAULT_SCHEMA_FULL_CHECKING ? "on" : "off");
System.err.print(" Memory: ");
System.err.println(DEFAULT_MEMORY_USAGE ? "on" : "off");
System.err.print(" Tagginess: ");
1.5 +58 -34 xml-xerces/java/samples/xni/DocumentTracer.java
Index: DocumentTracer.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/samples/xni/DocumentTracer.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DocumentTracer.java 2001/09/17 07:45:39 1.4
+++ DocumentTracer.java 2001/11/13 20:34:14 1.5
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2000,2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2000,2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -10,7 +10,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -18,7 +18,7 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
+ * if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
@@ -26,7 +26,7 @@
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
- * software without prior written permission. For written
+ * software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
@@ -78,15 +78,15 @@
import org.apache.xerces.xni.parser.XMLParserConfiguration;
/**
- * Provides a complete trace of XNI document and DTD events for
+ * Provides a complete trace of XNI document and DTD events for
* files parsed.
*
* @author Andy Clark, IBM
* @author Arnaud Le Hors, IBM
*
- * @version $Id: DocumentTracer.java,v 1.4 2001/09/17 07:45:39 andyc Exp $
+ * @version $Id: DocumentTracer.java,v 1.5 2001/11/13 20:34:14 sandygao Exp $
*/
-public class DocumentTracer
+public class DocumentTracer
extends XMLDocumentParser
implements XMLErrorHandler {
@@ -97,25 +97,29 @@
// feature ids
/** Namespaces feature id (http://xml.org/sax/features/namespaces). */
- protected static final String NAMESPACES_FEATURE_ID =
+ protected static final String NAMESPACES_FEATURE_ID =
"http://xml.org/sax/features/namespaces";
-
+
/** Validation feature id (http://xml.org/sax/features/validation). */
- protected static final String VALIDATION_FEATURE_ID =
+ protected static final String VALIDATION_FEATURE_ID =
"http://xml.org/sax/features/validation";
/** Schema validation feature id (http://apache.org/xml/features/validation/schema). */
- protected static final String SCHEMA_VALIDATION_FEATURE_ID =
+ protected static final String SCHEMA_VALIDATION_FEATURE_ID =
"http://apache.org/xml/features/validation/schema";
+ /** Schema full checking feature id (http://apache.org/xml/features/validation/schema-full-checking). */
+ protected static final String SCHEMA_FULL_CHECKING_FEATURE_ID =
+ "http://apache.org/xml/features/validation/schema-full-checking";
+
/** Character ref notification feature id (http://apache.org/xml/features/scanner/notify-char-refs). */
- protected static final String NOTIFY_CHAR_REFS_FEATURE_ID =
+ protected static final String NOTIFY_CHAR_REFS_FEATURE_ID =
"http://apache.org/xml/features/scanner/notify-char-refs";
// default settings
/** Default parser configuration (org.apache.xerces.parsers.StandardParserConfiguration). */
- protected static final String DEFAULT_PARSER_CONFIG =
+ protected static final String DEFAULT_PARSER_CONFIG =
"org.apache.xerces.parsers.StandardParserConfiguration";
/** Default namespaces support (true). */
@@ -123,13 +127,16 @@
/** Default validation support (false). */
protected static final boolean DEFAULT_VALIDATION = false;
-
+
/** Default Schema validation support (true). */
protected static final boolean DEFAULT_SCHEMA_VALIDATION = true;
+ /** Default Schema full checking support (false). */
+ protected static final boolean DEFAULT_SCHEMA_FULL_CHECKING = false;
+
/** Default character notifications (false). */
- protected static final boolean DEFAULT_NOTIFY_CHAR_REFS = false;
-
+ protected static final boolean DEFAULT_NOTIFY_CHAR_REFS = false;
+
//
// Data
//
@@ -178,7 +185,7 @@
/** Sets the output writer. */
public void setOutput(Writer writer) {
-
+
fOut = writer instanceof PrintWriter
? (PrintWriter)writer : new PrintWriter(writer);
@@ -198,10 +205,10 @@
* where the entity encoding is not auto-detected (e.g.
* internal entities or a document entity that is
* parsed from a java.io.Reader).
- *
+ *
* @throws XNIException Thrown by handler to signal an error.
*/
- public void startDocument(XMLLocator locator, String encoding)
+ public void startDocument(XMLLocator locator, String encoding)
throws XNIException {
fIndent = 0;
@@ -260,7 +267,7 @@
} // xmlDecl(String,String,String,String)
/** Doctype declaration. */
- public void doctypeDecl(String rootElement, String publicId,
+ public void doctypeDecl(String rootElement, String publicId,
String systemId) throws XNIException {
printIndent();
@@ -415,8 +422,8 @@
//
/** Start entity. */
- public void startEntity(String name,
- String publicId, String systemId,
+ public void startEntity(String name,
+ String publicId, String systemId,
String baseSystemId,
String encoding) throws XNIException {
@@ -565,8 +572,8 @@
} // startAttlist(String)
/** Attribute declaration. */
- public void attributeDecl(String elementName, String attributeName,
- String type, String[] enumeration,
+ public void attributeDecl(String elementName, String attributeName,
+ String type, String[] enumeration,
String defaultType, XMLString defaultValue)
throws XNIException {
@@ -636,7 +643,7 @@
printQuotedString(text.ch, text.offset, text.length);
fOut.print(',');
fOut.print("nonNormalizedText=");
- printQuotedString(nonNormalizedText.ch, nonNormalizedText.offset,
+ printQuotedString(nonNormalizedText.ch, nonNormalizedText.offset,
nonNormalizedText.length);
fOut.println(')');
fOut.flush();
@@ -644,7 +651,7 @@
} // internalEntityDecl(String,XMLString)
/** External entity declaration. */
- public void externalEntityDecl(String name,
+ public void externalEntityDecl(String name,
String publicId, String systemId,
String baseSystemId) throws XNIException {
@@ -667,7 +674,7 @@
} // externalEntityDecl(String,String,String)
/** Unparsed entity declaration. */
- public void unparsedEntityDecl(String name, String publicId,
+ public void unparsedEntityDecl(String name, String publicId,
String systemId, String notation)
throws XNIException {
@@ -800,7 +807,7 @@
/** #PCDATA. */
public void pcdata() throws XNIException {
-
+
printIndent();
fOut.println("pcdata()");
fOut.flush();
@@ -896,13 +903,13 @@
//
/** Warning. */
- public void warning(String domain, String key, XMLParseException ex)
+ public void warning(String domain, String key, XMLParseException ex)
throws XNIException {
printError("Warning", ex);
} // warning(String,String,XMLParseException)
/** Error. */
- public void error(String domain, String key, XMLParseException ex)
+ public void error(String domain, String key, XMLParseException ex)
throws XNIException {
printError("Error", ex);
} // error(String,String,XMLParseException)
@@ -1083,7 +1090,7 @@
/** Main. */
public static void main(String[] argv) throws Exception {
-
+
// is there anything to do?
if (argv.length == 0) {
printUsage();
@@ -1096,6 +1103,7 @@
boolean namespaces = DEFAULT_NAMESPACES;
boolean validation = DEFAULT_VALIDATION;
boolean schemaValidation = DEFAULT_SCHEMA_VALIDATION;
+ boolean schemaFullChecking = DEFAULT_SCHEMA_FULL_CHECKING;
boolean notifyCharRefs = DEFAULT_NOTIFY_CHAR_REFS;
// process arguments
@@ -1134,6 +1142,10 @@
schemaValidation = option.equals("s");
continue;
}
+ if (option.equalsIgnoreCase("f")) {
+ schemaFullChecking = option.equals("f");
+ continue;
+ }
if (option.equalsIgnoreCase("c")) {
notifyCharRefs = option.equals("c");
continue;
@@ -1156,7 +1168,7 @@
continue;
}
}
-
+
// set parser features
if (parser == null) {
parser = new DocumentTracer(parserConfig);
@@ -1182,6 +1194,14 @@
}
}
try {
+ parserConfig.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, schemaFullChecking);
+ }
+ catch (XMLConfigurationException e) {
+ if (e.getType() == XMLConfigurationException.NOT_SUPPORTED) {
+ System.err.println("warning: Parser does not support feature ("+SCHEMA_FULL_CHECKING_FEATURE_ID+")");
+ }
+ }
+ try {
parserConfig.setFeature(NOTIFY_CHAR_REFS_FEATURE_ID, notifyCharRefs);
}
catch (XMLConfigurationException e) {
@@ -1192,7 +1212,7 @@
System.err.println("warning: Parser does not support feature ("+NOTIFY_CHAR_REFS_FEATURE_ID+")");
}
}
-
+
// parse file
try {
parser.parse(new XMLInputSource(null, arg, null));
@@ -1220,13 +1240,15 @@
System.err.println("usage: java xni.DocumentTracer (options) uri ...");
System.err.println();
-
+
System.err.println("options:");
System.out.println(" -p name Specify parser configuration by name.");
System.err.println(" -n | -N Turn on/off namespace processing.");
System.err.println(" -v | -V Turn on/off validation.");
System.err.println(" -s | -S Turn on/off Schema validation support.");
System.err.println(" NOTE: Not supported by all parser configurations.");
+ System.err.println(" -f | -F Turn on/off Schema full checking.");
+ System.err.println(" NOTE: Requires use of -s and not supported by all parsers.");
System.err.println(" -c | -C Turn on/off character notifications");
System.err.println(" -h This help screen.");
System.err.println();
@@ -1239,6 +1261,8 @@
System.err.println(DEFAULT_VALIDATION ? "on" : "off");
System.out.print(" Schema: ");
System.err.println(DEFAULT_SCHEMA_VALIDATION ? "on" : "off");
+ System.err.print(" Schema full checking: ");
+ System.err.println(DEFAULT_SCHEMA_FULL_CHECKING ? "on" : "off");
System.out.print(" Char refs: ");
System.err.println(DEFAULT_NOTIFY_CHAR_REFS ? "on" : "off" );
1.3 +54 -30 xml-xerces/java/samples/xni/Writer.java
Index: Writer.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/samples/xni/Writer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Writer.java 2001/08/23 00:35:19 1.2
+++ Writer.java 2001/11/13 20:34:14 1.3
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -10,7 +10,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -18,7 +18,7 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
+ * if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
@@ -26,7 +26,7 @@
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
- * software without prior written permission. For written
+ * software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
@@ -55,8 +55,8 @@
* <http://www.apache.org/>.
*/
-package xni;
-
+package xni;
+
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
@@ -99,10 +99,10 @@
*
* @author Andy Clark, IBM
*
- * @version $Id: Writer.java,v 1.2 2001/08/23 00:35:19 lehors Exp $
+ * @version $Id: Writer.java,v 1.3 2001/11/13 20:34:14 sandygao Exp $
*/
-public class Writer
- extends XMLDocumentParser
+public class Writer
+ extends XMLDocumentParser
implements XMLErrorHandler {
//
@@ -112,21 +112,25 @@
// feature ids
/** Namespaces feature id (http://xml.org/sax/features/namespaces). */
- protected static final String NAMESPACES_FEATURE_ID =
+ protected static final String NAMESPACES_FEATURE_ID =
"http://xml.org/sax/features/namespaces";
-
+
/** Validation feature id (http://xml.org/sax/features/validation). */
- protected static final String VALIDATION_FEATURE_ID =
+ protected static final String VALIDATION_FEATURE_ID =
"http://xml.org/sax/features/validation";
/** Schema validation feature id (http://apache.org/xml/features/validation/schema). */
- protected static final String SCHEMA_VALIDATION_FEATURE_ID =
+ protected static final String SCHEMA_VALIDATION_FEATURE_ID =
"http://apache.org/xml/features/validation/schema";
+ /** Schema full checking feature id (http://apache.org/xml/features/validation/schema-full-checking). */
+ protected static final String SCHEMA_FULL_CHECKING_FEATURE_ID =
+ "http://apache.org/xml/features/validation/schema-full-checking";
+
// default settings
/** Default parser configuration (org.apache.xerces.parsers.StandardParserConfiguration). */
- protected static final String DEFAULT_PARSER_CONFIG =
+ protected static final String DEFAULT_PARSER_CONFIG =
"org.apache.xerces.parsers.StandardParserConfiguration";
/** Default namespaces support (true). */
@@ -134,10 +138,13 @@
/** Default validation support (false). */
protected static final boolean DEFAULT_VALIDATION = false;
-
+
/** Default Schema validation support (true). */
protected static final boolean DEFAULT_SCHEMA_VALIDATION = true;
+ /** Default Schema full checking support (false). */
+ protected static final boolean DEFAULT_SCHEMA_FULL_CHECKING = false;
+
/** Default canonical output (false). */
protected static final boolean DEFAULT_CANONICAL = false;
@@ -191,7 +198,7 @@
/** Sets the output writer. */
public void setOutput(java.io.Writer writer) {
-
+
fOut = writer instanceof PrintWriter
? (PrintWriter)writer : new PrintWriter(writer);
@@ -202,7 +209,7 @@
//
/** Start document. */
- public void startDocument(XMLLocator locator, String encoding)
+ public void startDocument(XMLLocator locator, String encoding)
throws XNIException {
fElementDepth = 0;
@@ -216,7 +223,7 @@
} // startDocument(XMLLocator,String)
/** Start element. */
- public void startElement(QName element, XMLAttributes attrs)
+ public void startElement(QName element, XMLAttributes attrs)
throws XNIException {
fElementDepth++;
@@ -241,7 +248,7 @@
} // startElement(QName,XMLAttributes)
/** Empty element. */
- public void emptyElement(QName element, XMLAttributes attrs)
+ public void emptyElement(QName element, XMLAttributes attrs)
throws XNIException {
fElementDepth++;
@@ -305,7 +312,7 @@
//
/** Processing instruction. */
- public void processingInstruction(String target, XMLString data)
+ public void processingInstruction(String target, XMLString data)
throws XNIException {
if (fElementDepth > 0) {
@@ -332,7 +339,7 @@
} // comment(XMLString)
/** Start entity. */
- public void startEntity(String name,
+ public void startEntity(String name,
String publicId, String systemId,
String baseSystemId) throws XNIException {
} // startEntity(String,String,String,String)
@@ -360,19 +367,19 @@
//
/** Warning. */
- public void warning(String domain, String key, XMLParseException ex)
+ public void warning(String domain, String key, XMLParseException ex)
throws XNIException {
printError("Warning", ex);
} // warning(String,String,XMLParseException)
/** Error. */
- public void error(String domain, String key, XMLParseException ex)
+ public void error(String domain, String key, XMLParseException ex)
throws XNIException {
printError("Error", ex);
} // error(String,String,XMLParseException)
/** Fatal error. */
- public void fatalError(String domain, String key, XMLParseException ex)
+ public void fatalError(String domain, String key, XMLParseException ex)
throws XNIException {
printError("Fatal Error", ex);
throw ex;
@@ -399,7 +406,7 @@
}
j++;
}
- attributes.insertAttributeAt(j, name, attrs.getType(i),
+ attributes.insertAttributeAt(j, name, attrs.getType(i),
attrs.getValue(i));
}
@@ -425,7 +432,7 @@
normalizeAndPrint(text.ch[text.offset + i]);
}
} // normalizeAndPrint(XMLString)
-
+
/** Normalizes and print the given character. */
protected void normalizeAndPrint(char c) {
@@ -493,7 +500,7 @@
/** Main program entry point. */
public static void main(String argv[]) {
-
+
// is there anything to do?
if (argv.length == 0) {
printUsage();
@@ -506,8 +513,9 @@
boolean namespaces = DEFAULT_NAMESPACES;
boolean validation = DEFAULT_VALIDATION;
boolean schemaValidation = DEFAULT_SCHEMA_VALIDATION;
+ boolean schemaFullChecking = DEFAULT_SCHEMA_FULL_CHECKING;
boolean canonical = DEFAULT_CANONICAL;
-
+
// process arguments
for (int i = 0; i < argv.length; i++) {
String arg = argv[i];
@@ -548,6 +556,10 @@
schemaValidation = option.equals("s");
continue;
}
+ if (option.equalsIgnoreCase("f")) {
+ schemaFullChecking = option.equals("f");
+ continue;
+ }
if (option.equalsIgnoreCase("c")) {
canonical = option.equals("c");
continue;
@@ -575,7 +587,7 @@
continue;
}
}
-
+
// set parser features
if (writer == null) {
writer = new Writer(parserConfig);
@@ -600,6 +612,14 @@
System.err.println("warning: Parser does not support feature ("+SCHEMA_VALIDATION_FEATURE_ID+")");
}
}
+ try {
+ parserConfig.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, schemaFullChecking);
+ }
+ catch (XMLConfigurationException e) {
+ if (e.getType() == XMLConfigurationException.NOT_SUPPORTED) {
+ System.err.println("warning: Parser does not support feature ("+SCHEMA_FULL_CHECKING_FEATURE_ID+")");
+ }
+ }
// parse file
try {
@@ -636,13 +656,15 @@
System.err.println("usage: java sax.Writer (options) uri ...");
System.err.println();
-
+
System.err.println("options:");
System.err.println(" -p name Select parser configuration by name.");
System.err.println(" -n | -N Turn on/off namespace processing.");
System.err.println(" -v | -V Turn on/off validation.");
System.err.println(" -s | -S Turn on/off Schema validation support.");
System.err.println(" NOTE: Not supported by all parsers.");
+ System.err.println(" -f | -F Turn on/off Schema full checking.");
+ System.err.println(" NOTE: Requires use of -s and not supported by all parsers.");
/***
System.err.println(" -c | -C Turn on/off Canonical XML output.");
System.err.println(" NOTE: This is not W3C canonical output.");
@@ -658,6 +680,8 @@
System.err.println(DEFAULT_VALIDATION ? "on" : "off");
System.err.print(" Schema: ");
System.err.println(DEFAULT_SCHEMA_VALIDATION ? "on" : "off");
+ System.err.print(" Schema full checking: ");
+ System.err.println(DEFAULT_SCHEMA_FULL_CHECKING ? "on" : "off");
/***
System.err.print(" Canonical: ");
System.err.println(DEFAULT_CANONICAL ? "on" : "off");
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org