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 2009/09/14 08:55:52 UTC

svn commit: r814498 - in /xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl: msg/ xs/ xs/alternative/ xs/traversers/

Author: mukulg
Date: Mon Sep 14 06:55:52 2009
New Revision: 814498

URL: http://svn.apache.org/viewvc?rev=814498&view=rev
Log:
PsychoPath integration with CTA evaluation, and moving common PsychoPath evaluation code (shared between assertions and CTA at the moment) to a base class.

Added:
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/AbstractPsychoPathImpl.java
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/XMLAssertPsychopathImpl.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/XSDTypeAlternativeTraverser.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=814498&r1=814497&r2=814498&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 Mon Sep 14 06:55:52 2009
@@ -107,7 +107,7 @@
         cvc-type.3.1.3 = cvc-type.3.1.3: The value ''{1}'' of element ''{0}'' is not valid.
         cvc-assertion.3.13.4.1 = cvc-assertion.3.13.4.1: Assertion evaluation (''{1}'') for element ''{0}'' with type ''{2}'' did not succeed.
         cvc-xpath.3.13.4.2 = cvc-xpath.3.13.4.2: Assertion evaluation (''{1}'') for element ''{0}'' with type ''{2}'' did not succeed.
-
+        
 #schema valid (3.X.3)
 
         schema_reference.4 = schema_reference.4: Failed to read schema document ''{0}'', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
@@ -320,6 +320,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-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}''.

Added: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/AbstractPsychoPathImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/AbstractPsychoPathImpl.java?rev=814498&view=auto
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/AbstractPsychoPathImpl.java (added)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/AbstractPsychoPathImpl.java Mon Sep 14 06:55:52 2009
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xerces.impl.xs;
+
+import org.apache.xerces.xs.XSModel;
+import org.eclipse.wst.xml.xpath2.processor.DefaultDynamicContext;
+import org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator;
+import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
+import org.eclipse.wst.xml.xpath2.processor.DynamicError;
+import org.eclipse.wst.xml.xpath2.processor.Evaluator;
+import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
+import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
+import org.eclipse.wst.xml.xpath2.processor.StaticChecker;
+import org.eclipse.wst.xml.xpath2.processor.StaticError;
+import org.eclipse.wst.xml.xpath2.processor.StaticNameResolver;
+import org.eclipse.wst.xml.xpath2.processor.ast.XPath;
+import org.eclipse.wst.xml.xpath2.processor.function.FnFunctionLibrary;
+import org.eclipse.wst.xml.xpath2.processor.function.XSCtrLibrary;
+import org.eclipse.wst.xml.xpath2.processor.internal.Focus;
+import org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType;
+import org.eclipse.wst.xml.xpath2.processor.internal.types.ElementType;
+import org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * A base class, providing common services for XPath 2.0 evaluation, with PsychoPath.
+ * 
+ * @author Mukul Gandhi, IBM
+ * 
+ * @version $Id: AbstractPsychoPathImpl.java 814163 2009-09-12 13:43:19Z mukulg $
+ */
+public class AbstractPsychoPathImpl {
+    
+    private DynamicContext fDynamicContext = null;
+    private Document domDoc = null;
+    
+    protected DynamicContext initDynamicContext(XSModel schema, Document document) {
+        fDynamicContext = new DefaultDynamicContext(schema, document);                
+        fDynamicContext.add_namespace("xs", "http://www.w3.org/2001/XMLSchema");
+        fDynamicContext.add_namespace("fn", "http://www.w3.org/2005/xpath-functions");
+        fDynamicContext.add_function_library(new FnFunctionLibrary());
+        fDynamicContext.add_function_library(new XSCtrLibrary());        
+        domDoc = document;
+        
+        return fDynamicContext; 
+    } //initDynamicContext
+    
+    protected boolean evaluatePsychoPathExpr(XPath xp, Element contextNode)
+                                    throws StaticError, DynamicError {
+        StaticChecker sc = new StaticNameResolver(fDynamicContext);
+        sc.check(xp);
+        
+        Evaluator eval = new DefaultEvaluator(fDynamicContext, domDoc);
+        
+        // change focus to the top most element
+        ResultSequence nodeEvalRS = ResultSequenceFactory.create_new();
+        nodeEvalRS.add(new ElementType(contextNode, 
+                           fDynamicContext.node_position(contextNode)));
+        fDynamicContext.set_focus(new Focus(nodeEvalRS));
+
+        ResultSequence rs = eval.evaluate(xp);
+
+        boolean result = false;
+
+        if (rs == null) {
+           result = false;
+        } else {
+           if (rs.size() == 1) {
+              AnyType rsReturn = rs.get(0);
+              if (rsReturn instanceof XSBoolean) {
+                 XSBoolean returnResultBool = (XSBoolean) rsReturn;
+                 result = returnResultBool.value();
+              } else {
+                 result = false;
+              }
+           } else {
+              result = false;
+           }
+        }
+        
+        return result;
+    } //evaluatePsychoPathExpr
+    
+} //AbstractPsychoPathImpl

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=814498&r1=814497&r2=814498&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 Mon Sep 14 06:55:52 2009
@@ -34,24 +34,11 @@
 import org.apache.xerces.xs.XSModel;
 import org.apache.xerces.xs.XSObjectList;
 import org.apache.xerces.xs.XSTypeDefinition;
