You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by sa...@apache.org on 2001/10/24 00:34:54 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/impl/v2 XSWildcardDecl.java XSDComplexTypeTraverser.java XSDAbstractTraverser.java
sandygao 01/10/23 15:34:54
Modified: java/src/org/apache/xerces/impl/v2 XSWildcardDecl.java
XSDComplexTypeTraverser.java
XSDAbstractTraverser.java
Log:
new wildcard decl implementation, which supports the (correct) subset/intersection/union operations.
thanks to Rahul's patch (though part of the partch was modified.)
Revision Changes Path
1.14 +341 -216 xml-xerces/java/src/org/apache/xerces/impl/v2/XSWildcardDecl.java
Index: XSWildcardDecl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSWildcardDecl.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- XSWildcardDecl.java 2001/10/18 21:54:35 1.13
+++ XSWildcardDecl.java 2001/10/23 22:34:53 1.14
@@ -67,10 +67,13 @@
* @author Sandy Gao, IBM
* @author Rahul Srivastava, Sun Microsystems Inc.
*
- * @version $Id: XSWildcardDecl.java,v 1.13 2001/10/18 21:54:35 sandygao Exp $
+ * @version $Id: XSWildcardDecl.java,v 1.14 2001/10/23 22:34:53 sandygao Exp $
*/
public class XSWildcardDecl {
+ //REVISIT: Should this be here. Is this required at all.
+ public static final String ABSENT = null;
+
// types of wildcard
// namespace="##any"
public static final short WILDCARD_ANY = 0;
@@ -96,290 +99,412 @@
// for WILDCARD_OTHER, it means not any of the namespaces in the list
public String[] fNamespaceList;
+ // I'm trying to implement the following constraint exactly as what the
+ // spec describes. Sometimes it seems redundant, and sometimes there seems
+ // to be much easier solutions. But it makes it easy to understand,
+ // easy to maintain, and easy to find a bug (either in the code, or in the
+ // spec). -SG
+ //
+ // NOTE: Schema spec only requires that ##other not(tNS,absent).
+ // The way we store ##other is not(NS1,NS2,...,NSN), which covers
+ // what's required by Schema, and allows future enhanced features.
+ //
+ // In the following in-line comments:
+ // - Bullet removed from w3c specification.
+ // + Bullet added as proposed by Sandy Gao, IBM.
+ // / Since we store ##other as not(NS1,NS2,...,NSN), we need to put some
+ // comments on where we didn't follow the spec exactly.
+ // * When we really support not(NS1,NS2,...,NSN), we need to revisit these items.
+
/**
- * Whether a namespace is allowed by this wildcard
+ * Validation Rule: Wildcard allows Namespace Name
*/
public boolean allowNamespace(String namespace) {
- // ##any allows any namespace
+ // For a value which is either a namespace name or �absent� to be �valid� with respect to a wildcard constraint (the value of a {namespace constraint}) one of the following must be true:
+
+ // 1 The constraint must be any.
if (fType == WILDCARD_ANY)
return true;
- // ##other doesn't allow target namespace and empty namespace
+ // 2 All of the following must be true:
+ // 2.1 The constraint is a pair of not and a namespace name or �absent� ([Definition:] call this the namespace test).
+ // 2.2 The value must not be identical to the �namespace test�.
+ // 2.3 The value must not be �absent�.
+ // / we store ##other as not(list), so our actual rule is
+ // / 2 The constraint is a pair of not and a set, and the value is not in such set.
if (fType == WILDCARD_OTHER) {
- return namespace != fNamespaceList[0] &&
- namespace != fNamespaceList[1];
- }
+ boolean found = false;
+ int listNum = fNamespaceList.length;
+ for (int i = 0; i < listNum && !found; i++) {
+ if (namespace == fNamespaceList[i])
+ found = true;
+ }
- // list allows any one in the list
- int listNum = fNamespaceList.length;
- for (int i = 0; i < listNum; i++) {
- if (namespace == fNamespaceList[i])
+ if (!found)
return true;
}
+ // 3 The constraint is a set, and the value is identical to one of the members of the set.
+ if (fType == WILDCARD_LIST) {
+ int listNum = fNamespaceList.length;
+ for (int i = 0; i < listNum; i++) {
+ if (namespace == fNamespaceList[i])
+ return true;
+ }
+ }
+
+ // none of the above conditions applied, so return false.
return false;
}
-
- //NOTE: ##OTHER means not targetNamespace, according to spec.
- // We are not considering it as, not and a set of URI's, where targetNamespace is
- // one of the element in the set. This may be taken as an enhanced feature, later.
+ /**
+ * Schema Component Constraint: Wildcard Subset
+ */
public boolean isSubsetOf(XSWildcardDecl superWildcard) {
- // For a namespace constraint (call it sub) to be an intensional subset of another namespace
- // constraint (call it super) one of the following must be true:
+ // if the super is null (not expressible), return false
+ if (superWildcard == null)
+ return false;
+
+ // For a namespace constraint (call it sub) to be an intensional subset of another
+ // namespace constraint (call it super) one of the following must be true:
// 1 super must be any.
- if (superWildcard.fType == WILDCARD_ANY) {
- return true;
- }
- // 2 All of the following must be true:
- // 2.1 sub must be a pair of not and a namespace name or �absent�.
- // 2.2 super must be a pair of not and the same value.
- else if ( (fType == WILDCARD_OTHER) && (superWildcard.fType == WILDCARD_OTHER) ){
- return (fNamespaceList[0] == superWildcard.fNamespaceList[0]);
- }
- // 3 All of the following must be true:
- // 3.1 sub must be a set whose members are either namespace names or �absent�.
- // 3.2 One of the following must be true:
- // 3.2.1 super must be the same set or a superset thereof.
- // 3.2.2 super must be a pair of not and a namespace name or �absent� and
- // that value must not be in sub's set.
- else if (fType == WILDCARD_LIST) {
- if (superWildcard.fType == WILDCARD_LIST) {
- boolean found;
-
- for (int i=0; i<fNamespaceList.length; i++) {
- found = false;
- for (int j=0; j<superWildcard.fNamespaceList.length; j++)
- if (fNamespaceList[i] == superWildcard.fNamespaceList[j]) {
- found = true;
- break;
- }
- if (!found) return false;
- }
+ if (superWildcard.fType == WILDCARD_ANY) {
return true;
}
- else if (superWildcard.fType == WILDCARD_OTHER) {
- for (int i=0; i<fNamespaceList.length; i++) {
- if (superWildcard.fNamespaceList[0] == fNamespaceList[i])
- return false;
+
+ // 2 All of the following must be true:
+ // 2.1 sub must be a pair of not and a namespace name or �absent�.
+ // 2.2 super must be a pair of not and the same value.
+ // * we can't just compare whether the namespace are the same value
+ // since we store other as not(list)
+ if (fType == WILDCARD_OTHER) {
+ if (superWildcard.fType == WILDCARD_OTHER &&
+ fNamespaceList[0] == superWildcard.fNamespaceList[0]) {
+ return true;
}
- return true;
}
- }
- return false;
- }
+ // 3 All of the following must be true:
+ // 3.1 sub must be a set whose members are either namespace names or �absent�.
+ // 3.2 One of the following must be true:
+ // 3.2.1 super must be the same set or a superset thereof.
+ // -3.2.2 super must be a pair of not and a namespace name or �absent� and
+ // that value must not be in sub's set.
+ // +3.2.2 super must be a pair of not and a namespace name or �absent� and
+ // either that value or �absent� must not be in sub's set.
+ // * since we store ##other as not(list), we acturally need to make sure
+ // that none of the namespaces in super.list is in sub.list.
+ if (fType == WILDCARD_LIST) {
+ if (superWildcard.fType == WILDCARD_LIST &&
+ subset2sets(fNamespaceList, superWildcard.fNamespaceList)) {
+ return true;
+ }
+ if (superWildcard.fType == WILDCARD_OTHER &&
+ !elementInSet(superWildcard.fNamespaceList[0], fNamespaceList) &&
+ !elementInSet(ABSENT, fNamespaceList)) {
+ return true;
+ }
+ }
- public XSWildcardDecl performUnionWith(XSWildcardDecl wildcard) {
- // For a wildcard's {namespace constraint} value to be the intensional union of two other such
- // values (call them O1 and O2): the appropriate case among the following must be true:
+ // none of the above conditions applied, so return false.
+ return false;
- XSWildcardDecl unionWildcard = new XSWildcardDecl();
+ } // isSubsetOf
+ /**
+ * Schema Component Constraint: Attribute Wildcard Union
+ */
+ public XSWildcardDecl performUnionWith(XSWildcardDecl wildcard,
+ short processContents) {
+ // if the other wildcard is not expressible, the result is still not expressible
+ if (wildcard == null)
+ return null;
+
+ // For a wildcard's {namespace constraint} value to be the intensional union of two
+ // other such values (call them O1 and O2): the appropriate case among the following
+ // must be true:
+
+ XSWildcardDecl unionWildcard = new XSWildcardDecl();
+ unionWildcard.fProcessContents = processContents;
+
// 1 If O1 and O2 are the same value, then that value must be the value.
- if (areSame(wildcard)) {
- unionWildcard.fType = fType;
- if (fType != WILDCARD_ANY)
- //REVISIT: Is it okay to copy like this.
+ if (areSame(wildcard)) {
+ unionWildcard.fType = fType;
unionWildcard.fNamespaceList = fNamespaceList;
- }
- // 2 If either O1 or O2 is any, then any must be the value.
- else if ( (fType == WILDCARD_ANY) || (wildcard.fType == WILDCARD_ANY) ) {
- unionWildcard.fType = WILDCARD_ANY;
- }
- // 3 If both O1 and O2 are sets of (namespace names or �absent�), then the union of those sets
- // must be the value.
- else if ( (fType == WILDCARD_LIST) && (wildcard.fType == WILDCARD_LIST) ) {
- boolean found;
- Vector union = null;
-
- // This way, the vector may be resized exactly once or none.
- if (fNamespaceList.length > wildcard.fNamespaceList.length)
- union = new Vector(fNamespaceList.length, wildcard.fNamespaceList.length);
- else
- union = new Vector(wildcard.fNamespaceList.length, fNamespaceList.length);
-
- for (int i=0; i<fNamespaceList.length; i++)
- union.addElement(fNamespaceList[i]);
-
- for (int i=0; i<wildcard.fNamespaceList.length; i++) {
- found = false;
- for (int j=0; j<fNamespaceList.length; j++)
- if (fNamespaceList[j] == wildcard.fNamespaceList[i]) {
- found = true;
- break;
- }
- if (!found)
- union.addElement(wildcard.fNamespaceList[i]);
}
+ // 2 If either O1 or O2 is any, then any must be the value.
+ else if ( (fType == WILDCARD_ANY) || (wildcard.fType == WILDCARD_ANY) ) {
+ unionWildcard.fType = WILDCARD_ANY;
+ }
+
+ // 3 If both O1 and O2 are sets of (namespace names or �absent�), then the union of
+ // those sets must be the value.
+ else if ( (fType == WILDCARD_LIST) && (wildcard.fType == WILDCARD_LIST) ) {
unionWildcard.fType = WILDCARD_LIST;
- // copy elements from vector to array
- int size = union.size();
- unionWildcard.fNamespaceList = new String[size];
- union.copyInto(unionWildcard.fNamespaceList);
- }
+ unionWildcard.fNamespaceList = union2sets(fNamespaceList, wildcard.fNamespaceList);
+ }
- //REVISIT: 4 If the two are negations of different namespace names, then the intersection is not expressible.
+ // -4 If the two are negations of different namespace names, then the intersection
+ // is not expressible.
+ // +4 If the two are negations of different namespace names or �absent�, then
+ // a pair of not and �absent� must be the value.
+ // * now we store ##other as not(list), the result should be
+ // not(intersection of two lists).
+ else if (fType == WILDCARD_OTHER && wildcard.fType == WILDCARD_OTHER) {
+ unionWildcard.fType = WILDCARD_OTHER;
+ unionWildcard.fNamespaceList = new String[2];
+ unionWildcard.fNamespaceList[0] = ABSENT;
+ unionWildcard.fNamespaceList[1] = ABSENT;
+ }
+
+ // 5 If either O1 or O2 is a pair of not and a namespace name and the other is a set of
+ // (namespace names or �absent�), then The appropriate case among the following must be true:
+ // -5.1 If the set includes the negated namespace name, then any must be the value.
+ // -5.2 If the set does not include the negated namespace name, then whichever of O1 or O2
+ // is a pair of not and a namespace name must be the value.
+ // +5.1 If the negated value is a namespace name, then The appropriate case
+ // among the following must be true:
+ // +5.1.1 If the set includes both the namespace name and �absent�, then any
+ // must be the value.
+ // +5.1.2 If the set includes the namespace name but does not include
+ // �absent�, then a pair of not and �absent� must be the value.
+ // +5.1.3 If the set does not include the namespace name but includes
+ // �absent�, then the union is not expressible.
+ // +5.1.4 If the set does not include either the namespace name or �absent�,
+ // then whichever of O1 or O2 is a pair of not and a namespace name must be
+ // the value.
+ // +5.2 If the negated value is �absent�, then The appropriate case among the
+ // following must be true:
+ // +5.2.1 If the set includes �absent�, then any must be the value.
+ // +5.2.2 If the set does not include �absent�, then whichever of O1 or O2 is
+ // a pair of not and a namespace name must be the value.
+ // * when we have not(list), the operation is just not(otherlist-list)
+ else if ( ((fType == WILDCARD_OTHER) && (wildcard.fType == WILDCARD_LIST)) ||
+ ((fType == WILDCARD_LIST) && (wildcard.fType == WILDCARD_OTHER)) ) {
+ String[] other = null;
+ String[] list = null;
- // 5 If either O1 or O2 is a pair of not and a namespace name and the other is a set of
- // (namespace names or �absent�), then The appropriate case among the following must be true:
- // 5.1 If the set includes the negated namespace name, then any must be the value.
- // 5.2 If the set does not include the negated namespace name, then whichever of O1 or O2
- // is a pair of not and a namespace name must be the value.
- else if ( ((fType == WILDCARD_OTHER) && (wildcard.fType == WILDCARD_LIST)) ||
- ((fType == WILDCARD_LIST) && (wildcard.fType == WILDCARD_OTHER)) ) {
+ if (fType == WILDCARD_OTHER) {
+ other = fNamespaceList;
+ list = wildcard.fNamespaceList;
+ }
+ else {
+ other = wildcard.fNamespaceList;
+ list = fNamespaceList;
+ }
- int i=0;
+ boolean foundAbsent = elementInSet(ABSENT, list);
- if (fType == WILDCARD_OTHER) {
- for (i=0; i<wildcard.fNamespaceList.length; i++)
- if (fNamespaceList[0] == wildcard.fNamespaceList[i]) {
+ if (other[0] != ABSENT) {
+ boolean foundNS = elementInSet(other[0], list);
+ if (foundNS && foundAbsent) {
unionWildcard.fType = WILDCARD_ANY;
- break;
+ } else if (foundNS && !foundAbsent) {
+ unionWildcard.fType = WILDCARD_OTHER;
+ unionWildcard.fNamespaceList = new String[2];
+ unionWildcard.fNamespaceList[0] = ABSENT;
+ unionWildcard.fNamespaceList[1] = ABSENT;
+ } else if (!foundNS && foundAbsent) {
+ return null;
+ } else { // !foundNS && !foundAbsent
+ unionWildcard.fType = WILDCARD_OTHER;
+ unionWildcard.fNamespaceList = other;
}
- // Loop traversed completely. This means, negated namespace viz. tNS (here)
- // is not in the other list. So, union is other.
- if (i == wildcard.fNamespaceList.length) {
- unionWildcard.fType = fType;
- //REVISIT: Is it okay to copy like this.
- unionWildcard.fNamespaceList = fNamespaceList;
- }
- }
- else {
- for (i=0; i<fNamespaceList.length; i++)
- if (wildcard.fNamespaceList[0] == fNamespaceList[i]) {
+ } else { // other[0] == ABSENT
+ if (foundAbsent) {
unionWildcard.fType = WILDCARD_ANY;
- break;
+ } else { // !foundAbsent
+ unionWildcard.fType = WILDCARD_OTHER;
+ unionWildcard.fNamespaceList = other;
}
- // Loop traversed completely. This means, negated namespace viz. tNS (here)
- // is not in the other list. So, union is other.
- if (i == fNamespaceList.length) {
- unionWildcard.fType = wildcard.fType;
- //REVISIT: Is it okay to copy like this.
- unionWildcard.fNamespaceList = wildcard.fNamespaceList;
}
}
- }
- unionWildcard.fProcessContents = fProcessContents;
- return unionWildcard;
+ return unionWildcard;
} // performUnionWith
-
- public XSWildcardDecl performIntersectionWith(XSWildcardDecl wildcard) {
- // For a wildcard's {namespace constraint} value to be the intensional intersection of two other
- // such values (call them O1 and O2): the appropriate case among the following must be true:
+ /**
+ * Schema Component Constraint: Attribute Wildcard Intersection
+ */
+ public XSWildcardDecl performIntersectionWith(XSWildcardDecl wildcard,
+ short processContents) {
+ // if the other wildcard is not expressible, the result is still not expressible
+ if (wildcard == null)
+ return null;
+
+ // For a wildcard's {namespace constraint} value to be the intensional intersection of
+ // two other such values (call them O1 and O2): the appropriate case among the following
+ // must be true:
- XSWildcardDecl intersectWildcard = new XSWildcardDecl();
+ XSWildcardDecl intersectWildcard = new XSWildcardDecl();
+ intersectWildcard.fProcessContents = processContents;
// 1 If O1 and O2 are the same value, then that value must be the value.
- if (areSame(wildcard)) {
- intersectWildcard.fType = fType;
- if (fType != WILDCARD_ANY)
- //REVISIT: Is it okay to copy like this.
+ if (areSame(wildcard)) {
+ intersectWildcard.fType = fType;
intersectWildcard.fNamespaceList = fNamespaceList;
- }
- // 2 If either O1 or O2 is any, then the other must be the value.
- else if ( (fType == WILDCARD_ANY) || (wildcard.fType == WILDCARD_ANY) ) {
- if (fType == WILDCARD_ANY) {
- intersectWildcard.fType = wildcard.fType;
- // both cannot be ANY, if we have reached here.
- //REVISIT: Is it okay to copy like this.
- intersectWildcard.fNamespaceList = wildcard.fNamespaceList;
}
- else {
- intersectWildcard.fType = fType;
+
+ // 2 If either O1 or O2 is any, then the other must be the value.
+ else if ( (fType == WILDCARD_ANY) || (wildcard.fType == WILDCARD_ANY) ) {
// both cannot be ANY, if we have reached here.
- //REVISIT: Is it okay to copy like this.
- intersectWildcard.fNamespaceList = fNamespaceList;
+ XSWildcardDecl other = this;
+
+ if (fType == WILDCARD_ANY)
+ other = wildcard;
+
+ intersectWildcard.fType = other.fType;
+ intersectWildcard.fNamespaceList = other.fNamespaceList;
}
- }
- // 3 If either O1 or O2 is a pair of not and a namespace name and the other is a set of
- // (namespace names or �absent�), then that set, minus the negated namespace name if it was in
- // the set, must be the value.
- else if ( ((fType == WILDCARD_OTHER) && (wildcard.fType == WILDCARD_LIST)) ||
- ((fType == WILDCARD_LIST) && (wildcard.fType == WILDCARD_OTHER)) ) {
- Vector intersect = null;
+
+ // -3 If either O1 or O2 is a pair of not and a namespace name and the other is a set of
+ // (namespace names or �absent�), then that set, minus the negated namespace name if
+ // it was in the set, must be the value.
+ // +3 If either O1 or O2 is a pair of not and a namespace name and the other
+ // is a set of (namespace names or �absent�), then that set, minus the negated
+ // namespace name if it was in the set, then minus �absent� if it was in the
+ // set, must be the value.
+ // * when we have not(list), the operation is just list-otherlist
+ else if ( ((fType == WILDCARD_OTHER) && (wildcard.fType == WILDCARD_LIST)) ||
+ ((fType == WILDCARD_LIST) && (wildcard.fType == WILDCARD_OTHER)) ) {
+ String[] list = null;
+ String[] other = null;
+
if (fType == WILDCARD_OTHER) {
- intersect = new Vector(wildcard.fNamespaceList.length);
- for (int i=0; i<wildcard.fNamespaceList.length; i++)
- if (fNamespaceList[0] != wildcard.fNamespaceList[i])
- intersect.addElement(wildcard.fNamespaceList[i]);
+ other = fNamespaceList;
+ list = wildcard.fNamespaceList;
}
else {
- intersect = new Vector(fNamespaceList.length);
- for (int i=0; i<fNamespaceList.length; i++)
- if (wildcard.fNamespaceList[0] != fNamespaceList[i])
- intersect.addElement(fNamespaceList[i]);
- }
- intersectWildcard.fType = WILDCARD_LIST;
- // copy elements from vector to array
- int size = intersect.size();
- intersectWildcard.fNamespaceList = new String[size];
- intersect.copyInto(intersectWildcard.fNamespaceList);
- }
- // 4 If both O1 and O2 are sets of (namespace names or �absent�), then the intersection of those
- // sets must be the value.
- else if ( (fType == WILDCARD_LIST) && (wildcard.fType == WILDCARD_LIST) ) {
- boolean found;
- Vector intersect = null;
-
- if (fNamespaceList.length < wildcard.fNamespaceList.length)
- intersect = new Vector(fNamespaceList.length);
- else
- intersect = new Vector(wildcard.fNamespaceList.length);
-
- for (int i=0; i<fNamespaceList.length; i++) {
- found = false;
- for (int j=0; j<wildcard.fNamespaceList.length; j++)
- if (fNamespaceList[i] == wildcard.fNamespaceList[j]) {
- found = true;
- break;
- }
- if (found)
- intersect.addElement(fNamespaceList[i]);
- }
+ other = wildcard.fNamespaceList;
+ list = fNamespaceList;
+ }
- intersectWildcard.fType = WILDCARD_LIST;
- // copy elements from vector to array
- int size = intersect.size();
- intersectWildcard.fNamespaceList = new String[size];
- intersect.copyInto(intersectWildcard.fNamespaceList);
- }
- //REVISIT: 5 If the two are negations of different namespace names, then the intersection is not expressible.
+ int listSize = list.length;
+ String[] intersect = new String[listSize];
+ int newSize = 0;
+ for (int i = 0; i < listSize; i++) {
+ if (list[i] != other[0] && list[i] != ABSENT)
+ intersect[newSize++] = list[i];
+ }
+
+ intersectWildcard.fType = WILDCARD_LIST;
+ intersectWildcard.fNamespaceList = new String[newSize];
+ System.arraycopy(intersect, 0, intersectWildcard.fNamespaceList, 0, newSize);
+ }
+
+ // 4 If both O1 and O2 are sets of (namespace names or �absent�), then the intersection of those
+ // sets must be the value.
+ else if ( (fType == WILDCARD_LIST) && (wildcard.fType == WILDCARD_LIST) ) {
+ intersectWildcard.fType = WILDCARD_LIST;
+ intersectWildcard.fNamespaceList = intersect2sets(fNamespaceList, wildcard.fNamespaceList);
+ }
+
+ // -5 If the two are negations of different namespace names, then the intersection is not expressible.
+ // +5 If the two are negations of namespace names or �absent�, then The
+ // appropriate case among the following must be true:
+ // +5.1 If the two are negations of different namespace names, then the
+ // intersection is not expressible.
+ // +5.2 If one of the two is a pair of not and �absent�, the other must be
+ // the value.
+ // * when we have not(list), the operation is just not(onelist+otherlist)
+ else if (fType == WILDCARD_OTHER && wildcard.fType == WILDCARD_OTHER) {
+ if (fNamespaceList[0] != ABSENT && wildcard.fNamespaceList[0] != ABSENT)
+ return null;
+
+ XSWildcardDecl other = this;
+ if (fNamespaceList[0] == ABSENT)
+ other = wildcard;
+
+ intersectWildcard.fType = other.fType;
+ intersectWildcard.fNamespaceList = other.fNamespaceList;
+ }
- intersectWildcard.fProcessContents = fProcessContents;
- return intersectWildcard;
+ return intersectWildcard;
} // performIntersectionWith
private boolean areSame(XSWildcardDecl wildcard) {
- if (fType == wildcard.fType) {
- if (fType == WILDCARD_ANY)
- return true;
- else {
+ if (fType == wildcard.fType) {
+ // ##any, true
+ if (fType == WILDCARD_ANY)
+ return true;
+
+ // ##other, only check the negated value
+ // * when we support not(list), we need to check in the same way
+ // as for WILDCARD_LIST.
+ if (fType == WILDCARD_OTHER)
+ return fNamespaceList[0] == wildcard.fNamespaceList[0];
+
+ // ## list, must have the same length,
+ // and each item in one list must appear in the other one
+ // (we are assuming that there are no duplicate items in a list)
if (fNamespaceList.length == wildcard.fNamespaceList.length) {
- int i=0;
- for (; i<fNamespaceList.length; i++) {
- if (fNamespaceList[i] != wildcard.fNamespaceList[i])
- break;
+ for (int i=0; i<fNamespaceList.length; i++) {
+ if (!elementInSet(fNamespaceList[i], wildcard.fNamespaceList))
+ return false;
}
- if (i == fNamespaceList.length)
- return true;
+ return true;
}
}
+
+ return false;
+ } // areSame
+
+ String[] intersect2sets(String[] one, String[] theOther){
+ String[] result = new String[Math.min(one.length,theOther.length)];
+
+ // simple implemention,
+ int count = 0;
+ for (int i=0; i<one.length; i++) {
+ if (elementInSet(one[i], theOther))
+ result[count++] = one[i];
+ }
+
+ String[] result2 = new String[count];
+ System.arraycopy(result, 0, result2, 0, count);
+
+ return result2;
}
- return false;
+ String[] union2sets(String[] one, String[] theOther){
+ String[] result1 = new String[one.length];
- } // areSame
+ // simple implemention,
+ int count = 0;
+ for (int i=0; i<one.length; i++) {
+ if (!elementInSet(one[i], theOther))
+ result1[count++] = one[i];
+ }
+
+ String[] result2 = new String[count+theOther.length];
+ System.arraycopy(result1, 0, result2, 0, count);
+ System.arraycopy(theOther, 0, result2, count, theOther.length);
+
+ return result2;
+ }
+
+ boolean subset2sets(String[] subSet, String[] superSet){
+ for (int i=0; i<subSet.length; i++) {
+ if (!elementInSet(subSet[i], superSet))
+ return false;
+ }
- // REVISIT: how to prepresent wildcard in string.
- // "namespace:usr=someuri," is not so descriptive
+ return true;
+ }
+
+ boolean elementInSet(String ele, String[] set){
+ boolean found = false;
+ for (int i=0; i<set.length && !found; i++) {
+ if (ele==set[i])
+ found = true;
+ }
+
+ return found;
+ }
/**
* get the string description of this wildcard
1.35 +5 -2 xml-xerces/java/src/org/apache/xerces/impl/v2/XSDComplexTypeTraverser.java
Index: XSDComplexTypeTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSDComplexTypeTraverser.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- XSDComplexTypeTraverser.java 2001/10/23 19:55:46 1.34
+++ XSDComplexTypeTraverser.java 2001/10/23 22:34:54 1.35
@@ -80,7 +80,7 @@
* ((group | all | choice | sequence)?,
* ((attribute | attributeGroup)*, anyAttribute?))))
* </complexType>
- * @version $Id: XSDComplexTypeTraverser.java,v 1.34 2001/10/23 19:55:46 sandygao Exp $
+ * @version $Id: XSDComplexTypeTraverser.java,v 1.35 2001/10/23 22:34:54 sandygao Exp $
*/
class XSDComplexTypeTraverser extends XSDAbstractParticleTraverser {
@@ -741,7 +741,10 @@
toAttrGrp.fAttributeWC = fromAttrGrp.fAttributeWC;
}
else if (fromAttrGrp.fAttributeWC != null) {
- toAttrGrp.fAttributeWC = toAttrGrp.fAttributeWC.performUnionWith(fromAttrGrp.fAttributeWC);
+ toAttrGrp.fAttributeWC = toAttrGrp.fAttributeWC.performUnionWith(fromAttrGrp.fAttributeWC, toAttrGrp.fAttributeWC.fProcessContents);
+ if (toAttrGrp.fAttributeWC == null) {
+ reportGenericSchemaError("intersection of wildcards is not expressible");
+ }
}
}
1.40 +9 -3 xml-xerces/java/src/org/apache/xerces/impl/v2/XSDAbstractTraverser.java
Index: XSDAbstractTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSDAbstractTraverser.java,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- XSDAbstractTraverser.java 2001/10/23 19:05:02 1.39
+++ XSDAbstractTraverser.java 2001/10/23 22:34:54 1.40
@@ -77,7 +77,7 @@
* @author Elena Litani, IBM
* @author Rahul Srivastava, Sun Microsystems Inc.
*
- * @version $Id: XSDAbstractTraverser.java,v 1.39 2001/10/23 19:05:02 sandygao Exp $
+ * @version $Id: XSDAbstractTraverser.java,v 1.40 2001/10/23 22:34:54 sandygao Exp $
*/
abstract class XSDAbstractTraverser {
@@ -454,7 +454,10 @@
// perform intersection of attribute wildcard
else {
attrGrp.fAttributeWC = attrGrp.fAttributeWC.
- performIntersectionWith(tempAttrGrp.fAttributeWC);
+ performIntersectionWith(tempAttrGrp.fAttributeWC, attrGrp.fAttributeWC.fProcessContents);
+ if (attrGrp.fAttributeWC == null) {
+ reportGenericSchemaError("intersection of wildcards is not expressible");
+ }
}
}
}
@@ -473,7 +476,10 @@
// perform intersection of attribute wildcard
else {
attrGrp.fAttributeWC = tempAttrWC.
- performIntersectionWith(attrGrp.fAttributeWC);
+ performIntersectionWith(attrGrp.fAttributeWC, tempAttrWC.fProcessContents);
+ if (attrGrp.fAttributeWC == null) {
+ reportGenericSchemaError("intersection of wildcards is not expressible");
+ }
}
child = DOMUtil.getNextSiblingElement(child);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org