mrglavas 2004/12/15 19:35:44 Modified: java/samples/sax DocumentTracer.java Writer.java Counter.java Log: Add validate-annotations option to SAX samples. Revision Changes Path 1.12 +23 -1 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.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- DocumentTracer.java 24 Feb 2004 23:41:06 -0000 1.11 +++ DocumentTracer.java 16 Dec 2004 03:35:43 -0000 1.12 @@ -80,6 +80,9 @@ /** 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"; + /** Validate schema annotations feature id (http://apache.org/xml/features/validate-annotations) */ + protected static final String VALIDATE_ANNOTATIONS_ID = "http://apache.org/xml/features/validate-annotations"; + /** 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"; @@ -114,6 +117,9 @@ /** Default Schema full checking support (false). */ protected static final boolean DEFAULT_SCHEMA_FULL_CHECKING = false; + /** Default validate schema annotations (false). */ + protected static final boolean DEFAULT_VALIDATE_ANNOTATIONS = false; + /** Default dynamic validation support (false). */ protected static final boolean DEFAULT_DYNAMIC_VALIDATION = false; @@ -776,6 +782,7 @@ boolean externalDTD = DEFAULT_LOAD_EXTERNAL_DTD; boolean schemaValidation = DEFAULT_SCHEMA_VALIDATION; boolean schemaFullChecking = DEFAULT_SCHEMA_FULL_CHECKING; + boolean validateAnnotations = DEFAULT_VALIDATE_ANNOTATIONS; boolean dynamicValidation = DEFAULT_DYNAMIC_VALIDATION; // process arguments @@ -831,6 +838,10 @@ schemaFullChecking = option.equals("f"); continue; } + if (option.equalsIgnoreCase("va")) { + validateAnnotations = option.equals("va"); + continue; + } if (option.equalsIgnoreCase("dv")) { dynamicValidation = option.equals("dv"); continue; @@ -901,6 +912,15 @@ System.err.println("warning: Parser does not support feature ("+SCHEMA_FULL_CHECKING_FEATURE_ID+")"); } try { + parser.setFeature(VALIDATE_ANNOTATIONS_ID, validateAnnotations); + } + catch (SAXNotRecognizedException e) { + System.err.println("warning: Parser does not support feature ("+VALIDATE_ANNOTATIONS_ID+")"); + } + catch (SAXNotSupportedException e) { + System.err.println("warning: Parser does not support feature ("+VALIDATE_ANNOTATIONS_ID+")"); + } + try { parser.setFeature(DYNAMIC_VALIDATION_FEATURE_ID, dynamicValidation); } catch (SAXNotRecognizedException e) { @@ -974,6 +994,8 @@ 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(" -va | -VA Turn on/off validation of schema annotations."); 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: Not supported by all parsers."); 1.13 +23 -1 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.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- Writer.java 23 Jun 2004 03:43:20 -0000 1.12 +++ Writer.java 16 Dec 2004 03:35:43 -0000 1.13 @@ -72,6 +72,9 @@ /** 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"; + + /** Validate schema annotations feature id (http://apache.org/xml/features/validate-annotations) */ + protected static final String VALIDATE_ANNOTATIONS_ID = "http://apache.org/xml/features/validate-annotations"; /** 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"; @@ -107,6 +110,9 @@ /** Default Schema full checking support (false). */ protected static final boolean DEFAULT_SCHEMA_FULL_CHECKING = false; + /** Default validate schema annotations (false). */ + protected static final boolean DEFAULT_VALIDATE_ANNOTATIONS = false; + /** Default dynamic validation support (false). */ protected static final boolean DEFAULT_DYNAMIC_VALIDATION = false; @@ -536,6 +542,7 @@ boolean externalDTD = DEFAULT_LOAD_EXTERNAL_DTD; boolean schemaValidation = DEFAULT_SCHEMA_VALIDATION; boolean schemaFullChecking = DEFAULT_SCHEMA_FULL_CHECKING; + boolean validateAnnotations = DEFAULT_VALIDATE_ANNOTATIONS; boolean dynamicValidation = DEFAULT_DYNAMIC_VALIDATION; boolean canonical = DEFAULT_CANONICAL; @@ -593,6 +600,10 @@ schemaFullChecking = option.equals("f"); continue; } + if (option.equalsIgnoreCase("va")) { + validateAnnotations = option.equals("va"); + continue; + } if (option.equalsIgnoreCase("dv")) { dynamicValidation = option.equals("dv"); continue; @@ -668,6 +679,15 @@ System.err.println("warning: Parser does not support feature ("+SCHEMA_FULL_CHECKING_FEATURE_ID+")"); } try { + parser.setFeature(VALIDATE_ANNOTATIONS_ID, validateAnnotations); + } + catch (SAXNotRecognizedException e) { + System.err.println("warning: Parser does not support feature ("+VALIDATE_ANNOTATIONS_ID+")"); + } + catch (SAXNotSupportedException e) { + System.err.println("warning: Parser does not support feature ("+VALIDATE_ANNOTATIONS_ID+")"); + } + try { parser.setFeature(DYNAMIC_VALIDATION_FEATURE_ID, dynamicValidation); } catch (SAXNotRecognizedException e) { @@ -742,6 +762,8 @@ 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(" -va | -VA Turn on/off validation of schema annotations."); 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: Not supported by all parsers."); 1.13 +24 -1 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.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- Counter.java 24 Feb 2004 23:41:06 -0000 1.12 +++ Counter.java 16 Dec 2004 03:35:43 -0000 1.13 @@ -74,6 +74,9 @@ /** 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"; + + /** Validate schema annotations feature id (http://apache.org/xml/features/validate-annotations) */ + protected static final String VALIDATE_ANNOTATIONS_ID = "http://apache.org/xml/features/validate-annotations"; /** 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"; @@ -100,6 +103,9 @@ /** Default Schema full checking support (false). */ protected static final boolean DEFAULT_SCHEMA_FULL_CHECKING = false; + + /** Default validate schema annotations (false). */ + protected static final boolean DEFAULT_VALIDATE_ANNOTATIONS = false; /** Default dynamic validation support (false). */ protected static final boolean DEFAULT_DYNAMIC_VALIDATION = false; @@ -330,6 +336,7 @@ boolean validation = DEFAULT_VALIDATION; boolean schemaValidation = DEFAULT_SCHEMA_VALIDATION; boolean schemaFullChecking = DEFAULT_SCHEMA_FULL_CHECKING; + boolean validateAnnotations = DEFAULT_VALIDATE_ANNOTATIONS; boolean dynamicValidation = DEFAULT_DYNAMIC_VALIDATION; boolean memoryUsage = DEFAULT_MEMORY_USAGE; boolean tagginess = DEFAULT_TAGGINESS; @@ -403,6 +410,10 @@ schemaFullChecking = option.equals("f"); continue; } + if (option.equalsIgnoreCase("va")) { + validateAnnotations = option.equals("va"); + continue; + } if (option.equalsIgnoreCase("dv")) { dynamicValidation = option.equals("dv"); continue; @@ -485,6 +496,16 @@ System.err.println("warning: Parser does not support feature ("+SCHEMA_FULL_CHECKING_FEATURE_ID+")"); } try { + parser.setFeature(VALIDATE_ANNOTATIONS_ID, validateAnnotations); + } + catch (SAXNotRecognizedException e) { + System.err.println("warning: Parser does not support feature ("+VALIDATE_ANNOTATIONS_ID+")"); + + } + catch (SAXNotSupportedException e) { + System.err.println("warning: Parser does not support feature ("+VALIDATE_ANNOTATIONS_ID+")"); + } + try { parser.setFeature(DYNAMIC_VALIDATION_FEATURE_ID, dynamicValidation); } catch (SAXNotRecognizedException e) { @@ -552,6 +573,8 @@ 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(" -va | -VA Turn on/off validation of schema annotations."); 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: Not supported by all parsers.");
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]