Hi,

        Modified 'SimpleTypeUsage' for the support added in DV implementation 
for fundamental facet, shows how to get information about the different 
fundamental facet 'ordered', 'numeric', 'bounded', 'cardinality' schema 
components.


--
regards,
Neeraj Bajaj
Sun Microsystems, inc.

Phone: 080-2298989 x87425.


[Attatched File1 : SimpleTypeUsage.java
Attatched File2 : patch_SimpleTypeUsage]



> Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm
> list-help: <mailto:[EMAIL PROTECTED]>
> list-unsubscribe: <mailto:[EMAIL PROTECTED]>
> list-post: <mailto:[EMAIL PROTECTED]>
> Delivered-To: mailing list [EMAIL PROTECTED]
> Date: Sat, 22 Dec 2001 01:55:45 +0000 (Asia/Calcutta)
> From: Neeraj Bajaj <[EMAIL PROTECTED]>
> Subject: 'SimpleTypeUsage' class
> To: [EMAIL PROTECTED]
> X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N
> 
> Hi, 
>       Please find attatched 'SimpleTypeUsage' class to be put in 'samples' 
> package.
> 
> It demonstrates how to use the new simple type interfaces defined in 
> 'org.apache.xerces.impl.dv' package for the purpose of,
> 
>    1. how to query property information of Simple Type Definition Schema 
Component 
> as defined,
>   http://www.w3.org/TR/xmlschema-1/#Simple_Type_Definition_details
>   
>   2. how to get instance of particular SchemaDVFactory implementation.
>   3. how to get built-in type/s and create new types as derived by 
restriction, 
> list or union, using factory methods of SchemaDVFactory.
>   4. how to use those simple type (built-in/created) to validate the values.
>   
>      This class will be useful for any application which wants to use the 
simple 
> type implementation directly as separate module.
>       
>       this example will also be chagned as more PSVI support (information 
about 
> fundamental facets) is added in simple type implementation.
>        
> thanks,
> Neeraj Bajaj
> Sun Microsystems, inc.
> 
> Phone: 080-2298989 x87425.
> 
> 

Attachment: SimpleTypeUsage.java
Description: SimpleTypeUsage.java

101,103c101,103
<       //suppose application wants to use class 'MySchemaDVFactoryImpl' as 
SchemaDVFactory
<   // implementation which resides in say 'myApp.simpleType' package.
< 
---
>       //Suppose application wants to use class 'MySchemaDVFactoryImpl' as 
>SchemaDVFactory
>         // implementation which resides in say 'myApp.simpleType' package.
>     
107c107
<   // in 'org.apache.xerces.impl.dv.xs_new' package.
---
>         // in 'org.apache.xerces.impl.dv.xs_new' package.
131c131
<     String name = "myString";
---
>     String name = "myString1";
202a203,207
> public ValidatedInfo validateObject(Object value, XSSimpleType simpleType){
> 
> return new ValidatedInfo();
> }
> 
281,282c286,287
<     System.err.println("'base type definition' name \t: " + baseType.getTypeName()   
);
<     System.err.println("'base type definition' target namespace : " + 
baseType.getTargetNamespace());
---
>     System.err.println("'base type definition' name \t: " + ( baseType != null ? 
>baseType.getTypeName() : "null" )   );
>     System.err.println("'base type definition' target namespace : " + ( baseType != 
>null ? baseType.getTypeName() : "null" )   );
285c290
<     if(baseType.getXSType() == XSTypeDecl.SIMPLE_TYPE ){
---
>     if(baseType != null && (baseType.getXSType() == XSTypeDecl.SIMPLE_TYPE) ){
309a315,320
>     
>     //fundamental facet information
>     
>     //ordered schema component
>     short ordered = simpleType.getOrderedFacet();
>     printOrdered(ordered);
310a322,343
>     //bounded schema component
>     boolean bounded = simpleType.isBounded();    
>     if(bounded){
>         System.err.println("'bounded' \t\t\t\t: true"  );
>     }
>     else{
>         System.err.println("'bounded' \t\t\t\t: false"  );
>     }
>     
>     //cardinality schema component
>     short cardinality = simpleType.getCardinalityFacet();
>     printCardinality(cardinality);
>     
>     //numeric schema component
>     boolean numeric = simpleType.isNumeric();
>     if(numeric){
>         System.err.println("'numeric' \t\t\t\t: true"  );
>     }
>     else{
>         System.err.println("'numeric' \t\t\t\t: false"  );
>     }
>     
311a345
> 
313a348,375
> void printOrdered (short ordered){
> 
>     switch(ordered){
>     
>         case XSSimpleType.ORDERED_FALSE:
>             System.err.println("'ordered' \t\t\t\t: false"  );
>             break;
>             
>         case XSSimpleType.ORDERED_PARTIAL:
>             System.err.println("'ordered' \t\t\t\t: partial"  );
>             break;
>             
>         case XSSimpleType.ORDERED_TOTAL:
>             System.err.println("'ordered' \t\t\t\t: total"  );
>             break;
>             
>     }
> }//printOrdered()
> 
> void printCardinality (short cardinality){
>     
> if(cardinality == XSSimpleType.CARDINALITY_COUNTABLY_INFINITE){
>     System.err.println("'cardinality' \t\t\t\t: countably infinite"  );
> }else if(cardinality == XSSimpleType.CARDINALITY_FINITE)
>     System.err.println("'cardinality' \t\t\t\t: finite"  );
> 
> }//printCardinality()
> 
408,421c470,474
<     if(args.length == 1 ){
<         if(args[0].startsWith("sampleType")){
<             //querying the property information of Simple Type Definition Schema 
Component as derived by restriction
<             XSSimpleType st = usage.deriveByRestriction() ;
<             usage.querySimpleType(st);
< 
<         }else{
<             XSSimpleType stringType = factory.getBuiltInType(args[0]);
<             if(stringType == null){
<                 System.err.println("Invalid built-in Simple datatype given as 
argument.");
<             }
<             else {
<                 usage.querySimpleType(stringType);
<             }
---
>     if(args.length == 1 ){         
>         XSSimpleType builtInType = factory.getBuiltInType(args[0]);
>         if(builtInType == null){
>             System.err.println("Invalid built-in Simple datatype given as 
>argument.");
>             printUsage();
422a476,478
>         else {
>             usage.querySimpleType(builtInType);
>         }
431c487
<         System.err.println("usage: java simpletype.SimpleTypeUsage  (options) ");
---
>         System.err.println("usage: java simpletype.SimpleTypeUsage  
>'Built-InDatatypeName' ");
433d488
<         System.err.println("options :");
435,437c490
<         System.err.println("  built-inType  \t\tprints information about built-in 
datatype.");
<         System.err.println("  sampleType    \t\tprints information about a simple 
type derived by restriction.");
< 
---
>         System.err.println("  Built-InDatatypeName  \t\tBuilt-In Datatype name as 
>defined by w3c schema spec \n <a href = 
>'http://www.w3.org/TR/xmlschema-2/#built-in-datatypes'> XML Schema  part 2: Datatypes 
></a>.");        
439,442d491
<         System.err.println(" For example  'java simpletype.SimpleTypeUsage  decimal' 
gives");
<         System.err.println(" information about the built-in datatype 'decimal' as 
defined by w3c-spec");
<         System.err.println(" http://www.w3.org/TR/xmlschema-2/#decimal";);
<         System.err.println();

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to