Search in sources :

Example 1 with XercesFloatUserDefined

use of org.eclipse.wst.xml.xpath2.processor.testsuite.userdefined.XercesFloatUserDefined in project webtools.sourceediting by eclipse.

the class XercesFloatUserDefined method constructor.

public ResultSequence constructor(ResultSequence arg) throws DynamicError {
    ResultSequence rs = ResultSequenceFactory.create_new();
    if (arg.empty())
        return rs;
    // AnyAtomicType aat = (AnyAtomicType) arg.first();
    AnyType aat = arg.first();
    XSSimpleTypeDefinition simpletype = (XSSimpleTypeDefinition) typeInfo;
    if (simpletype != null) {
        if (simpletype.isDefinedFacet(XSSimpleTypeDefinition.FACET_MININCLUSIVE)) {
            String minValue = simpletype.getLexicalFacetValue(XSSimpleTypeDefinition.FACET_MININCLUSIVE);
            float iminValue = Float.parseFloat(minValue);
            float actualValue = Float.parseFloat(aat.getStringValue());
            if (actualValue < iminValue) {
                throw DynamicError.invalidForCastConstructor();
            }
        }
        if (simpletype.isDefinedFacet(XSSimpleTypeDefinition.FACET_MAXINCLUSIVE)) {
            String maxValue = simpletype.getLexicalFacetValue(XSSimpleTypeDefinition.FACET_MAXINCLUSIVE);
            float imaxValue = Float.parseFloat(maxValue);
            float actualValue = Float.parseFloat(aat.getStringValue());
            if (actualValue > imaxValue) {
                throw DynamicError.invalidForCastConstructor();
            }
        }
    }
    rs.add(new XercesFloatUserDefined(Float.parseFloat(aat.getStringValue())));
    return rs;
}
Also used : ResultSequence(org.eclipse.wst.xml.xpath2.processor.ResultSequence) AnyType(org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType) XSSimpleTypeDefinition(org.apache.xerces.xs.XSSimpleTypeDefinition)

Example 2 with XercesFloatUserDefined

use of org.eclipse.wst.xml.xpath2.processor.testsuite.userdefined.XercesFloatUserDefined in project webtools.sourceediting by eclipse.

the class AbstractPsychoPathTest method addUserDefinedSimpleTypes.

protected void addUserDefinedSimpleTypes(XSModel schema) {
    XSNamedMap xstypes = schema.getComponents(XSConstants.TYPE_DEFINITION);
    if (xstypes.getLength() == 0) {
        return;
    }
    addNamespace("myType", "http://www.w3.org/XQueryTest/userDefinedTypes");
    UserDefinedCtrLibrary udl = new UserDefinedCtrLibrary("http://www.w3.org/XQueryTest/userDefinedTypes");
    for (int i = 0; i < xstypes.getLength(); i++) {
        XSObject xsobject = xstypes.item(i);
        if ("http://www.w3.org/XQueryTest/userDefinedTypes".equals(xsobject.getNamespace())) {
            if (xsobject instanceof XSSimpleTypeDefinition) {
                XSSimpleTypeDefinition typeDef = (XSSimpleTypeDefinition) xsobject;
                if (typeDef.getNumeric()) {
                    if (xsobject.getName().equals("floatBased") || xsobject.getName().equals("shoesize")) {
                        XercesFloatUserDefined fudt = new XercesFloatUserDefined(xsobject);
                        udl.add_type(fudt);
                    } else {
                        XercesIntegerUserDefined iudt = new XercesIntegerUserDefined(xsobject);
                        udl.add_type(iudt);
                    }
                } else {
                    if (xsobject.getName().equals("QNameBased")) {
                        XercesQNameUserDefined qudt = new XercesQNameUserDefined(xsobject);
                        udl.add_type(qudt);
                    } else {
                        XercesUserDefined udt = new XercesUserDefined(typeDef);
                        udl.add_type(udt);
                    }
                }
            }
        }
    }
    addFunctionLibrary(udl);
}
Also used : XercesIntegerUserDefined(org.eclipse.wst.xml.xpath2.processor.testsuite.userdefined.XercesIntegerUserDefined) XercesFloatUserDefined(org.eclipse.wst.xml.xpath2.processor.testsuite.userdefined.XercesFloatUserDefined) XSObject(org.apache.xerces.xs.XSObject) XSNamedMap(org.apache.xerces.xs.XSNamedMap) UserDefinedCtrLibrary(org.eclipse.wst.xml.xpath2.processor.internal.types.userdefined.UserDefinedCtrLibrary) XercesUserDefined(org.eclipse.wst.xml.xpath2.processor.testsuite.userdefined.XercesUserDefined) XSSimpleTypeDefinition(org.apache.xerces.xs.XSSimpleTypeDefinition) XercesQNameUserDefined(org.eclipse.wst.xml.xpath2.processor.testsuite.userdefined.XercesQNameUserDefined)

Aggregations

XSSimpleTypeDefinition (org.apache.xerces.xs.XSSimpleTypeDefinition)2 XSNamedMap (org.apache.xerces.xs.XSNamedMap)1 XSObject (org.apache.xerces.xs.XSObject)1 ResultSequence (org.eclipse.wst.xml.xpath2.processor.ResultSequence)1 AnyType (org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType)1 UserDefinedCtrLibrary (org.eclipse.wst.xml.xpath2.processor.internal.types.userdefined.UserDefinedCtrLibrary)1 XercesFloatUserDefined (org.eclipse.wst.xml.xpath2.processor.testsuite.userdefined.XercesFloatUserDefined)1 XercesIntegerUserDefined (org.eclipse.wst.xml.xpath2.processor.testsuite.userdefined.XercesIntegerUserDefined)1 XercesQNameUserDefined (org.eclipse.wst.xml.xpath2.processor.testsuite.userdefined.XercesQNameUserDefined)1 XercesUserDefined (org.eclipse.wst.xml.xpath2.processor.testsuite.userdefined.XercesUserDefined)1