You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mu...@apache.org on 2011/03/27 03:30:16 UTC

svn commit: r1085851 - in /xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl: msg/ xs/ xs/assertion/

Author: mukulg
Date: Sun Mar 27 01:30:15 2011
New Revision: 1085851

URL: http://svn.apache.org/viewvc?rev=1085851&view=rev
Log:
committing slight improvements to error codes for simpleType assertion facet failures (making error codes cvc-assertions-valid for simpleType varieties atomic and list as well). doing slight refactoring as well.

Modified:
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/AbstractPsychoPathXPath2Impl.java
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertPsychopathXPath2Impl.java
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertionXPath2Value.java
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertionXPath2ValueImpl.java

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties?rev=1085851&r1=1085850&r2=1085851&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties Sun Mar 27 01:30:15 2011
@@ -106,7 +106,8 @@
         cvc-type.3.1.2 = cvc-type.3.1.2: Element ''{0}'' is a simple type, so it must have no element information item [children].
         cvc-type.3.1.3 = cvc-type.3.1.3: The value ''{1}'' of element ''{0}'' is not valid.
         cvc-assertion = cvc-assertion: Assertion evaluation (''{1}'') for element ''{0}'' on schema type ''{2}'' did not succeed. {3}
-        cvc-assertion-failure-mesg = cvc-assertion-failure-mesg: {0} {1}                  
+        cvc-assertion-failure-mesg = cvc-assertion-failure-mesg: {0} {1}
+        cvc-assertions-valid = cvc-assertions-valid: Value ''{0}'' is not facet-valid with respect to assertion ''{1}''.                
         cvc-assertions-valid-context = cvc-assertions-valid-context: Assertion evaluation (''{1}'') for element ''{0}'' on schema type ''{2}'' did not succeed (undefined context). {3}
         cvc-assertions-valid-union-elem = cvc-assertions-valid-union-elem: Value ''{0}'' is not facet-valid with respect to the specified assertions, on type ''{2}'' on element ''{1}''.
         cvc-assertions-valid-union-attr = cvc-assertions-valid-union-attr: Value ''{0}'' is not facet-valid with respect to the specified assertions, on type ''{3}'' on attribute ''{2}'/@'{1}''.         

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/AbstractPsychoPathXPath2Impl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/AbstractPsychoPathXPath2Impl.java?rev=1085851&r1=1085850&r2=1085851&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/AbstractPsychoPathXPath2Impl.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/AbstractPsychoPathXPath2Impl.java Sun Mar 27 01:30:15 2011
@@ -133,29 +133,21 @@ public class AbstractPsychoPathXPath2Imp
         
         XPathParser xpathParser = new JFlexCupParser();
         XPath xpathObject = null;
-        
+
         try {
             xpathObject = xpathParser.parse("boolean(" + xpathStr + ")", true);
         } catch (XPathParserException ex) {
             // error compiling XPath expression
-            if (SchemaSymbols.ASSERT_XPATHEXPR_COMPILE_ERR_MESG_1.equals(ex.getMessage())) {
-               reportError("cvc-xpath.3.13.4.2b", assertImpl, fSchemaHandler, schemaContextElem); 
+            if (SchemaSymbols.ASSERT_XPATHEXPR_COMPILE_ERR_MESG_1.equals(ex.getMessage())) {               
+                fSchemaHandler.reportSchemaError("cvc-xpath.3.13.4.2b", new Object[] {assertImpl.getTest().getXPath().toString(), XSTypeHelper.getSchemaTypeName(assertImpl.getTypeDefinition())}, schemaContextElem);
             }
-            else {
-               reportError("cvc-xpath.3.13.4.2a", assertImpl, fSchemaHandler, schemaContextElem);
+            else {               
+                fSchemaHandler.reportSchemaError("cvc-xpath.3.13.4.2a", new Object[] {assertImpl.getTest().getXPath().toString(), XSTypeHelper.getSchemaTypeName(assertImpl.getTypeDefinition())}, schemaContextElem);
             }
         }  
-        
+
         return xpathObject;
         
     } // compileXPathStr
     
-    
-    /*
-     * Method to report error messages.
-     */
-    private void reportError(String key, XSAssertImpl assertImpl, XSDHandler fSchemaHandler, Element schemaContextElem) {        
-        fSchemaHandler.reportSchemaError(key, new Object[] {assertImpl.getTest().getXPath().toString(), XSTypeHelper.getSchemaTypeName(assertImpl.getTypeDefinition())}, schemaContextElem);        
-    } // reportError
-    
 } // class AbstractPsychoPathXPath2Impl

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertPsychopathXPath2Impl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertPsychopathXPath2Impl.java?rev=1085851&r1=1085850&r2=1085851&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertPsychopathXPath2Impl.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertPsychopathXPath2Impl.java Sun Mar 27 01:30:15 2011
@@ -50,7 +50,6 @@ import org.apache.xerces.xs.XSSimpleType
 import org.apache.xerces.xs.XSTypeDefinition;
 import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
 import org.eclipse.wst.xml.xpath2.processor.DynamicError;
-import org.eclipse.wst.xml.xpath2.processor.StaticError;
 import org.eclipse.wst.xml.xpath2.processor.ast.XPath;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -499,8 +498,7 @@ public class XMLAssertPsychopathXPath2Im
             XPath xpathObject = assertImpl.getCompiledXPathExpr();
             
             boolean result;            
