KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > thaiopensource > validate > schematron > SchematronProperty


1 package com.thaiopensource.validate.schematron;
2
3 import com.thaiopensource.validate.StringPropertyId;
4 import com.thaiopensource.validate.FlagPropertyId;
5 import com.thaiopensource.validate.Option;
6 import com.thaiopensource.validate.FlagOption;
7 import com.thaiopensource.validate.StringOption;
8 import com.thaiopensource.validate.OptionArgumentFormatException;
9 import com.thaiopensource.validate.SchemaReader;
10 import com.thaiopensource.xml.util.Naming;
11
12 /**
13  * Properties for controlling schema reading and validation specific to Schematron.
14  */

15 public class SchematronProperty {
16   private SchematronProperty() { }
17
18   /**
19    * PropertyId that specifies the Schematron phase to use.
20    * This applies during schema creation.
21    */

22   public static final StringPropertyId PHASE = new StringPropertyId("PHASE");
23
24   static public class PhaseOption extends StringOption {
25     private PhaseOption() {
26       super(PHASE);
27     }
28
29     public String JavaDoc normalize(String JavaDoc value) throws OptionArgumentFormatException {
30       value = value.trim();
31       if (!value.equals("#ALL") && !Naming.isNcname(value))
32         throw new OptionArgumentFormatException();
33       return value;
34     }
35   }
36
37   public static final StringOption PHASE_OPTION = new PhaseOption();
38
39   /**
40    * PropertyId thats specifies that diagnostic messages should be included.
41    * This applies during validation.
42    */

43   public static final FlagPropertyId DIAGNOSE = new FlagPropertyId("DIAGNOSE");
44
45   public static Option getOption(String JavaDoc uri) {
46     if (!uri.startsWith(SchemaReader.BASE_URI))
47       return null;
48     uri = uri.substring(SchemaReader.BASE_URI.length());
49     if (uri.equals("diagnose"))
50       return new FlagOption(DIAGNOSE);
51     if (uri.equals("phase"))
52       return PHASE_OPTION;
53     return null;
54   }
55 }
56
Popular Tags