Examples of XSAssertImpl


Examples of org.apache.xerces.impl.xs.assertion.XSAssertImpl

                    attrTypeVariety = XSSimpleTypeDefinition.VARIETY_UNION;
                    // Special handling for assertions on "simpleType -> union" cases. Adding an assertion here,
                    // for determining the XSModel NamespaceContext. This particular assertion object is not
                    // actually evaluated. For simpleType's with variety union, assertions are later again determined
                    // in XMLAssertPsychopathImpl, which are evaluated to determine validity of an XML instance.              
                    XSAssertImpl assertImpl = getFirstAssertFromUnionMemberTypes(attrType.getMemberTypes());
                    if (assertImpl != null) {
                        assertImpl.setTypeDefinition(attrType);
                        assertImpl.setVariety(attrTypeVariety);
                        assertImpl.setAttrName(attributes.getLocalName(attrIndx));
                        assertImpl.setAttrValue(attributes.getValue(attrIndx));
                        attrAssertList.addXSObject(assertImpl);
                    }
                }

                // iterate all the schema facets for attributes having the simpleType variety "atomic | list", and
                // accumulate assertions from them.
                for (int facetIdx = 0; facetIdx < facets.getLength(); facetIdx++) {
                    XSMultiValueFacet facet = (XSMultiValueFacet) facets.item(facetIdx);
                    if (facet.getFacetKind() == XSSimpleTypeDefinition.FACET_ASSERT) {
                        Vector attrAsserts = facet.getAsserts();
                        for (int j = 0; j < attrAsserts.size(); j++) {
                            XSAssertImpl attrAssert = (XSAssertImpl) attrAsserts.elementAt(j);
                            attrAssert.setAttrName(attributes.getLocalName(attrIndx));
                            attrAssert.setAttrValue(attributes.getValue(attrIndx));
                            attrAssert.setVariety(attrTypeVariety);                               
                            attrAssertList.addXSObject(attrAssert);   
                        }
                        // break from the for loop
                        break;
                    }
View Full Code Here

Examples of org.apache.xerces.impl.xs.assertion.XSAssertImpl

            facets = (XSObjectListImpl) simpleTypeDef.getItemType().getMultiValueFacets();   
        }
        else if (simpleTypeDef.getVariety() == XSSimpleTypeDefinition.VARIETY_UNION) {
            // Special handling for assertions on "simpleType -> union" cases. Adding an assertion here,
            // for determining the NamespaceContext.
            XSAssertImpl assertImpl = getFirstAssertFromUnionMemberTypes(simpleTypeDef.getMemberTypes());
            if (assertImpl != null) {
                simpleTypeAsserts = new Vector();
                simpleTypeAsserts.add(assertImpl);
            }
        }
View Full Code Here