-import org.eclipse.wst.xml.xpath2.processor.DefaultDynamicContext;
-import org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator;
 import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
-import org.eclipse.wst.xml.xpath2.processor.Evaluator;
 import org.eclipse.wst.xml.xpath2.processor.JFlexCupParser;
-import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
-import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
-import org.eclipse.wst.xml.xpath2.processor.StaticChecker;
-import org.eclipse.wst.xml.xpath2.processor.StaticNameResolver;
 import org.eclipse.wst.xml.xpath2.processor.XPathParser;
 import org.eclipse.wst.xml.xpath2.processor.XPathParserException;
 import org.eclipse.wst.xml.xpath2.processor.ast.XPath;
-import org.eclipse.wst.xml.xpath2.processor.function.FnFunctionLibrary;
-import org.eclipse.wst.xml.xpath2.processor.function.XSCtrLibrary;
-import org.eclipse.wst.xml.xpath2.processor.internal.Focus;
-import org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType;
-import org.eclipse.wst.xml.xpath2.processor.internal.types.ElementType;
-import org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean;
 import org.eclipse.wst.xml.xpath2.processor.internal.types.XSString;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -59,8 +46,8 @@
 import org.w3c.dom.NodeList;
 
 /**
- * The implementation of the XPath interface. This class interfaces with the
- * PsychoPath XPath 2.0 engine.
+ * An implementation of the XPath interface, for XML Schema 1.1 'assertions'
+ * evaluation. This class interfaces with the PsychoPath XPath 2.0 engine.
  * 
  * @author Mukul Gandhi, IBM
  * @author Ken Cai, IBM
@@ -73,6 +60,7 @@
     // class variable declarations
     DynamicContext fDynamicContext;
     XSModel fSchema = null;
+    AbstractPsychoPathImpl abstrPsychopathImpl = null;
 
     // a factory Document object to construct DOM tree nodes
     Document assertDocument = null;
@@ -108,13 +96,24 @@
      * Initialize the PsychoPath XPath processor
      */
     private void initXPathProcessor() throws Exception {
-        validator = (XMLSchemaValidator) getProperty("http://apache.org/xml/properties/assert/validator");
-        fDynamicContext = new DefaultDynamicContext(fSchema, assertDocument);
-        // add variable "value" to the XPath context
+        validator = (XMLSchemaValidator) getProperty("http://apache.org/xml/properties/assert/validator");        
+        abstrPsychopathImpl = new AbstractPsychoPathImpl();
+        fDynamicContext = abstrPsychopathImpl.initDynamicContext(fSchema, assertDocument);
+        
+        // assign value to variable, "value" in XPath context
         fDynamicContext.add_variable(new org.eclipse.wst.xml.xpath2.processor.internal.types.QName(
-                                                                   "value"));        
-        fDynamicContext.add_namespace("xs", "http://www.w3.org/2001/XMLSchema");
-        fDynamicContext.add_namespace("fn", "http://www.w3.org/2005/xpath-functions");
+                                         "value"));
+        String value = "";
+        NodeList childList = currentAssertDomNode.getChildNodes();
+        if (childList.getLength() == 1) {
+            Node node = childList.item(0);
+            if (node.getNodeType() == Node.TEXT_NODE) {
+                value = node.getNodeValue();
+            }
+        }
+        fDynamicContext.set_variable(
+                new org.eclipse.wst.xml.xpath2.processor.internal.types.QName(
+                        "value"), new XSString(value));
     }
 
     /*
@@ -171,26 +170,7 @@
             
             if (!assertRootStack.empty() && (currentAssertDomNode == assertRootStack.peek())) {               
                  // get XSModel                
-                 fSchema =  ((PSVIElementNSImpl)currentAssertDomNode).getSchemaInformation();  
-                 
-                 /*              
-                 // debugging code. can be present till the code is final.
-                 // print the tree on which assertions are evaluated
-                 try {
-                   DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
-                   DOMImplementationLS impl = (DOMImplementationLS) registry
-                                       .getDOMImplementation("LS");
-                   LSSerializer writer = impl.createLSSerializer();
-                   LSOutput output = impl.createLSOutput();
-                   output.setByteStream(System.out);
-                   writer.write(currentAssertDomNode, output);
-                   System.out.println("\n");
-                 }
-                 catch (Exception ex) {
-                   ex.printStackTrace();
-                 }
-                 */
-                 
+                 fSchema =  ((PSVIElementNSImpl)currentAssertDomNode).getSchemaInformation();
                  assertRootStack.pop(); // pop the stack, to go one level up
                  Object assertions = assertListStack.pop(); // get assertions, and go one level up
                 