-            if ((value == null) ||
-                (xPathContextExists == true)) {
+            if (value == null || xPathContextExists == true) {
                 result = fAbstrPsychopathImpl.evaluateXPathExpr(xpathObject, fCurrentAssertDomNode);  
             } 
             else {
@@ -514,7 +512,7 @@ public class XMLAssertPsychopathXPath2Im
             }
         }
         catch (DynamicError ex) {
-            if (ex.code().equals("XPDY0002")) {
+            if ("XPDY0002".equals(ex.code())) {
                // ref: http://www.w3.org/TR/xpath20/#eval_context
                assertionError = new AssertionError("cvc-assertions-valid-context", element, assertImpl, value, isList);
             }
@@ -522,9 +520,6 @@ public class XMLAssertPsychopathXPath2Im
                assertionError = new AssertionError("cvc-assertion", element, assertImpl, value, isList);
             }
         }
-        catch (StaticError ex) {
-            assertionError = new AssertionError("cvc-assertion", element, assertImpl, value, isList);
-        }
         catch(Exception ex) {
             assertionError = new AssertionError("cvc-assertion", element, assertImpl, value, isList);   
         }
@@ -620,18 +615,18 @@ public class XMLAssertPsychopathXPath2Im
                
         String typeNameStr = XSTypeHelper.getSchemaTypeName(assertImpl.getTypeDefinition());
         
-        String elemErrorAnnotation = element.rawname;
+        String elemNameAnnotation = element.rawname;
         if (assertImpl.getAttrName() != null) {
-            elemErrorAnnotation = element.rawname + " (attribute => " + assertImpl.getAttrName()+ ")";    
+            elemNameAnnotation = element.rawname + " (attribute => " + assertImpl.getAttrName()+ ")";    
         }                
         
         String listAssertErrMessage = "";        
         if (isList) {
            if (assertError.getIsTypeDerivedFromList()) {
-               listAssertErrMessage =  "Assertion failed for xs:list instance '" + assertError.getValue() + "'.";  
+               listAssertErrMessage =  "Assertion failed for xs:list instance '" + value + "'.";  
            }
            else {
-               listAssertErrMessage =  "Assertion failed for an xs:list member value '" + assertError.getValue() + "'.";
+               listAssertErrMessage =  "Assertion failed for an xs:list member value '" + value + "'.";
            }
         }
             
@@ -645,7 +640,7 @@ public class XMLAssertPsychopathXPath2Im
            if (!message.endsWith(".")) {
                message = message + ".";    
            }
-           if (key.equals("cvc-assertions-valid-context")) {
+           if ("cvc-assertions-valid-context".equals(key)) {
                message = "Assertion failed (undefined context) for schema type '" + typeNameStr + "'. " + message;   
            }
            else {
@@ -654,7 +649,15 @@ public class XMLAssertPsychopathXPath2Im
            fXmlSchemaValidator.reportSchemaError("cvc-assertion-failure-mesg", new Object[] {message, listAssertErrMessage});    
         }
         else {
-           fXmlSchemaValidator.reportSchemaError(key, new Object[] {elemErrorAnnotation, assertImpl.getTest().getXPath().toString(), typeNameStr, listAssertErrMessage});
+           if (assertImpl.getAssertKind() == XSConstants.ASSERTION) {
+              // error for xs:assert component
+              fXmlSchemaValidator.reportSchemaError(key, new Object[] {elemNameAnnotation, assertImpl.getTest().getXPath().toString(), typeNameStr, listAssertErrMessage});
+           }
+           else {
+               // errors for xs:assertion facet
+               fXmlSchemaValidator.reportSchemaError("cvc-assertions-valid", new Object[] {value, assertImpl.getTest().getXPath().toString()});
+               fXmlSchemaValidator.reportSchemaError(key, new Object[] {elemNameAnnotation, assertImpl.getTest().getXPath().toString(), typeNameStr, listAssertErrMessage});  
+           }
         }
         
     } // reportAssertionsError

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertionXPath2Value.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertionXPath2Value.java?rev=1085851&r1=1085850&r2=1085851&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertionXPath2Value.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertionXPath2Value.java Sun Mar 27 01:30:15 2011
@@ -35,7 +35,7 @@ import org.w3c.dom.Element;
 public interface XSAssertionXPath2Value {
     
     /*
-     * Determine "string value" of XPath2 context variable $value.
+     * Determine "string value" of XPath 2.0 context variable $value.
      */
     public String computeStringValueOf$value(Element currentAssertDomRootElem, ElementPSVI pElemPSVI) throws DOMException;
     

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertionXPath2ValueImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertionXPath2ValueImpl.java?rev=1085851&r1=1085850&r2=1085851&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertionXPath2ValueImpl.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertionXPath2ValueImpl.java Sun Mar 27 01:30:15 2011
@@ -56,7 +56,7 @@ import org.w3c.dom.NodeList;
 public class XSAssertionXPath2ValueImpl implements XSAssertionXPath2Value {
 
     /*
-     * Determine "string value" of XPath2 context variable $value.
+     * Determine "string value" of XPath 2.0 context variable $value.
      */
     public String computeStringValueOf$value(Element currentAssertDomRootElem, ElementPSVI pElemPSVI) throws DOMException {
         



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org