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/10/20 16:05:03 UTC

svn commit: r1186819 - in /xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs: XMLSchemaValidator.java XSDTypeAlternativeValidator.java alternative/Test.java

Author: mukulg
Date: Thu Oct 20 14:05:03 2011
New Revision: 1186819

URL: http://svn.apache.org/viewvc?rev=1186819&view=rev
Log:
schema 1.1 commit: assigning document URI to the XDM tree for <alternative> (using an approximation for the URI; reusing document URI of the parent document). if required, we may later create a logical URI for XDM trees for <alternative>, perhaps something like file:///alternative/file-path/x.xml (i.e we could insert an infix string like "alternative" within the document URI, to make it distinct from the parent document's URI). but for now, the current fix seems to meet our purpose (I attempted to solve one more XSD 1.1 test case, with this fix; and this works).

Modified:
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSDTypeAlternativeValidator.java
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/alternative/Test.java

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java?rev=1186819&r1=1186818&r2=1186819&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java Thu Oct 20 14:05:03 2011
@@ -2250,7 +2250,7 @@ public class XMLSchemaValidator
 
         //process type alternatives
         if (fTypeAlternativesChecking && fCurrentElemDecl != null) {
-           fTypeAlternative = fTypeAlternativeValidator.getTypeAlternative(fCurrentElemDecl, element, attributes, fInheritableAttrList, fNamespaceContext);           
+           fTypeAlternative = fTypeAlternativeValidator.getTypeAlternative(fCurrentElemDecl, element, attributes, fInheritableAttrList, fNamespaceContext, fLocator.getExpandedSystemId());           
            if (fTypeAlternative != null) {
                fCurrentType = fTypeAlternative.getTypeDefinition();
            }

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSDTypeAlternativeValidator.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSDTypeAlternativeValidator.java?rev=1186819&r1=1186818&r2=1186819&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSDTypeAlternativeValidator.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSDTypeAlternativeValidator.java Thu Oct 20 14:05:03 2011
@@ -53,7 +53,7 @@ public class XSDTypeAlternativeValidator
     /*
      * Determine the schema type applicable (represented as XSTypeAlternative component) for an element declaration, using type alternative information.
      */
-    public XSTypeAlternative getTypeAlternative(XSElementDecl currentElemDecl, QName element, XMLAttributes attributes, Vector inheritableAttrList, NamespaceContext instanceNamespaceContext) {
+    public XSTypeAlternative getTypeAlternative(XSElementDecl currentElemDecl, QName element, XMLAttributes attributes, Vector inheritableAttrList, NamespaceContext instanceNamespaceContext, String expandedSystemId) {
         
         XSTypeAlternative selectedTypeAlternative = null; 
         
@@ -63,7 +63,7 @@ public class XSDTypeAlternativeValidator
             XMLAttributes ctaAttributes = getAttributesForCTA(attributes, inheritableAttrList);
             for (int typeAltIdx = 0; typeAltIdx < typeAlternatives.length; typeAltIdx++) {
                 Test ctaTest = typeAlternatives[typeAltIdx].getTest();
-                if (ctaTest != null && ctaTest.evaluateTest(element, ctaAttributes, instanceNamespaceContext)) {
+                if (ctaTest != null && ctaTest.evaluateTest(element, ctaAttributes, instanceNamespaceContext, expandedSystemId)) {
                     selectedTypeAlternative = typeAlternatives[typeAltIdx]; 
                     break;
                 }

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=1186819&r1=1186818&r2=1186819&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 Oct 20 14:05:03 2011
@@ -108,11 +108,11 @@ public class Test extends AbstractPsycho
     }
     
     /** Evaluate the test expression with respect to the specified element and its attributes */
-    public boolean evaluateTest(QName element, XMLAttributes attributes, NamespaceContext instanceNamespaceContext) {        
+    public boolean evaluateTest(QName element, XMLAttributes attributes, NamespaceContext instanceNamespaceContext, String expandedSystemId) {        
         if (fXPath != null) {
             return fXPath.evaluateTest(element, attributes);
         } else if (fXPathPsychoPath != null) {
-            return evaluateTestWithPsychoPathXPathEngine(element, attributes, instanceNamespaceContext);  
+            return evaluateTestWithPsychoPathXPathEngine(element, attributes, instanceNamespaceContext, expandedSystemId);  
         }
         else {
             return false;
@@ -126,7 +126,7 @@ public class Test extends AbstractPsycho
     /*
      * Evaluate the XPath "test" expression on an XDM instance, for CTA evaluation. Uses PsychoPath XPath 2.0 engine for the evaluation. 
      */
-    private boolean evaluateTestWithPsychoPathXPathEngine(QName element, XMLAttributes attributes, NamespaceContext instanceNamespaceContext) {
+    private boolean evaluateTestWithPsychoPathXPathEngine(QName element, XMLAttributes attributes, NamespaceContext instanceNamespaceContext, String expandedSystemId) {
         
         boolean evaluationResult = false;
 
@@ -134,6 +134,7 @@ public class Test extends AbstractPsycho
             // 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();
+            document.setDocumentURI(expandedSystemId); // an approximation (the URI of the parent document) of the document URI for this <alternative>, document tree
             Element elem = document.createElementNS(element.uri, element.rawname);
             for (int attrIndx = 0; attrIndx < attributes.getLength(); attrIndx++) {         
                 PSVIAttrNSImpl attrNode = new PSVIAttrNSImpl((PSVIDocumentImpl)document, attributes.getURI(attrIndx), attributes.getQName(attrIndx));



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