Examples of org.apache.xerces.impl.xs.assertion.XSAssertImpl

     * Get the 1st assertion from the member types of simpleType having variety union. Needed to get an schema
     * "namespace context", which is available for example, in the 1st assertion in the assertions list.
     */
    private XSAssertImpl getFirstAssertFromUnionMemberTypes(XSObjectList memberTypes) {
       
        XSAssertImpl assertImpl = null;
       
        for (int memberTypeIdx = 0; memberTypeIdx < memberTypes.getLength(); memberTypeIdx++) {
            XSSimpleTypeDefinition memType = (XSSimpleTypeDefinition) memberTypes.item(memberTypeIdx);
            if (!SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(memType.getNamespace())) {
                XSObjectList memberTypeFacets = memType.getMultiValueFacets();
View Full Code Here

Examples of org.apache.xerces.impl.xs.assertion.XSAssertImpl

                        //if no annotations are present add an empty list to the assertion
                        annotations = XSObjectListImpl.EMPTY_LIST;
                    }
                   
                    // create an assertion object
                    XSAssertImpl assertImpl = new XSAssertImpl(typeDef,
                                                           annotations,
                                                           fSchemaHandler);
                    Test testExpr = new Test(new XPath20Assert(test, fSymbolTable,
                                             new SchemaNamespaceSupport(schemaDoc.
                                             fNamespaceSupport)), assertImpl);                
                    assertImpl.setAssertKind(XSConstants.ASSERTION_FACET);
                    assertImpl.setTest(testExpr);
                    assertImpl.setXPathDefaultNamespace(xpathDefaultNamespace);
                    assertImpl.setXPath2NamespaceContext(new SchemaNamespaceSupport
                                                     (schemaDoc.fNamespaceSupport));
                    String assertMessage = XMLChar.trim(content.getAttributeNS(
                                                SchemaSymbols.URI_XERCES_EXTENSIONS,
                                                SchemaSymbols.ATT_ASSERT_MESSAGE));
                    if (!"".equals(assertMessage)) {
                       assertImpl.setMessage(assertMessage);
                    }
                   
                    if (assertData == null) {
                       assertData = new Vector();
                    }                   
View Full Code Here

Examples of org.apache.xerces.impl.xs.assertion.XSAssertImpl

       
        XSObjectList assertList = (XSObjectList) assertions;
        XSObjectList attrMemberTypes = null;
        final int assertListSize = assertList.size();
        for (int i = 0; i < assertListSize; i++) {
            XSAssertImpl assertImpl = (XSAssertImpl) assertList.get(i);              
            boolean xpathContextExists = false;
            if (assertImpl.getType() == XSConstants.ASSERTION) {
                // not an assertion facet
                xpathContextExists = true;  
            }
            // check if this is an assertion, from an attribute
            if (assertImpl.getAttrName() != null) {
                value = assertImpl.getAttrValue();
                XSSimpleTypeDefinition attrType = (XSSimpleTypeDefinition) assertImpl.getTypeDefinition();
                attrMemberTypes = attrType.getMemberTypes();
                if (assertImpl.getVariety() == XSSimpleTypeDefinition.VARIETY_LIST) {
                    // this assertion belongs to a type, that is an item type of a "simpleType -> list".
                    // tokenize the list value by the longest sequence of white-spaces.
                    StringTokenizer values = new StringTokenizer(value, " \n\t\r");
                   
                    // evaluate assertion on all of list items
                    while (values.hasMoreTokens()) {
                        String itemValue = values.nextToken();
                        setValueOf$valueForAListItem(attrType, itemValue);                       
                        AssertionError assertError = evaluateAssertion(element, assertImpl, itemValue,
                                                                       xpathContextExists, true);
                        if (assertError != null) {
                            reportAssertionsError(assertError);   
                        }
                    }
                }
                else if (assertImpl.getVariety() == XSSimpleTypeDefinition.VARIETY_ATOMIC) {
                    // evaluating assertions for "simpleType -> restriction"
                    setTypedValueFor$value(value, null, attrType);
                    AssertionError assertError = evaluateAssertion(element, assertImpl, value,
                                                                   xpathContextExists, false);
                    if (assertError != null) {
View Full Code Here

Examples of org.apache.xerces.impl.xs.assertion.XSAssertImpl

       
        // assertions from a simple type definition          
        Vector assertList = (Vector) assertions;
        final int assertListLength = assertList.size();
        for (int i = 0; i < assertListLength; i++) {
            XSAssertImpl assertImpl = (XSAssertImpl) assertList.get(i);
            if (itemType != null) {
               // evaluating assertions for "simpleType -> list". tokenize the list value by the longest sequence of
               // white-spaces.
               StringTokenizer values = new StringTokenizer(value, " \n\t\r");
              
View Full Code Here

Examples of org.apache.xerces.impl.xs.assertion.XSAssertImpl

                    XSMultiValueFacet facet = (XSMultiValueFacet) memberTypeFacets.item(memberTypeFacetIdx);
                    if (facet.getFacetKind() == XSSimpleTypeDefinition.FACET_ASSERT) {
                        Vector assertFacets = facet.getAsserts();
                        int assertsSucceeded = 0;
                        for (Iterator iter = assertFacets.iterator(); iter.hasNext(); ) {
                            XSAssertImpl assertImpl = (XSAssertImpl) iter.next();
                            try {
                               setTypedValueFor$value(value, memType, null);
                               AssertionError assertError = evaluateAssertion(element, assertImpl, value, false, false);
                               if (assertError == null) {
                                   assertsSucceeded++; 
                               }
                               else if (isAttribute && fAttrName == null) {
                                   fAttrName = assertImpl.getAttrName();  
                               }
                            }
                            catch(Exception ex) {
                               // An exception may occur if for example, a typed value cannot be constructed by PsychoPath
                               // engine for a given "string value" (say a value '5' was attempted to be formed as a typed
View Full Code Here

Examples of org.apache.xerces.impl.xs.assertion.XSAssertImpl

     */
    private void reportAssertionsError(AssertionError assertError) {
       
        String key = assertError.getErrorCode();
        QName element = assertError.getElement();
        XSAssertImpl assertImpl = assertError.getAssertion();
        boolean isList = assertError.isList();
        String value = assertError.getValue();
       
        XSTypeDefinition typeDef = assertImpl.getTypeDefinition();       
        String typeString = "";
       
        if (typeDef != null) {
            typeString = (typeDef.getName() != null) ? typeDef.getName() : "#anonymous";  
        }
        else {
            typeString = "#anonymous";
        }
       
        String elemErrorAnnotation = element.rawname;
        if (assertImpl.getAttrName() != null) {
            elemErrorAnnotation = element.rawname + " (attribute => " + assertImpl.getAttrName()+ ")";   
        }               
       
        String listAssertErrMessage = "";       
        if (isList) {
           listAssertErrMessage =  "Assertion failed for an xs:list member value '" + assertError.getValue() + "'.";
        }
           
        String message = assertImpl.getMessage();
        if (message != null) {
           // substitute all placeholder macro instances of "{$value}" with atomic value stored in variable "value".
           if (value != null && !"".equals(value)) {
              message = message.replaceAll(ERROR_PLACEHOLDER_REGEX, value);
           }
          
           if (!message.endsWith(".")) {
              message = message + ".";   
           }
           if (key.equals("cvc-assertion.4.3.15.3")) {
              message = "Assertion failed (undefined context) for schema type '" + typeString + "'. " + message;  
           }
           else {
              message = "Assertion failed for schema type '" + typeString + "'. " + message;
           }          
           fValidator.reportSchemaError("cvc-assertion.failure", new Object[] { message, listAssertErrMessage } );   
        }
        else {
           fValidator.reportSchemaError(key, new Object[] { elemErrorAnnotation, assertImpl.getTest().getXPath().toString(),
                                                            typeString, listAssertErrMessage} );
        }
       
    } // reportAssertionsError
View Full Code Here

Examples of org.apache.xerces.impl.xs.assertion.XSAssertImpl

                    XSMultiValueFacet facet = (XSMultiValueFacet) facets.
                                                                     item(facetIdx);
                    if (facet.getFacetKind() == XSSimpleTypeDefinition.FACET_ASSERT) {
                        Vector assertionFacets = facet.getAsserts();
                        for (int j = 0; j < assertionFacets.size(); j++) {
                           XSAssertImpl assertImpl = (XSAssertImpl)
                                                            assertionFacets.get(j);
                           addAssertion(assertImpl);
                        }
                      
                        // among the facet list, there could be only one
View Full Code Here

Examples of org.apache.xerces.impl.xs.assertion.XSAssertImpl

                // annotations.
                annotations = XSObjectListImpl.EMPTY_LIST;
            }
           
            // create an assertion object           
            XSAssertImpl assertImpl = new XSAssertImpl(enclosingCT,
                                                       annotations,
                                                       fSchemaHandler);
            Test testExpr = new Test(new XPath20Assert(test, fSymbolTable,
                                     new SchemaNamespaceSupport(schemaDoc.
                                     fNamespaceSupport)), assertImpl);
            assertImpl.setTest(testExpr);
            assertImpl.setXPathDefaultNamespace(xpathDefaultNamespace);
            assertImpl.setXPath2NamespaceContext(new SchemaNamespaceSupport
                                            (schemaDoc.fNamespaceSupport));
            String assertMessage = XMLChar.trim(assertElement.getAttributeNS(
                                          SchemaSymbols.URI_XERCES_EXTENSIONS,
                                          SchemaSymbols.ATT_ASSERT_MESSAGE));
            if (!"".equals(assertMessage)) {
               assertImpl.setMessage(assertMessage);
            }

            // add assertion object, to the list of assertions to be processed
            addAssertion(assertImpl);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.