You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2005/10/30 21:49:31 UTC

svn commit: r329638 - in /xerces/java/trunk/samples/jaxp: InlineSchemaValidator.java SourceValidator.java TypeInfoWriter.java

Author: mrglavas
Date: Sun Oct 30 12:49:20 2005
New Revision: 329638

URL: http://svn.apache.org/viewcvs?rev=329638&view=rev
Log:
Adding option to select schema language to validation samples.

Modified:
    xerces/java/trunk/samples/jaxp/InlineSchemaValidator.java
    xerces/java/trunk/samples/jaxp/SourceValidator.java
    xerces/java/trunk/samples/jaxp/TypeInfoWriter.java

Modified: xerces/java/trunk/samples/jaxp/InlineSchemaValidator.java
URL: http://svn.apache.org/viewcvs/xerces/java/trunk/samples/jaxp/InlineSchemaValidator.java?rev=329638&r1=329637&r2=329638&view=diff
==============================================================================
--- xerces/java/trunk/samples/jaxp/InlineSchemaValidator.java (original)
+++ xerces/java/trunk/samples/jaxp/InlineSchemaValidator.java Sun Oct 30 12:49:20 2005
@@ -90,6 +90,9 @@
     
     // default settings
     
+    /** Default schema language (http://www.w3.org/2001/XMLSchema). */
+    protected static final String DEFAULT_SCHEMA_LANGUAGE = XMLConstants.W3C_XML_SCHEMA_NS_URI;
+    
     /** Default repetition (1). */
     protected static final int DEFAULT_REPETITION = 1;
     
@@ -354,6 +357,7 @@
         HashMap prefixMappings = null;
         HashMap uriMappings = null;
         String docURI = argv[argv.length - 1];
+        String schemaLanguage = DEFAULT_SCHEMA_LANGUAGE;
         int repetition = DEFAULT_REPETITION;
         boolean schemaFullChecking = DEFAULT_SCHEMA_FULL_CHECKING;
         boolean honourAllSchemaLocations = DEFAULT_HONOUR_ALL_SCHEMA_LOCATIONS;