@@ -235,12 +215,10 @@
     }
 
     /*
-     * Helper method to evaluate assertions
+     * Method to evaluate an assertion, XPath expression
      */
     private void evaluateAssertion(QName element, XSAssertImpl assertImpl) {
-        fDynamicContext.add_function_library(new FnFunctionLibrary());
-        fDynamicContext.add_function_library(new XSCtrLibrary());
-
+        
         XPathParser xpp = new JFlexCupParser();
         XPath xp = null;
         try {
@@ -250,59 +228,14 @@
             // error compiling XPath expression
             reportError("cvc-xpath.3.13.4.2", element, assertImpl);
         }
-        
-        StaticChecker sc = new StaticNameResolver(fDynamicContext);
-        
-        try {
-            sc.check(xp);        
-             
-            // assign value to variable, "value"
-            String value = "";
-            NodeList childList = currentAssertDomNode.getChildNodes();
-            if (childList.getLength() == 1) {
-                Node node = childList.item(0);
-                if (node.getNodeType() == Node.TEXT_NODE) {
-                    value = node.getNodeValue();
-                }
-            }
 
-            fDynamicContext.set_variable(
-                    new org.eclipse.wst.xml.xpath2.processor.internal.types.QName(
-                            "value"), new XSString(value));
+        try {            
+            boolean result = abstrPsychopathImpl.evaluatePsychoPathExpr(xp, currentAssertDomNode);
             
-            Evaluator eval = new DefaultEvaluator(fDynamicContext, assertDocument);
-            
-            // change focus to the top most element
-            ResultSequence nodeEvalRS = ResultSequenceFactory.create_new();
-            nodeEvalRS.add(new ElementType(currentAssertDomNode, 
-                               fDynamicContext.node_position(currentAssertDomNode)));
-            fDynamicContext.set_focus(new Focus(nodeEvalRS));
-
-            ResultSequence rs = eval.evaluate(xp);
-
-            boolean result = false;
-
-            if (rs == null) {
-                result = false;
-            } else {
-                if (rs.size() == 1) {
-                    AnyType rsReturn = rs.get(0);
-                    if (rsReturn instanceof XSBoolean) {
-                        XSBoolean returnResultBool = (XSBoolean) rsReturn;
-                        result = returnResultBool.value();
-                    } else {
-                        result = false;
-                    }
-                } else {
-                    result = false;
-                }
-            }
-
             if (!result) {
                 // assertion evaluation is false
                 reportError("cvc-assertion.3.13.4.1", element, assertImpl);
             }
-
         } catch (Exception ex) {
             reportError("cvc-assertion.3.13.4.1", element, assertImpl);
         }

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=814498&r1=814497&r2=814498&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 Mon Sep 14 06:55:52 2009
@@ -17,44 +17,80 @@
 
 package org.apache.xerces.impl.xs.alternative;
 
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
 import org.apache.xerces.impl.xpath.XPath20;
+import org.apache.xerces.impl.xs.AbstractPsychoPathImpl;
 import org.apache.xerces.xni.QName;
 import org.apache.xerces.xni.XMLAttributes;
+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;
 
 /**
- * XML schema type alternative test attribute
+ * Representation of XML Schema 1.1 'type alternatives', "test" attribute.
  * 
  * @author Hiranya Jayathilaka, University of Moratuwa
  * @version $Id$
  */
-public class Test {
+public class Test extends AbstractPsychoPathImpl {
 
 	/** The type alternative to which the test belongs */
     protected final XSTypeAlternativeImpl fTypeAlternative;
 
-    /** XPath 2.0 expression */
-    protected final XPath20 fXPath;
+    /** XPath 2.0 expression. Xerces-J native XPath 2.0 subset. */
+    protected XPath20 fXPath = null;
+    
+    /** XPath 2.0 expression. PsychoPath XPath 2.0 expression. */
+    protected XPath fXPathPsychoPath = null;
 
-    /** Constructs a test for type alternatives */
+    /** Constructs a "test" for type alternatives */
     public Test(XPath20 xpath, XSTypeAlternativeImpl typeAlternative) {
         fXPath = xpath;
         fTypeAlternative = typeAlternative;
     }
+    
+    /*
+     * Constructs a "test" for type alternatives. An overloaded constructor,
+     * for PsychoPath XPath processor.
+     */
+    public Test(XPath xpath, XSTypeAlternativeImpl typeAlternative) {
+       fXPathPsychoPath = xpath;
+       fTypeAlternative = typeAlternative;    
+    }
 
     public XSTypeAlternativeImpl getTypeAlternative() {
         return fTypeAlternative;
     }
 	
-    /** Returns the test XPath */
-    public XPath20 getXPath() {
-        return fXPath;
+     /*
+      * Returns the test XPath. Return the native XPath expression,
+      * or PsychoPath, whichever is available. 
+      */
+    public Object getXPath() {
+        Object xpath = null;
+        
+        if (fXPath != null) {
+            xpath = fXPath;    
+        } else if (fXPathPsychoPath != null) {
+            xpath = fXPathPsychoPath;    
+        }
+        
+        return xpath;
     }
-
+    
     /** Evaluate the test expression with respect to the specified element and its attributes */
     public boolean evaluateTest(QName element, XMLAttributes attributes) {
         if (fXPath != null) {
             return fXPath.evaluateTest(element, attributes);
-        } else {
+        } else if (fXPathPsychoPath != null) {
+            return evaluateTestWithPsychoPath(element, attributes);  
+        }
+        else {
             return false;
         }
     }
@@ -62,4 +98,41 @@
     public String toString() {
         return fXPath.toString();
     }
+    
+    /*
+     * Evaluate the XPath "test" expression on an XDM instance, containing the specified
+     * element and its attributes. Using PsychoPath XPath 2.0 engine for the evaluation. 
+     */
+    private boolean evaluateTestWithPsychoPath(QName element, XMLAttributes attributes) {
+       boolean result = false;
+       
+       try {
+         // construct a DOM document (an XPath XDM instance), for XPath evaluation
+         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+         DocumentBuilder docBuilder = dbf.newDocumentBuilder();
+         Document document = docBuilder.newDocument();
+       
+         Element elem = document.createElementNS(element.uri, element.rawname);
+         for (int attrIndx = 0; attrIndx < attributes.getLength(); attrIndx++) {
+            elem.setAttributeNS(attributes.getURI(attrIndx),
+                            attributes.getQName(attrIndx),
+                            attributes.getValue(attrIndx));
+         }
+       
+         document.appendChild(elem);
+         
+         initDynamicContext(null, document);       
+         result = evaluatePsychoPathExpr(fXPathPsychoPath, elem);
+       } catch(ParserConfigurationException ex) {
+           result = false;  
+       } catch (StaticError ex) {
+           result = false; 
+       } catch(DynamicError ex) {
+           result = false;
+       }
+       
+       return result;
+       
+    } //evaluateTestWithPsychoPath
+    
 }

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=814498&r1=814497&r2=814498&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 Mon Sep 14 06:55:52 2009
@@ -30,10 +30,14 @@
 import org.apache.xerces.xni.QName;
 import org.apache.xerces.xs.XSObjectList;
 import org.apache.xerces.xs.XSTypeDefinition;
+import org.eclipse.wst.xml.xpath2.processor.JFlexCupParser;
+import org.eclipse.wst.xml.xpath2.processor.XPathParser;
+import org.eclipse.wst.xml.xpath2.processor.XPathParserException;
+import org.eclipse.wst.xml.xpath2.processor.ast.XPath;
 import org.w3c.dom.Element;
 
 /**
- * The traverser implementation for XML schema type alternatives.
+ * The traverser implementation for XML Schema 1.1 'type alternative' component.
  * 
  * <alternative
  *    id = ID
@@ -101,7 +105,7 @@
         if (typeAtt != null) {
             alternativeType = (XSTypeDefinition)fSchemaHandler.getGlobalDecl(schemaDoc, XSDHandler.TYPEDECL_TYPE, typeAtt, altElement);
         }
-
+        
         // check whether the childNode still points to something...
         // if it does it must be an anonymous type declaration
         if (childNode != null) {
@@ -155,13 +159,20 @@
             Test testExpr = null;
             //set the test attribute value
             try {
-                testExpr = new Test(new XPath20(test, fSymbolTable, schemaDoc.fNamespaceSupport), typeAlternative);
-            }
+               testExpr = new Test(new XPath20(test, fSymbolTable, schemaDoc.fNamespaceSupport), typeAlternative);
+            } 
             catch (XPathException e) {
-                //if the xpath is invalid create a Test without an expression
-                reportSchemaError(e.getKey(), new Object[] { test }, altElement);
-                testExpr = new Test(null, typeAlternative);
-            }
+               // fall back to full XPath 2.0 support, with PsychoPath engine
+               try {
+                  XPathParser xpp = new JFlexCupParser();
+                  XPath xp = xpp.parse("boolean(" + test + ")");
+                  testExpr = new Test(xp, typeAlternative);
+               } catch(XPathParserException ex) {
+                  reportSchemaError("c-cta-xpath", new Object[] { test }, altElement);
+                  //if the XPath is invalid, create a Test without an expression
+                  testExpr = new Test((XPath20) null, typeAlternative);
+               }                
+            }            
             typeAlternative.setTest(testExpr);
         }
 



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