Package org.relaxng.datatype

Examples of org.relaxng.datatype.DatatypeException


        name = theCollapse.process(name);
        if (name.equals("preserve"))    return thePreserve;
        if (name.equals("collapse"))    return theCollapse;
        if (name.equals("replace"))     return theReplace;

        throw new DatatypeException(XSDatatypeImpl.localize(XSDatatypeImpl.ERR_INVALID_WHITESPACE_VALUE, name));
    }
View Full Code Here


        this.maxLength = _maxLength;

        // loosened facet check
        DataTypeWithFacet o = baseType.getFacetObject(FACET_MAXLENGTH);
        if(o!=null && ((MaxLengthFacet)o).maxLength < this.maxLength )
            throw new DatatypeException( localize( ERR_LOOSENED_FACET,
                FACET_MAXLENGTH, o.displayName() ) );
       
        // consistency with minLength is checked in XSDatatypeImpl.derive method.
    }
View Full Code Here

        // this method is never called.
        if(o==null)    throw new IllegalStateException();    // assertion
       
        int cnt = ((Discrete)concreteType).countLength(o);
        if(cnt>maxLength)
            throw new DatatypeException( DatatypeException.UNKNOWN,
                localize(ERR_MAXLENGTH, new Integer(cnt), new Integer(maxLength)) );
    }
View Full Code Here

                for( int i=1; i<members.length; i++ )
                    r+= "/\""+members[i].toString()+"\"";
               
                r = "("+r+")";    // oh, don't tell me I should use StringBuffer.
               
                throw new DatatypeException( DatatypeException.UNKNOWN,
                    localize(ERR_ENUMERATION_WITH_ARG, r) );
            }
        }
        throw new DatatypeException( DatatypeException.UNKNOWN,
            localize(ERR_ENUMERATION) );
    }
View Full Code Here

        }
       
        dt = (XSDatatype)builtinType.get(dataTypeName);
        if(dt!=null)        return dt;
       
        throw new DatatypeException("undefined type name:"+dataTypeName);
    }
View Full Code Here

    public ListType( String nsUri, String newTypeName, XSDatatypeImpl itemType ) throws DatatypeException {
        super(nsUri,newTypeName);
       
        if(itemType.isFinal( DERIVATION_BY_LIST ))
            // derivation by list is not applicable
            throw new DatatypeException( localize(ERR_INVALID_ITEMTYPE) );
       
        this.itemType = itemType;
    }
View Full Code Here

        length = _length;
       
        // loosened facet check
        DataTypeWithFacet o = baseType.getFacetObject(FACET_LENGTH);
        if(o!=null && ((LengthFacet)o).length != this.length )
            throw new DatatypeException(
                localize(ERR_LOOSENED_FACET, FACET_LENGTH, o.displayName() ) );
       
        // consistency with minLength/maxLength is checked in XSDatatypeImpl.derive method.
    }
View Full Code Here

        // this method is never called.
        if(o==null)    throw new IllegalStateException();    // assertion
       
        int cnt = ((Discrete)concreteType).countLength(o);
        if(cnt!=length)
            throw new DatatypeException( DatatypeException.UNKNOWN,
                localize(ERR_LENGTH, new Integer(cnt), new Integer(length)) );
    }
View Full Code Here

                // to issue an error, we need to first make sure that the
                // specified value is different from the fixed value.
                //            throw new DatatypeException( XSDatatypeImpl.localize(
                //                XSDatatypeImpl.ERR_OVERRIDING_FIXED_FACET, name ) );
            case XSDatatypeImpl.NOT_ALLOWED :
                throw new DatatypeException(XSDatatypeImpl.localize(XSDatatypeImpl.ERR_NOT_APPLICABLE_FACET, name));
            default :
                throw new Error(); // assertion failed
        }

        Object value;

        if (isValueFacet(name)) {
            value = baseType.createValue(strValue, context);
            if (value == null)
                throw new DatatypeException(
                    XSDatatypeImpl.localize(
                        XSDatatypeImpl.ERR_INVALID_VALUE_FOR_THIS_TYPE,
                        strValue,
                        baseType.displayName()));
        } else
            value = strValue;

        if (isRepeatable(name)) {
            FacetInfo fi;
            if (impl.containsKey(name))
                fi = (FacetInfo)impl.get(name);
            else
                impl.put(name, fi = new FacetInfo(new Vector(), fixed));

            ((Vector)fi.value).add(value);
            // TODO : what shall we do if
            // <enumeration value="a" fixed="true" />
            // <enumeration value="b" fixed="false" />
            fi.fixed |= fixed;
        } else {
            if (impl.containsKey(name))
                throw new DatatypeException(XSDatatypeImpl.localize(XSDatatypeImpl.ERR_DUPLICATE_FACET, name));
            impl.put(name, new FacetInfo(value, fixed));
        }
    }
View Full Code Here

        if (baseType instanceof ErrorType)
            return baseType;

        if (baseType.isFinal(XSDatatype.DERIVATION_BY_RESTRICTION))
            throw new DatatypeException(
                XSDatatypeImpl.localize(XSDatatypeImpl.ERR_INVALID_BASE_TYPE, baseType.displayName()));

        if (isEmpty()) {
            // if no facet is specified, and user wants anonymous type,
            // then no need to create another object.
            // TODO: for the type-derivation-OK test to work correctly,
            // maybe we need to wrap this by a FinalComponent.
            if (newNameUri == null && newLocalName == null)
                return baseType;

            // using FinalComponent as a wrapper,
            // so that the new type object can have its own name.
            return new FinalComponent(newNameUri, newLocalName, baseType, 0);
        }

        XSDatatypeImpl r = baseType; // start from current datatype

        // TODO : make sure that the following interpretation is true
        /*
            several facet consistency check is done here.
            those which are done in this time are:
       
                - length and (minLength/maxLength) are exclusive
                - maxInclusive and maxExclusive are exclusive
                - minInclusive and minExclusive are exclusive
       
       
            those are exclusive within the one restriction;
            that is, it is legal to derive types in the following way:
       
            <simpleType name="foo">
                <restriction baseType="string">
                    <minLength value="3" />
                </restrction>
            </simpleType>
       
            <simpleType name="bar">
                <restriction baseType="foo">
                    <length value="5" />
                </restrction>
            </simpleType>
       
            although the following is considered as an error
       
            <simpleType name="bar">
                <restriction baseType="foo">
                    <length value="5" />
                    <minLength value="3" />
                </restrction>
            </simpleType>
       
       
            This method is the perfect place to perform this kind of check.
        */

        // makes sure that no mutually exclusive facets are specified
        for (int i = 0; i < exclusiveFacetPairs.length; i++)
            if (contains(exclusiveFacetPairs[i][0]) && contains(exclusiveFacetPairs[i][1]))
                throw new DatatypeException(
                    XSDatatypeImpl.localize(
                        XSDatatypeImpl.ERR_X_AND_Y_ARE_EXCLUSIVE,
                        exclusiveFacetPairs[i][0],
                        exclusiveFacetPairs[i][1]));

View Full Code Here

TOP

Related Classes of org.relaxng.datatype.DatatypeException

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.