Author: mukulg
Date: Wed May 11 08:25:07 2011
New Revision: 1101780
URL: http://svn.apache.org/viewvc?rev=1101780&view=rev
Log:
schema 1.1 implementation commit. improving implementation of type table
comparison, for "element declaration consistent" constraint. this improvement
implements comparison of namespace bindings & base URIs (in addition to
comparison of other type alternative properties) of type alternative's, and
also completes mandatory requirements of schema type table comparison.
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSConstraints.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/alternative/XSTypeAlternativeImpl.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDElementTraverser.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/xs/XSConstraints.java
URL:
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSConstraints.java?rev=1101780&r1=1101779&r2=1101780&view=diff
==============================================================================
---
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSConstraints.java
(original)
+++
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSConstraints.java
Wed May 11 08:25:07 2011
@@ -29,6 +29,7 @@ import org.apache.xerces.impl.xs.models.
import org.apache.xerces.impl.xs.util.SimpleLocator;
import org.apache.xerces.impl.xs.util.XSObjectListImpl;
import org.apache.xerces.impl.xs.util.XSTypeHelper;
+import org.apache.xerces.util.NamespaceSupport;
import org.apache.xerces.util.SymbolHash;
import org.apache.xerces.xs.XSConstants;
import org.apache.xerces.xs.XSObjectList;
@@ -598,13 +599,43 @@ public abstract class XSConstraints {
XSTypeDefinition typeDefn1 = typeAlt1.getTypeDefinition();
XSTypeDefinition typeDefn2 = typeAlt2.getTypeDefinition();
+ // check equivalence of defaultNamespace, test expression & type
definition
if (((defNamespace1 == null && defNamespace2 == null) ||
(defNamespace1 != null && defNamespace2 != null &&
defNamespace1.equals(defNamespace2))) &&
((testStr1 == null && testStr2 == null) || (testStr1 != null &&
testStr2 != null && (testStr1.trim()).equals(testStr2.trim()))) &&
(XSTypeHelper.isSchemaTypesIdentical(typeDefn1, typeDefn2))) {
isTypeAlternativesEquivalent = true;
}
- // TO DO: equivalence check for namespace bindings and base URI
+ // check equivalence of namespace bindings
+ if (isTypeAlternativesEquivalent) {
+ NamespaceSupport typeAlt1NamespaceContext =
typeAlt1.getNamespaceContext();
+ NamespaceSupport typeAlt2NamespaceContext =
typeAlt2.getNamespaceContext();
+ int nsDeclPrefixCount1 =
typeAlt1NamespaceContext.getDeclaredPrefixCount();
+ if (nsDeclPrefixCount1 ==
typeAlt2NamespaceContext.getDeclaredPrefixCount()) {
+ for (int prefIdx1 = 0; prefIdx1 < nsDeclPrefixCount1;
prefIdx1++) {
+ String prefix1 =
typeAlt1NamespaceContext.getDeclaredPrefixAt(prefIdx1);
+ if (!(typeAlt2NamespaceContext.containsPrefix(prefix1) &&
(typeAlt1NamespaceContext.getURI(prefix1) ==
typeAlt2NamespaceContext.getURI(prefix1)))) {
+ isTypeAlternativesEquivalent = false;
+ break;
+ }
+ }
+ }
+ else {
+ isTypeAlternativesEquivalent = false;
+ }
+ }
+
+ // check equivalence of base URIs
+ if (isTypeAlternativesEquivalent) {
+ String baseURI1 = typeAlt1.getBaseURI();
+ String baseURI2 = typeAlt2.getBaseURI();
+ if ((baseURI1 == null && baseURI2 != null) || (baseURI2 == null &&
baseURI1 != null)) {
+ isTypeAlternativesEquivalent = false;
+ }
+ else if ((baseURI1 == null && baseURI2 == null) ||
baseURI1.equals(baseURI2)) {
+ isTypeAlternativesEquivalent = true;
+ }
+ }
return isTypeAlternativesEquivalent;
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=1101780&r1=1101779&r2=1101780&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
Wed May 11 08:25:07 2011
@@ -72,6 +72,10 @@ public class Test extends AbstractPsycho
fXPath2NamespaceContext = namespaceContext;
}
+ public NamespaceSupport getNamespaceContext() {
+ return fXPath2NamespaceContext;
+ }
+
public XSTypeAlternativeImpl getTypeAlternative() {
return fTypeAlternative;
}
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/alternative/XSTypeAlternativeImpl.java
URL:
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/alternative/XSTypeAlternativeImpl.java?rev=1101780&r1=1101779&r2=1101780&view=diff
==============================================================================
---
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/alternative/XSTypeAlternativeImpl.java
(original)
+++
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/alternative/XSTypeAlternativeImpl.java
Wed May 11 08:25:07 2011
@@ -17,6 +17,7 @@
package org.apache.xerces.impl.xs.alternative;
+import org.apache.xerces.util.NamespaceSupport;
import org.apache.xerces.xs.XSConstants;
import org.apache.xerces.xs.XSNamespaceItem;
import org.apache.xerces.xs.XSObjectList;
@@ -47,6 +48,10 @@ public class XSTypeAlternativeImpl imple
/** Default XPath namespace */
protected String fXPathDefaultNamespace = null;
+
+ protected NamespaceSupport fNamespaceContext = null;
+
+ protected String fBaseURI = null;
/** Constructor */
public XSTypeAlternativeImpl(String elementName, XSTypeDefinition type,
XSObjectList annotations) {
@@ -68,6 +73,26 @@ public class XSTypeAlternativeImpl imple
public void setXPathDefauleNamespace(String namespace) {
fXPathDefaultNamespace = namespace;
}
+
+ public void setNamespaceContext(NamespaceSupport namespaceContext) {
+ fNamespaceContext = namespaceContext;
+ }
+
+ public void setBaseURI(String baseUri) {
+ fBaseURI = baseUri;
+ }
+
+ public NamespaceSupport getNamespaceContext() {
+ NamespaceSupport namespaceContext = fNamespaceContext;
+ if (namespaceContext == null && fTestExpr != null) {
+ namespaceContext = fTestExpr.getNamespaceContext();
+ }
+ return namespaceContext;
+ } // getNamespaceContext
+
+ public String getBaseURI() {
+ return fBaseURI;
+ }
//gets the name of the owning element
public String getElementName() {
@@ -141,4 +166,5 @@ public class XSTypeAlternativeImpl imple
public short getType() {
return XSConstants.TYPE_ALTERNATIVE;
}
+
}
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDElementTraverser.java
URL:
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDElementTraverser.java?rev=1101780&r1=1101779&r2=1101780&view=diff
==============================================================================
---
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDElementTraverser.java
(original)
+++
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDElementTraverser.java
Wed May 11 08:25:07 2011
@@ -32,6 +32,7 @@ import org.apache.xerces.impl.xs.XSParti
import org.apache.xerces.impl.xs.util.XInt;
import org.apache.xerces.impl.xs.util.XSObjectListImpl;
import org.apache.xerces.util.DOMUtil;
+import org.apache.xerces.util.NamespaceSupport;
import org.apache.xerces.util.SymbolTable;
import org.apache.xerces.util.XMLChar;
import org.apache.xerces.xni.QName;
@@ -438,6 +439,9 @@ class XSDElementTraverser extends XSDAbs
reportSchemaError("src-element.5", new
Object[]{nameAtt}, elmDecl);
}
element.setDefaultTypeDefinition();
+ if (element.getDefaultTypeDefinition() != null) {
+
element.getDefaultTypeDefinition().setNamespaceContext(new
NamespaceSupport(schemaDoc.fNamespaceSupport));
+ }
break;
}
}
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=1101780&r1=1101779&r2=1101780&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
Wed May 11 08:25:07 2011
@@ -31,6 +31,7 @@ import org.apache.xerces.impl.xs.alterna
import org.apache.xerces.impl.xs.util.XSObjectListImpl;
import org.apache.xerces.impl.xs.util.XSTypeHelper;
import org.apache.xerces.util.DOMUtil;
+import org.apache.xerces.util.NamespaceSupport;
import org.apache.xerces.xni.QName;
import org.apache.xerces.xs.XSObjectList;
import org.apache.xerces.xs.XSTypeDefinition;
@@ -75,8 +76,7 @@ class XSDTypeAlternativeTraverser extend
* schema grammar. Validate the content of the type alternative
* element.
*/
- public void traverse(Element altElement, XSElementDecl element,
- XSDocumentInfo schemaDoc, SchemaGrammar grammar) {
+ public void traverse(Element altElement, XSElementDecl element,
XSDocumentInfo schemaDoc, SchemaGrammar grammar) {
Object[] attrValues = fAttrChecker.checkAttributes(altElement, false,
schemaDoc);
QName typeAtt = (QName) attrValues[XSAttributeChecker.ATTIDX_TYPE];
@@ -189,9 +189,7 @@ class XSDTypeAlternativeTraverser extend
Test testExpr = null;
//set the test attribute value
try {
- testExpr = new Test(new XPath20(testStr, fSymbolTable,
schemaDoc.fNamespaceSupport),
- typeAlternative,
- schemaDoc.fNamespaceSupport);
+ 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
@@ -202,12 +200,16 @@ class XSDTypeAlternativeTraverser extend
} 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,
- schemaDoc.fNamespaceSupport);
+ testExpr = new Test((XPath20) null, typeAlternative, new
NamespaceSupport(schemaDoc.fNamespaceSupport));
}
}
typeAlternative.setTest(testExpr);
}
+ else {
+ typeAlternative.setNamespaceContext(new
NamespaceSupport(schemaDoc.fNamespaceSupport));
+ }
+
+ typeAlternative.setBaseURI(altElement.getBaseURI());
if (xpathNS != null) {
//set the xpathDefaultNamespace attribute value
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]