Package org.relaxng.datatype

Examples of org.relaxng.datatype.Datatype


      error("unrecognized_datatype_library", datatypeLibrary, (Locator)loc);
    else {
      try {
        DatatypeBuilder dtb = dl.createDatatypeBuilder(type);
        try {
          Datatype dt = dtb.createDatatype();
          Object obj = dt.createValue(value, new ValidationContextImpl(context, ns));
          if (obj != null)
            return pb.makeValue(dt, obj);
          error("invalid_value", value, (Locator)loc);
        }
        catch (DatatypeException e) {
View Full Code Here


*/
public class DatatypeDeserializer {
    public static Datatype deserialize( String str ) {
        try {
            ObjectInputStream ois = new ObjectInputStream( new StringInputStream(str) );
            Datatype dt = (Datatype)ois.readObject();
            ois.close();
       
            return dt;
        } catch( IOException e ) {
            throw new InternalError(e.getMessage());
View Full Code Here

        if(!(body instanceof DataExp ))                    return;
       
        SimpleNameClass snc = (SimpleNameClass)exp.nameClass;
        if(!snc.namespaceURI.equals(""))    return;
       
        Datatype dt = ((DataExp)body).dt;
        if( dt==IDType.theInstance || dt==IDREFType.theInstance ) {
            if( currentTagName==null
                // complex attribute name is used.
                // ID/IDREF must have an unique attribute name
            ||  overloadedNames.contains(currentTagName) )
View Full Code Here

        String elementName, String attributeName, String attributeType,
        String[] enums, short attributeUse, String defaultValue )
            throws SAXException {
       
        // create Datatype that validates attribute value.
        Datatype dt = createDatatype(attributeType);
       
        StringPair str = new StringPair("",attributeType);
       
        if(enums!=null) {
            Expression exp = Expression.nullSet;
            for( int i=0; i<enums.length; i++ )
                exp = grammar.pool.createChoice( exp,
                    grammar.pool.createValue(dt,str,
                        dt.createValue(enums[i],null)));
            return exp;
        }
   
        if( attributeUse == USE_FIXED ) {
            return grammar.pool.createValue(dt,str,
                dt.createValue(defaultValue,null));
        }
       
        return grammar.pool.createData(dt,str);
    }
View Full Code Here

   
    protected Expression makeExpression() {
        final RELAXNGReader reader = (RELAXNGReader)this.reader;
        String typeName = startTag.getCollapsedAttribute("type");
       
        Datatype type;
       
        StringPair typeFullName;
       
        if(typeName==null) {
            try {
                // defaults to built-in token type.
                type = reader.resolveDataTypeLibrary("").createDatatype("token");
                typeFullName = new StringPair("","token");
            } catch( DatatypeException e ) {
                // since token is the built-in datatype,
                // this can't happen
                e.printStackTrace();
                throw new InternalError();
            }
        } else {
            type = reader.resolveDataType(typeName);
            typeFullName = new StringPair(reader.datatypeLibURI,typeName);
        }
       
        Object value = type.createValue(text.toString(),reader);
        if( value==null ) {
            // this is not a good value for this type.
            reader.reportError( RELAXNGReader.ERR_BAD_DATA_VALUE, typeName, text.toString().trim() );
            return Expression.nullSet;    // recover by returning something.
        }
View Full Code Here

           
        throw new UnsupportedOperationException( exp.dt.getClass().getName() );
    }
       
    public void onData(DataExp exp) {
        Datatype dt = exp.dt;

        if (dt instanceof XSDatatypeImpl) {
            XSDatatypeImpl dti = (XSDatatypeImpl)dt;

            if (isPredefinedType(dt)) {
                // it's a pre-defined types.
                writer.element("data", new String[] { "type", dti.getName()});
            } else {
                serializeDataType(dti);
            }
            return;
        }

        // unknown datatype
        writer.element("data-unknown", new String[] { "class", dt.getClass().getName()});
    }
View Full Code Here

                                throws SAXException {
        super.endElement(namespaceUri,localName,qName);
       
        // getLastCharacterType may sometimes return null. For example,
        // 1) this element should be empty and there was only whitespace characters.
        Datatype dt;
        Datatype[] lastType = getLastCharacterType();
        if( lastType==null || lastType.length==0 )    dt = null;
        else                                        dt = getLastCharacterType()[0];
           
        // call matchers
View Full Code Here

      error("unrecognized_datatype_library", datatypeLibrary, (Locator)loc);
    else {
      try {
        DatatypeBuilder dtb = dl.createDatatypeBuilder(type);
        try {
          Datatype dt = dtb.createDatatype();
          Object obj = dt.createValue(value, new ValidationContextImpl(context, ns));
          if (obj != null)
            return pb.makeValue(dt, obj);
          error("invalid_value", value, (Locator)loc);
        }
        catch (DatatypeException e) {
View Full Code Here

      error("unrecognized_datatype_library", datatypeLibrary, (Locator)loc);
    else {
      try {
        DatatypeBuilder dtb = dl.createDatatypeBuilder(type);
        try {
          Datatype dt = dtb.createDatatype();
          Object obj = dt.createValue(value, new ValidationContextImpl(context, ns));
          if (obj != null)
            return pb.makeValue(dt, obj);
          error("invalid_value", value, (Locator)loc);
        }
        catch (DatatypeException e) {
View Full Code Here

                return new DatatypeBuilder() {
                    public void addParameter(String s, String s1, ValidationContext validationContext) throws DatatypeException {
                    }

                    public Datatype createDatatype() throws DatatypeException {
                        return new Datatype() {

                            public boolean isValid(String s, ValidationContext validationContext) {
                                return false;
                            }
View Full Code Here

TOP

Related Classes of org.relaxng.datatype.Datatype

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.