Package org.relaxng.datatype

Examples of org.relaxng.datatype.Datatype


                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


    /**
     * @param args
     * @throws DatatypeException
     */
    public static void main(String[] args) throws DatatypeException {
        Datatype dt = (new Html5DatatypeLibrary()).createDatatype("iri");
        dt.checkValid("DaTa:,\u00e4", null);
    }
View Full Code Here

      // if this exp is already wrapped, use it instead of creating another one.
      // this will reduce the size of the LL grammar for data-binding.
      return (Expression)primitiveItems.get(exp);
    else {
      // if this is the first time, wrap it and memorize it.
      Datatype dt = exp.getType();
     
      PrimitiveItem p = new PrimitiveItem(
        (dt instanceof DatabindableDatatype)?(DatabindableDatatype)dt:null,
        (Expression)exp);
      primitiveItems.put( exp, p );
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

      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

   
    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

                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

            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

                                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

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.