@@ -366,6 +370,16 @@
             String arg = argv[i];
             if (arg.startsWith("-")) {
                 String option = arg.substring(1);
+                if (option.equals("l")) {
+                    // get schema language name
+                    if (++i == argv.length) {
+                        System.err.println("error: Missing argument to -l option.");
+                    }
+                    else {
+                        schemaLanguage = argv[i];
+                    }
+                    continue;
+                }
                 if (option.equals("x")) {
                     if (++i == argv.length) {
                         System.err.println("error: Missing argument to -x option.");
@@ -487,7 +501,7 @@
             }
 
             // Create SchemaFactory and configure
-            SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+            SchemaFactory factory = SchemaFactory.newInstance(schemaLanguage);
             factory.setErrorHandler(inlineSchemaValidator);
             
             try {
@@ -630,6 +644,7 @@
         System.err.println();
         
         System.err.println("options:");
+        System.err.println("  -l name          Select schema language by name.");
         System.err.println("  -x number        Select number of repetitions.");
         System.err.println("  -a xpath    ...  Provide a list of XPath expressions for schema roots");
         System.err.println("  -i xpath    ...  Provide a list of XPath expressions for validation roots");
@@ -647,6 +662,7 @@
         
         System.err.println();
         System.err.println("defaults:");
+        System.err.println("  Schema language:                 " + DEFAULT_SCHEMA_LANGUAGE);
         System.err.println("  Repetition:                      " + DEFAULT_REPETITION);
         System.err.print("  Schema full checking:            ");
         System.err.println(DEFAULT_SCHEMA_FULL_CHECKING ? "on" : "off");

Modified: xerces/java/trunk/samples/jaxp/SourceValidator.java
URL: http://svn.apache.org/viewcvs/xerces/java/trunk/samples/jaxp/SourceValidator.java?rev=329638&r1=329637&r2=329638&view=diff
==============================================================================
--- xerces/java/trunk/samples/jaxp/SourceValidator.java (original)
+++ xerces/java/trunk/samples/jaxp/SourceValidator.java Sun Oct 30 12:49:20 2005
@@ -86,6 +86,9 @@
     
     // default settings
     
+    /** Default schema language (http://www.w3.org/2001/XMLSchema). */
+    protected static final String DEFAULT_SCHEMA_LANGUAGE = XMLConstants.W3C_XML_SCHEMA_NS_URI;
+    
     /** Default repetition (1). */
     protected static final int DEFAULT_REPETITION = 1;
     
@@ -251,6 +254,7 @@
         // variables
         Vector schemas = null;
         Vector instances = null;
+        String schemaLanguage = DEFAULT_SCHEMA_LANGUAGE;
         int repetition = DEFAULT_REPETITION;
         String validationSource = DEFAULT_VALIDATION_SOURCE;
         boolean schemaFullChecking = DEFAULT_SCHEMA_FULL_CHECKING;
@@ -264,6 +268,16 @@
             String arg = argv[i];
             if (arg.startsWith("-")) {
                 String option = arg.substring(1);
+                if (option.equals("l")) {
+                    // get schema language name
+                    if (++i == argv.length) {
+                        System.err.println("error: Missing argument to -l option.");
+                    }
+                    else {
+                        schemaLanguage = argv[i];
+                    }
+                    continue;
+                }
                 if (option.equals("x")) {
                     if (++i == argv.length) {
                         System.err.println("error: Missing argument to -x option.");
@@ -350,7 +364,7 @@
             SourceValidator sourceValidator = new SourceValidator();
             
             // Create SchemaFactory and configure
-            SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+            SchemaFactory factory = SchemaFactory.newInstance(schemaLanguage);
             factory.setErrorHandler(sourceValidator);
             
             try {
@@ -507,6 +521,7 @@
         System.err.println();
         
         System.err.println("options:");
+        System.err.println("  -l name     Select schema language by name.");
         System.err.println("  -x number   Select number of repetitions.");
         System.err.println("  -a uri ...  Provide a list of schema documents");
         System.err.println("  -i uri ...  Provide a list of instance documents to validate");
@@ -524,6 +539,7 @@
         
         System.err.println();
         System.err.println("defaults:");
+        System.err.println("  Schema language:                 " + DEFAULT_SCHEMA_LANGUAGE);
         System.err.println("  Repetition:                      " + DEFAULT_REPETITION);
         System.err.println("  Validation source:               " + DEFAULT_VALIDATION_SOURCE);
         System.err.print("  Schema full checking:            ");

Modified: xerces/java/trunk/samples/jaxp/TypeInfoWriter.java
URL: http://svn.apache.org/viewcvs/xerces/java/trunk/samples/jaxp/TypeInfoWriter.java?rev=329638&r1=329637&r2=329638&view=diff
==============================================================================
--- xerces/java/trunk/samples/jaxp/TypeInfoWriter.java (original)
+++ xerces/java/trunk/samples/jaxp/TypeInfoWriter.java Sun Oct 30 12:49:20 2005
@@ -77,7 +77,10 @@
     
     // default settings
     
-    /** Default parser name. */
+    /** Default schema language (http://www.w3.org/2001/XMLSchema). */
+    protected static final String DEFAULT_SCHEMA_LANGUAGE = XMLConstants.W3C_XML_SCHEMA_NS_URI;
+    
+    /** Default parser name (org.apache.xerces.parsers.SAXParser). */
     protected static final String DEFAULT_PARSER_NAME = "org.apache.xerces.parsers.SAXParser";
     
     /** Default schema full checking support (false). */
@@ -338,6 +341,7 @@
         XMLReader parser = null;
         Vector schemas = null;
         Vector instances = null;
+        String schemaLanguage = DEFAULT_SCHEMA_LANGUAGE;
         boolean schemaFullChecking = DEFAULT_SCHEMA_FULL_CHECKING;
         boolean honourAllSchemaLocations = DEFAULT_HONOUR_ALL_SCHEMA_LOCATIONS;
         boolean validateAnnotations = DEFAULT_VALIDATE_ANNOTATIONS;
@@ -348,6 +352,16 @@
             String arg = argv[i];
             if (arg.startsWith("-")) {
                 String option = arg.substring(1);
+                if (option.equals("l")) {
+                    // get schema language name
+                    if (++i == argv.length) {
+                        System.err.println("error: Missing argument to -l option.");
+                    }
+                    else {
+                        schemaLanguage = argv[i];
+                    }
+                    continue;
+                }
                 if (option.equals("p")) {
                     // get parser name
                     if (++i == argv.length) {
@@ -441,7 +455,7 @@
             writer.setOutput(System.out, "UTF8");
             
             // Create SchemaFactory and configure
-            SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+            SchemaFactory factory = SchemaFactory.newInstance(schemaLanguage);
             factory.setErrorHandler(writer);
             
             try {
@@ -577,9 +591,10 @@
         System.err.println();
         
         System.err.println("options:");
+        System.err.println("  -l name     Select schema language by name.");
+        System.err.println("  -p name     Select parser by name.");
         System.err.println("  -a uri ...  Provide a list of schema documents");
         System.err.println("  -i uri ...  Provide a list of instance documents to validate");
-        System.err.println("  -p name     Select parser by name.");
         System.err.println("  -f  | -F    Turn on/off Schema full checking.");
         System.err.println("              NOTE: Not supported by all schema factories and validators.");
         System.err.println("  -hs | -HS   Turn on/off honouring of all schema locations.");
@@ -592,7 +607,8 @@
         
         System.err.println();
         System.err.println("defaults:");
-        System.err.println("  Parser:     "+DEFAULT_PARSER_NAME);
+        System.err.println("  Schema language:                 " + DEFAULT_SCHEMA_LANGUAGE);
+        System.err.println("  Parser:                          " + DEFAULT_PARSER_NAME);
         System.err.print("  Schema full checking:            ");
         System.err.println(DEFAULT_SCHEMA_FULL_CHECKING ? "on" : "off");
         System.err.print("  Honour all schema locations:     ");



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org