Author: mukulg
Date: Thu Sep  8 03:46:24 2011
New Revision: 1166522

URL: http://svn.apache.org/viewvc?rev=1166522&view=rev
Log:
schema 1.1 change: as per private discussion with Sandy Gao, implementing a 
feature to control "xpath subset" vs "full xpath" for CTA evaluation, with 
xpath subset being default.

Modified:
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/Constants.java
    
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/XMLSchemaLoader.java
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/alternative/Test.java
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDTypeAlternativeTraverser.java
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/validation/XMLSchemaValidatorComponentManager.java
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/parsers/StandardParserConfiguration.java
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/parsers/XML11Configuration.java

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/Constants.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/Constants.java?rev=1166522&r1=1166521&r2=1166522&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/Constants.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/Constants.java
 Thu Sep  8 03:46:24 2011
@@ -334,6 +334,9 @@ public final class Constants {
     /** Feature to ignore errors caused by type alternatives */
     public static final String TYPE_ALTERNATIVES_CHEKING_FEATURE = 
"validation/type-alternative-checking";
     
+    /** Feature to control full XPath 2.0 checking for CTA processing */
+    public static final String CTA_FULL_XPATH_CHECKING_FEATURE = 
"validation/cta-full-xpath-checking";
+    
     /** Feature to ignore errors caused by unparsed entities 
("validation/unparsed-entity-checking") */
     public static final String UNPARSED_ENTITY_CHECKING_FEATURE = 
"validation/unparsed-entity-checking";
     
@@ -548,6 +551,7 @@ public final class Constants {
             TOLERATE_DUPLICATES_FEATURE,
             STRINGS_INTERNED_FEATURE,
             TYPE_ALTERNATIVES_CHEKING_FEATURE,
+            CTA_FULL_XPATH_CHECKING_FEATURE,
     };
     
     /** Xerces properties. */

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=1166522&r1=1166521&r2=1166522&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
 Thu Sep  8 03:46:24 2011
@@ -347,7 +347,7 @@
         c-fields-xpaths = c-fields-xpaths: The field value = ''{0}'' is not 
valid.
         c-general-xpath = c-general-xpath: The expression ''{0}'' is not valid 
with respect to the XPath subset supported by XML Schema.
         c-general-xpath-ns = c-general-xpath-ns: A namespace prefix in XPath 
expression ''{0}'' was not bound to a namespace.
-        c-cta-xpath = c-cta-xpath: The expression ''{0}'' is not a valid XPath 
expression, for CTA evaluation.  
+        c-cta-xpath = c-cta-xpath: The XPath expression ''{0}'' couldn''t 
compile successfully in ''{1}'' mode, during CTA evaluation.  
         c-selector-xpath = c-selector-xpath: The selector value = ''{0}'' is 
not valid; selector xpaths cannot contain attributes.
         EmptyTargetNamespace = EmptyTargetNamespace: In schema document 
''{0}'', the value of the ''targetNamespace'' attribute cannot be an empty 
string.
         FacetValueFromBase = FacetValueFromBase: In the declaration of type 
''{0}'', value ''{1}'' of facet ''{2}'' must be from the value space of the 
base type, ''{3}''.

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java?rev=1166522&r1=1166521&r2=1166522&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java
 Thu Sep  8 03:46:24 2011
@@ -146,6 +146,10 @@ XSLoader, DOMConfiguration {
     protected static final String TOLERATE_DUPLICATES = 
         Constants.XERCES_FEATURE_PREFIX + 
Constants.TOLERATE_DUPLICATES_FEATURE;
     
+    /** Feature identifier: tolerate duplicates */
+    protected static final String CTA_FULL_XPATH = 
+        Constants.XERCES_FEATURE_PREFIX + 
Constants.CTA_FULL_XPATH_CHECKING_FEATURE;
+    
     /** Property identifier: Schema DV Factory */
     protected static final String SCHEMA_DV_FACTORY = 
         Constants.XERCES_PROPERTY_PREFIX + 
Constants.SCHEMA_DV_FACTORY_PROPERTY;
@@ -162,7 +166,8 @@ XSLoader, DOMConfiguration {
         VALIDATE_ANNOTATIONS,
         HONOUR_ALL_SCHEMALOCATIONS,
         NAMESPACE_GROWTH,
-        TOLERATE_DUPLICATES
+        TOLERATE_DUPLICATES,
+        CTA_FULL_XPATH,
     };
     
     // property identifiers

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/alternative/Test.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/alternative/Test.java?rev=1166522&r1=1166521&r2=1166522&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/alternative/Test.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/alternative/Test.java
 Thu Sep  8 03:46:24 2011
@@ -101,7 +101,7 @@ public class Test extends AbstractPsycho
         if (fXPath != null) {
             return fXPath.evaluateTest(element, attributes);
         } else if (fXPathPsychoPath != null) {
-            return evaluateTestExprWithPsychoPathEngine(element, attributes);  
+            return evaluateTestWithPsychoPathXPathEngine(element, attributes); 
 
         }
         else {
             return false;
@@ -113,15 +113,15 @@ public class Test extends AbstractPsycho
     }
     
     /*
-     * Evaluate the XPath "test" expression on an XDM instance, consisting of 
the specified element and its attributes.
-     * Uses PsychoPath XPath 2.0 engine for the evaluation. 
+     * Evaluate the XPath "test" expression on an XDM instance, for CTA 
evaluation. Uses PsychoPath XPath 2.0 engine for the evaluation. 
      */
-    private boolean evaluateTestExprWithPsychoPathEngine(QName element, 
XMLAttributes attributes) {
+    private boolean evaluateTestWithPsychoPathXPathEngine(QName element, 
XMLAttributes attributes) {
         
         boolean evaluationResult = false;
 
         try { 
-            // an untyped PSVI DOM tree is constructed, to provide to 
PsychoPath engine for evaluation.
+            // an untyped PSVI DOM tree (consisting only of the top most 
element node and it's attributes) is constructed,
+            // to provide to PsychoPath XPath engine for evaluation.
             Document document = new PSVIDocumentImpl();
             Element elem = document.createElementNS(element.uri, 
element.rawname);
             for (int attrIndx = 0; attrIndx < attributes.getLength(); 
attrIndx++) {         
@@ -146,6 +146,6 @@ public class Test extends AbstractPsycho
 
         return evaluationResult;
        
-    } // evaluateTestExprWithPsychoPathEngine
+    } // evaluateTestWithPsychoPathXPathEngine
     
 }

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java?rev=1166522&r1=1166521&r2=1166522&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java
 Thu Sep  8 03:46:24 2011
@@ -77,7 +77,6 @@ import org.apache.xerces.util.StAXLocati
 import org.apache.xerces.util.SymbolHash;
 import org.apache.xerces.util.SymbolTable;
 import org.apache.xerces.util.URI.MalformedURIException;
-import org.apache.xerces.util.XMLChar;
 import org.apache.xerces.util.XMLSymbols;
 import org.apache.xerces.xni.QName;
 import org.apache.xerces.xni.XNIException;
@@ -179,6 +178,10 @@ public class XSDHandler {
     protected static final String TOLERATE_DUPLICATES = 
       Constants.XERCES_FEATURE_PREFIX + Constants.TOLERATE_DUPLICATES_FEATURE;
     
+    /** Feature identifier: Full XPath 2.0 for CTA evaluations */
+    protected static final String CTA_FULL_XPATH = 
+      Constants.XERCES_FEATURE_PREFIX + 
Constants.CTA_FULL_XPATH_CHECKING_FEATURE;
+    
     /** Feature identifier: namespace prefixes. */
     private static final String NAMESPACE_PREFIXES =
         Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACE_PREFIXES_FEATURE;
@@ -403,6 +406,9 @@ public class XSDHandler {
     
     // handle tolerate duplicates feature
     boolean fTolerateDuplicates = false;
+    
+    // handle full XPath 2.0 feature
+    boolean fFullXPathForCTA = false;
 
     // the XMLErrorReporter
     private XMLErrorReporter fErrorReporter;
@@ -3818,6 +3824,12 @@ public class XSDHandler {
         } catch (XMLConfigurationException e) {
             fTolerateDuplicates = false;
         }
+        
+        try {
+            fFullXPathForCTA = componentManager.getFeature(CTA_FULL_XPATH);
+        } catch (XMLConfigurationException e) {
+            fFullXPathForCTA = false;
+        }
 
         try {
             fSchemaParser.setFeature(

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDTypeAlternativeTraverser.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDTypeAlternativeTraverser.java?rev=1166522&r1=1166521&r2=1166522&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDTypeAlternativeTraverser.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDTypeAlternativeTraverser.java
 Thu Sep  8 03:46:24 2011
@@ -61,7 +61,9 @@ import org.w3c.dom.Element;
  */
 class XSDTypeAlternativeTraverser extends XSDAbstractTraverser {
     
-    private static final XSSimpleType fErrorType;
+    private static final XSSimpleType fErrorType;    
+    private boolean fIsFullXPathModeForCTA;
+    private String[] fctaXPathModes = {"cta-subset", "cta-full"};
     
     static {
         SchemaGrammar grammar = 
SchemaGrammar.getS4SGrammar(Constants.SCHEMA_VERSION_1_1);
@@ -70,6 +72,7 @@ class XSDTypeAlternativeTraverser extend
 
     XSDTypeAlternativeTraverser (XSDHandler handler, XSAttributeChecker 
attrChecker) {
         super(handler, attrChecker);
+        fIsFullXPathModeForCTA = handler.fFullXPathForCTA;
     }
 
     /**
@@ -188,21 +191,27 @@ class XSDTypeAlternativeTraverser extend
         // now look for other optional attributes like test and 
xpathDefaultNamespace
         if (testStr != null) {
             Test testExpr = null;
-            //set the test attribute value
             try {
-               testExpr = new Test(new XPath20(testStr, fSymbolTable, new 
NamespaceSupport(schemaDoc.fNamespaceSupport)), typeAlternative, new 
NamespaceSupport(schemaDoc.fNamespaceSupport));
-            } 
+                if (fIsFullXPathModeForCTA) {
+                    // if full XPath 2.0 support is enabled for CTA, use 
PsychoPath XPath 2.0 engine for XPath evaluation
+                    XPathParser xpp = new JFlexCupParser();
+                    XPath xp = xpp.parse("boolean(" + testStr + ")");
+                    testExpr = new Test(xp, typeAlternative, 
schemaDoc.fNamespaceSupport);
+                }
+                else {
+                    // if XPath subset is enabled for CTA (this is also the 
default option), use Xerces's native XPath parser for CTA
+                    testExpr = new Test(new XPath20(testStr, fSymbolTable, new 
NamespaceSupport(schemaDoc.fNamespaceSupport)), typeAlternative, new 
NamespaceSupport(schemaDoc.fNamespaceSupport));
+                }
+            }
             catch (XPathException e) {
-               // fall back to full XPath 2.0 support, with PsychoPath engine
-               try {
-                  XPathParser xpp = new JFlexCupParser();
-                  XPath xp = xpp.parse("boolean(" + testStr + ")");
-                  testExpr = new Test(xp, typeAlternative, 
schemaDoc.fNamespaceSupport);
-               } catch(XPathParserException ex) {
-                  reportSchemaError("c-cta-xpath", new Object[] { testStr }, 
altElement);
-                  //if the XPath is invalid, create a Test without an 
expression
-                  testExpr = new Test((XPath20) null, typeAlternative, new 
NamespaceSupport(schemaDoc.fNamespaceSupport));
-               }                
+                // if XPath expression couldn't compile, create a "test" 
without an expression
+                testExpr = new Test((XPath20) null, typeAlternative, new 
NamespaceSupport(schemaDoc.fNamespaceSupport));
+                reportSchemaError("c-cta-xpath", new Object[] {testStr, 
fctaXPathModes[0]}, altElement);                
+            }
+            catch(XPathParserException ex) {
+                // if XPath expression couldn't compile, create a "test" 
without an expression
+                testExpr = new Test((XPath20) null, typeAlternative, new 
NamespaceSupport(schemaDoc.fNamespaceSupport));
+                reportSchemaError("c-cta-xpath", new Object[] {testStr, 
fctaXPathModes[1]}, altElement);                
             }            
             typeAlternative.setTest(testExpr);
         }

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/validation/XMLSchemaValidatorComponentManager.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/validation/XMLSchemaValidatorComponentManager.java?rev=1166522&r1=1166521&r2=1166522&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/validation/XMLSchemaValidatorComponentManager.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/validation/XMLSchemaValidatorComponentManager.java
 Thu Sep  8 03:46:24 2011
@@ -87,6 +87,10 @@ final class XMLSchemaValidatorComponentM
     private static final String TYPE_ALTERNATIVES_CHECKING =
         Constants.XERCES_FEATURE_PREFIX + 
Constants.TYPE_ALTERNATIVES_CHEKING_FEATURE;
     
+    /** Feature identifier: whether to use full XPath 2.0 support for CTA 
processing */
+    private static final String CTA_FULL_XPATH_CHECKING =
+        Constants.XERCES_FEATURE_PREFIX + 
Constants.CTA_FULL_XPATH_CHECKING_FEATURE;
+    
     /** Feature identifier: disallow DOCTYPE declaration */
     private static final String DISALLOW_DOCTYPE_DECL_FEATURE =
         Constants.XERCES_FEATURE_PREFIX + 
Constants.DISALLOW_DOCTYPE_DECL_FEATURE;
@@ -286,7 +290,8 @@ final class XMLSchemaValidatorComponentM
         fFeatures.put(ID_IDREF_CHECKING, Boolean.TRUE);
         fFeatures.put(IDENTITY_CONSTRAINT_CHECKING, Boolean.TRUE);
         fFeatures.put(UNPARSED_ENTITY_CHECKING, Boolean.TRUE);
-        fFeatures.put(TYPE_ALTERNATIVES_CHECKING, Boolean.TRUE);        
+        fFeatures.put(TYPE_ALTERNATIVES_CHECKING, Boolean.TRUE);
+        fFeatures.put(CTA_FULL_XPATH_CHECKING, Boolean.FALSE);
     }
 
     /**

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/parsers/StandardParserConfiguration.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/parsers/StandardParserConfiguration.java?rev=1166522&r1=1166521&r2=1166522&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/parsers/StandardParserConfiguration.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/parsers/StandardParserConfiguration.java
 Thu Sep  8 03:46:24 2011
@@ -131,6 +131,10 @@ public class StandardParserConfiguration
     /** Feature identifier: whether to ignore type alternatives errors */
     protected static final String TYPE_ALTERNATIVES_CHECKING =
         Constants.XERCES_FEATURE_PREFIX + 
Constants.TYPE_ALTERNATIVES_CHEKING_FEATURE;
+    
+    /** Feature identifier: whether to use full XPath 2.0 support for CTA 
processing */
+    protected static final String CTA_FULL_XPATH_CHECKING =
+        Constants.XERCES_FEATURE_PREFIX + 
Constants.CTA_FULL_XPATH_CHECKING_FEATURE;
 
     // property identifiers
 
@@ -239,6 +243,7 @@ public class StandardParserConfiguration
             IDENTITY_CONSTRAINT_CHECKING,
             UNPARSED_ENTITY_CHECKING,
             TYPE_ALTERNATIVES_CHECKING,
+            CTA_FULL_XPATH_CHECKING,
         };
         addRecognizedFeatures(recognizedFeatures);
 
@@ -257,6 +262,7 @@ public class StandardParserConfiguration
         setFeature(IDENTITY_CONSTRAINT_CHECKING, true);
         setFeature(UNPARSED_ENTITY_CHECKING, true);
         setFeature(TYPE_ALTERNATIVES_CHECKING, true);
+        setFeature(CTA_FULL_XPATH_CHECKING, false);
 
         // add default recognized properties
     

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/parsers/XML11Configuration.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/parsers/XML11Configuration.java?rev=1166522&r1=1166521&r2=1166522&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/parsers/XML11Configuration.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/parsers/XML11Configuration.java
 Thu Sep  8 03:46:24 2011
@@ -196,6 +196,10 @@ public class XML11Configuration extends 
     protected static final String TYPE_ALTERNATIVES_CHECKING =
         Constants.XERCES_FEATURE_PREFIX + 
Constants.TYPE_ALTERNATIVES_CHEKING_FEATURE;
     
+    /** Feature identifier: whether to use full XPath 2.0 support for CTA 
processing */
+    protected static final String CTA_FULL_XPATH_CHECKING =
+        Constants.XERCES_FEATURE_PREFIX + 
Constants.CTA_FULL_XPATH_CHECKING_FEATURE;
+    
 
     // property identifiers
    
@@ -499,6 +503,7 @@ public class XML11Configuration extends 
                        ID_IDREF_CHECKING, IDENTITY_CONSTRAINT_CHECKING,
                        UNPARSED_ENTITY_CHECKING, USE_GRAMMAR_POOL_ONLY,
                        TYPE_ALTERNATIVES_CHECKING,
+                       CTA_FULL_XPATH_CHECKING,
                        // NOTE: These shouldn't really be here but since the 
XML Schema
                        //       validator is constructed dynamically, its 
recognized
                        //       features might not have been set and it would 
cause a



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

Reply via email to