Author: mukulg
Date: Sun Dec  6 11:50:17 2009
New Revision: 887671

URL: http://svn.apache.org/viewvc?rev=887671&view=rev
Log:
minor improvements to assertion implementation (xs:assertion can never access 
the xpath2 context).

Modified:
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertPsychopathImpl.java
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertImpl.java
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSConstants.java

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertPsychopathImpl.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertPsychopathImpl.java?rev=887671&r1=887670&r2=887671&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertPsychopathImpl.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertPsychopathImpl.java
 Sun Dec  6 11:50:17 2009
@@ -33,6 +33,7 @@
 import org.apache.xerces.xni.XMLString;
 import org.apache.xerces.xni.parser.XMLAssertAdapter;
 import org.apache.xerces.xs.ElementPSVI;
+import org.apache.xerces.xs.XSConstants;
 import org.apache.xerces.xs.XSModel;
 import org.apache.xerces.xs.XSObjectList;
 import org.apache.xerces.xs.XSTypeDefinition;
@@ -220,11 +221,16 @@
             }
             XSObjectList assertList = (XSObjectList) assertions;
             for (int i = 0; i < assertList.size(); i++) {
-               XSAssertImpl assertImpl = (XSAssertImpl) assertList.get(i);
+               XSAssertImpl assertImpl = (XSAssertImpl) assertList.get(i);     
          
+               boolean xpathContextExists = false;
+               if (assertImpl.getType() == XSConstants.ASSERTION) {
+                  // not an assertion facet
+                  xpathContextExists = true;   
+               }               
                evaluateAssertion(element,
                                  assertImpl,
                                  value,
-                                 xPathContextExistsForComplexType());
+                                 xpathContextExists);
             }
         } else if (assertions instanceof Vector) {
             // assertions from a simple type definition
@@ -238,37 +244,6 @@
     }
 
     /*
-     * Determine, if XPath context should exist, for assertions on
-     * complex types.
-     * an XPath context should exist, if complex type has following
-     * content model:
-     * complexType -> simpleContent -> extension
-     * OR
-     * complexType -> mixed content type
-     *                (i.e, <xs:complexType ... mixed="true")
-     */
-    private boolean xPathContextExistsForComplexType() {
-        boolean contextExistsForComplexType = false;
-        
-        PSVIElementNSImpl psviElemCurrent = (PSVIElementNSImpl)
-                                                 currentAssertDomNode;         
-        if (psviElemCurrent.getTypeDefinition().getTypeCategory() == 
-                                         XSTypeDefinition.COMPLEX_TYPE) {
-             XSComplexTypeDecl compTypeDecl = (XSComplexTypeDecl)
-                                           
psviElemCurrent.getTypeDefinition();                                       
-             if (compTypeDecl.isDerivedFrom(SchemaSymbols.URI_SCHEMAFORSCHEMA,
-                                    SchemaSymbols.ATTVAL_ANYSIMPLETYPE,
-                                    XSComplexTypeDecl.DERIVATION_EXTENSION) ||
-                                    (compTypeDecl.getContentType() ==
-                                           compTypeDecl.CONTENTTYPE_MIXED)) {
-                 contextExistsForComplexType = true;    
-             }
-        }
-         
-        return contextExistsForComplexType;
-    }
-
-    /*
      * (non-Javadoc)
      * @see 
org.apache.xerces.xni.parser.XMLAssertAdapter#characters(org.apache.xerces.xni.XMLString)
      */
@@ -293,17 +268,12 @@
             boolean result;            
             if ((value == null) ||
                 (xPathContextExists == true)) {
-                // assertion on complex type, with complex content
-                // OR, complex type -> simpleContent -> extension
-                // OR, complex type -> mixed
                 result = abstrPsychopathImpl.evaluatePsychoPathExpr(xp,
                                  assertImpl.getXPathDefaultNamespace(),
                                  currentAssertDomNode);  
-            }
+            } 
             else {
-                // assertion on simple type
-                // OR, complex type -> simpleContent -> restriction.
-                // here, XPath context is "undefined"
+                // XPath context is "undefined"
                 result = abstrPsychopathImpl.evaluatePsychoPathExpr(xp,
                                  assertImpl.getXPathDefaultNamespace(),
                                  null); 

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertImpl.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertImpl.java?rev=887671&r1=887670&r2=887671&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertImpl.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertImpl.java
 Sun Dec  6 11:50:17 2009
@@ -37,6 +37,8 @@
  */
 public class XSAssertImpl extends AbstractPsychoPathImpl implements XSAssert {
 
+    protected short assertType = XSConstants.ASSERTION;
+    
     /** The type definition associated with the assertion component */
     protected XSTypeDefinition fTypeDefinition;
 
@@ -91,6 +93,13 @@
     public void setXPath2NamespaceContext(NamespaceSupport namespaceContext) {
         fXPath2NamespaceContext = namespaceContext;       
     }
+    
+    /**
+     * Sets the type of the object
+     */
+    public void setType(short assertType) {
+        this.assertType = assertType;
+    }
    
     public XSObjectList getAnnotations() {
         return fAnnotations;
@@ -141,7 +150,7 @@
      * Get the type of the object
      */
     public short getType() {
-        return XSConstants.ASSERTION;
+        return assertType;
     }
        
     /**

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java?rev=887671&r1=887670&r2=887671&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java
 Sun Dec  6 11:50:17 2009
@@ -24,7 +24,6 @@
 import org.apache.xerces.impl.dv.InvalidDatatypeValueException;
 import org.apache.xerces.impl.dv.XSFacets;
 import org.apache.xerces.impl.dv.XSSimpleType;
-import org.apache.xerces.impl.dv.xs.TypeValidatorHelper;
 import org.apache.xerces.impl.validation.ValidationState;
 import org.apache.xerces.impl.xpath.XPath20Assert;
 import org.apache.xerces.impl.xs.SchemaGrammar;
@@ -45,6 +44,7 @@
 import org.apache.xerces.util.SymbolTable;
 import org.apache.xerces.xni.QName;
 import org.apache.xerces.xs.XSAttributeUse;
+import org.apache.xerces.xs.XSConstants;
 import org.apache.xerces.xs.XSMultiValueFacet;
 import org.apache.xerces.xs.XSObjectList;
 import org.apache.xerces.xs.XSSimpleTypeDefinition;
@@ -511,6 +511,7 @@
                                                            fSchemaHandler);
                     Test testExpr = new Test(new XPath20Assert(test, 
fSymbolTable, 
                                            schemaDoc.fNamespaceSupport), 
assertImpl);                 
+                    assertImpl.setType(XSConstants.ASSERTION_FACET);
                     assertImpl.setTest(testExpr);
                     assertImpl.setXPathDefaultNamespace(xpathDefaultNamespace);
                     
assertImpl.setXPath2NamespaceContext(schemaDoc.fNamespaceSupport);

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSConstants.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSConstants.java?rev=887671&r1=887670&r2=887671&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSConstants.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSConstants.java
 Sun Dec  6 11:50:17 2009
@@ -89,11 +89,16 @@
      * The object describes a XML Schema assertion
      */
     public static final short ASSERTION                 = 16;
+    
+    /**
+     * The object describes a XML Schema assertion, facet
+     */
+    public static final short ASSERTION_FACET           = 17;
 
     /**
      * The object describes an openContent
      */
-    public static final short OPEN_CONTENT              = 17;
+    public static final short OPEN_CONTENT              = 18;
 
     // Derivation constants
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to