Package com.sun.msv.datatype.xsd

Examples of com.sun.msv.datatype.xsd.XSDatatype


            return Expression.nullSet;
        }
       
        // we need a special handling for built-in types
        if(reader.isSchemaNamespace(baseTypeName[0])) {
            XSDatatype dt = reader.resolveBuiltinDataType(baseTypeName[1]);
            if(dt!=null) {
                XSDatatypeExp dtexp = new XSDatatypeExp(dt,reader.pool);
                parentDecl.simpleBaseType = dtexp;
                return dtexp;
            }
View Full Code Here


     *        null if the type is not defined.
     */
    public SimpleTypeExp resolveBuiltinSimpleType( String typeLocalName ) {
        // datatypes of XML Schema part 2
        try {
            XSDatatype dt = DatatypeFactory.getTypeByName(typeLocalName);
            SimpleTypeExp sexp = xsdSchema.simpleTypes.getOrCreate(typeLocalName);
            if(!sexp.isDefined())
                sexp.set( new XSDatatypeExp(dt,pool) );
            return sexp;
        } catch( DatatypeException e ) {
View Full Code Here

            return  new XSDatatypeExp(StringType.theInstance,pool);
        }
       
        if( isSchemaNamespace(r[0]) ) {
            // internal definitions should be consulted first.
            XSDatatype dt = resolveBuiltinDataType(r[1]);
            if(dt!=null) return new XSDatatypeExp(dt,pool);
           
            // the name was not found.
            // maybe we are parsing schema for schema.
            // consult the externally defined types.
View Full Code Here

       
        return new Type(){
            public int getDerivationMethod() { return ComplexTypeExp.RESTRICTION; }
            public int getBlockValue() { return 0; }
            public Type getBaseType() {
                XSDatatype base = dt.getBaseType();
                if(base==null)    return getType(complexUrType);
                else            return getType(base);
            }
            public Object getCore() { return dt; }
        };
View Full Code Here

            // then try as a built-in type
            // if this method fails, it throws an exception
            return new XSDatatypeExp( DatatypeFactory.getTypeByName(typeName), pool );
        } catch( DatatypeException e ) {
           
            XSDatatype dt = getBackwardCompatibleType(typeName);
           
            if(typeName.equals("none"))         dt = NoneType.theInstance;
            if(typeName.equals("emptyString"))  dt = EmptyStringType.theInstance;
           
            if(dt==null) {
View Full Code Here

                incubator = new XSDatatypeExp(StringType.theInstance,reader.pool).createIncubator();
            } else {
               
                // we need a special handling for built-in types
                if(reader.isSchemaNamespace(baseTypeName[0])) {
                    XSDatatype dt = reader.resolveBuiltinDataType(baseTypeName[1]);
                    if(dt!=null)
                        incubator = new XSDatatypeExp(dt,reader.pool).createIncubator();
                   
                    // maybe we are parsing the schema for schema.
                    // consult externally specified schema.
View Full Code Here

        }
       

        // we need a special handling for built-in types
        if(reader.isSchemaNamespace(baseTypeName[0])) {
            XSDatatype dt = reader.resolveBuiltinDataType(baseTypeName[1]);
            if(dt!=null) {
                parentDecl.simpleBaseType = new XSDatatypeExp(dt,reader.pool);
                return exp;
            }
        }
View Full Code Here

            return dti.convertToLexicalValue(items[random.nextInt(items.length)],context);
          } catch( Exception x ) { ; }
        }
      }
     
      XSDatatype baseType = dti.getConcreteType();
     
      if( baseType instanceof ListType )
        return generateList(dti,context);
      if( baseType instanceof UnionType )
        return generateUnion((UnionType)baseType,context);
View Full Code Here

        Set appliedFacets = new HashSet();

        // store effective facets (those which are not shadowed by another facet).
        Vector effectiveFacets = new Vector();

        XSDatatype x = dt;
        while (x instanceof DataTypeWithFacet || x instanceof FinalComponent) {

            if (x instanceof FinalComponent) {
                // skip FinalComponent
                x = x.getBaseType();
                continue;
            }

            String facetName = ((DataTypeWithFacet)x).facetName;

            if (facetName.equals(XSDatatypeImpl.FACET_ENUMERATION)) {
                // if it contains enumeration, then we will serialize this
                // by using <value>s.
                serializeEnumeration((XSDatatypeImpl)dt, (EnumerationFacet)x);
                return;
            }

            if (facetName.equals(XSDatatypeImpl.FACET_WHITESPACE)) {
                // TODO: better error handling
                System.err.println("warning: unsupported whiteSpace facet is ignored");
                x = x.getBaseType();
                continue;
            }

            // find the same facet twice.
            // pattern is allowed more than once.
            if (!appliedFacets.contains(facetName) || appliedFacets.equals(XSDatatypeImpl.FACET_PATTERN)) {

                appliedFacets.add(facetName);
                effectiveFacets.add(x);
            }

            x = ((DataTypeWithFacet)x).baseType;
        }

        if (x instanceof ListType) {
            // the base type is list.
            serializeListType((XSDatatypeImpl)dt);
            return;
        }

        // it cannot be the union type. Union type cannot be derived by
        // restriction.

        // so this must be one of the pre-defined types.
        if (!(x instanceof ConcreteType))
            throw new Error(x.getClass().getName());

        if (x instanceof com.sun.msv.grammar.relax.EmptyStringType) {
            // empty token will do.
            writer.element("value");
            return;
        }
        if (x instanceof com.sun.msv.grammar.relax.NoneType) {
            // "none" is equal to <notAllowed/>
            writer.element("notAllowed");
            return;
        }

        writer.start("data", new String[] { "type", x.getName()});

        // serialize effective facets
        for (int i = effectiveFacets.size() - 1; i >= 0; i--) {
            DataTypeWithFacet dtf = (DataTypeWithFacet)effectiveFacets.get(i);
View Full Code Here

            unless it's absolutely necessary, so that the class loader doesn't load
            the datatype class easily.
       
            If we use a map, it makes the class loader loads all classes.
        */
        XSDatatype dt = null;
       
        if( typeName.equals("uriReference") )
            dt = com.sun.msv.datatype.xsd.AnyURIType.theInstance;
        else
        if( typeName.equals("number") )
            dt = com.sun.msv.datatype.xsd.NumberType.theInstance;
        else
        if( typeName.equals("timeDuration") )
            dt = com.sun.msv.datatype.xsd.DurationType.theInstance;
        else
        if( typeName.equals("CDATA") )
            dt = com.sun.msv.datatype.xsd.NormalizedStringType.theInstance;
        else
        if( typeName.equals("year") )
            dt = com.sun.msv.datatype.xsd.GYearType.theInstance;
        else
        if( typeName.equals("yearMonth") )
            dt = com.sun.msv.datatype.xsd.GYearMonthType.theInstance;
        else
        if( typeName.equals("month") )
            dt = com.sun.msv.datatype.xsd.GMonthType.theInstance;
        else
        if( typeName.equals("monthDay") )
            dt = com.sun.msv.datatype.xsd.GMonthDayType.theInstance;
        else
        if( typeName.equals("day") )
            dt = com.sun.msv.datatype.xsd.GDayType.theInstance;

        if( dt!=null )
            reportWarning( WRN_DEPRECATED_TYPENAME, typeName, dt.displayName() );
       
        return dt;
    }
View Full Code Here

TOP

Related Classes of com.sun.msv.datatype.xsd.XSDatatype

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.