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/22 20:53:02 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/impl/v2 XSDAbstractTraverser.java XSAttributeGroupDecl.java
sandygao 01/10/22 11:53:02
Modified: java/src/org/apache/xerces/impl/v2 XSDAbstractTraverser.java
XSAttributeGroupDecl.java
Log:
Remove prohibited attribute uses after we finished traversed all attributes, attribute groups, and attribute wildcard.
Revision Changes Path
1.35 +7 -7 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.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- XSDAbstractTraverser.java 2001/10/22 13:33:33 1.34
+++ XSDAbstractTraverser.java 2001/10/22 18:53:02 1.35
@@ -77,7 +77,7 @@
* @author Elena Litani, IBM
* @author Rahul Srivastava, Sun Microsystems Inc.
*
- * @version $Id: XSDAbstractTraverser.java,v 1.34 2001/10/22 13:33:33 sandygao Exp $
+ * @version $Id: XSDAbstractTraverser.java,v 1.35 2001/10/22 18:53:02 sandygao Exp $
*/
abstract class XSDAbstractTraverser {
@@ -368,6 +368,7 @@
attrGrp.addAttributeUse(tempAttrUse);
}
else {
+ // REVISIT: what if one of the attribute uses is "prohibited"
reportGenericSchemaError("Duplicate attribute " +
tempAttrUse.fAttrDecl.fName + " found ");
}
@@ -386,6 +387,7 @@
attrGrp.addAttributeUse(attrUseS[i]);
}
else {
+ // REVISIT: what if one of the attribute uses is "prohibited"
reportGenericSchemaError("Duplicate attribute " +
existingAttrUse.fAttrDecl.fName + " found ");
}
@@ -421,15 +423,13 @@
}
child = DOMUtil.getNextSiblingElement(child);
}
-
- if (child != null) {
- // Error - the element is not an attribute, attributeGroup or anyAttr
- return child;
- }
}
+ // remove prohibited attribute uses
+ attrGrp.removeProhibitedAttrs();
+
// Success
- return null;
+ return child;
}
1.9 +50 -19 xml-xerces/java/src/org/apache/xerces/impl/v2/XSAttributeGroupDecl.java
Index: XSAttributeGroupDecl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSAttributeGroupDecl.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- XSAttributeGroupDecl.java 2001/10/11 20:07:29 1.8
+++ XSAttributeGroupDecl.java 2001/10/22 18:53:02 1.9
@@ -66,7 +66,7 @@
* @author Sandy Gao, IBM
* @author Rahul Srivastava, Sun Microsystems Inc.
*
- * @version $Id: XSAttributeGroupDecl.java,v 1.8 2001/10/11 20:07:29 lmartin Exp $
+ * @version $Id: XSAttributeGroupDecl.java,v 1.9 2001/10/22 18:53:02 sandygao Exp $
*/
public class XSAttributeGroupDecl {
@@ -96,13 +96,44 @@
}
public XSAttributeUse getAttributeUse(String uri, String localpart) {
- for (int i=0; i<fAttrUseNum; i++) {
- if ( (fAttributeUses[i].fAttrDecl.fTargetNamespace == uri) &&
- (fAttributeUses[i].fAttrDecl.fName == localpart) )
- return fAttributeUses[i];
- }
-
- return null;
+ for (int i=0; i<fAttrUseNum; i++) {
+ if ( (fAttributeUses[i].fAttrDecl.fTargetNamespace == uri) &&
+ (fAttributeUses[i].fAttrDecl.fName == localpart) )
+ return fAttributeUses[i];
+ }
+
+ return null;
+ }
+
+ public void removeProhibitedAttrs() {
+ int pCount = 0;
+ XSAttributeUse[] pUses = new XSAttributeUse[fAttrUseNum];
+ for (int i = 0; i < fAttrUseNum; i++) {
+ if (fAttributeUses[i].fUse == SchemaSymbols.USE_PROHIBITED) {
+ pCount++;
+ // we use the entries at the end, so that we can use the
+ // first entries to store non-prohibited attribute uses,
+ // hence avoid creating a new array.
+ pUses[fAttrUseNum-pCount] = fAttributeUses[i];
+ }
+ }
+
+ int newCount = 0;
+ if (pCount > 0) {
+ for (int i = 0; i < fAttrUseNum; i++) {
+ if (fAttributeUses[i].fUse == SchemaSymbols.USE_PROHIBITED)
+ continue;
+ for (int j = 1; j <= pCount; j++) {
+ if (fAttributeUses[i].fAttrDecl.fName == pUses[fAttrUseNum-pCount].fAttrDecl.fName &&
+ fAttributeUses[i].fAttrDecl.fTargetNamespace == pUses[fAttrUseNum-pCount].fAttrDecl.fTargetNamespace) {
+ continue;
+ }
+ }
+ pUses[newCount++] = fAttributeUses[i];
+ }
+ fAttributeUses = pUses;
+ fAttrUseNum = newCount;
+ }
}
public XSAttributeUse[] getAttributeUses() {
@@ -112,8 +143,8 @@
return fAttributeUses;
}
- // Check that the attributes in this group validly restrict those from a base group
- // If an error is found, the error code is returned.
+ // Check that the attributes in this group validly restrict those from a base group
+ // If an error is found, the error code is returned.
public String validRestrictionOf(XSAttributeGroupDecl baseGroup) {
String errorCode = null;
@@ -129,7 +160,7 @@
//
// derivation-ok-restriction. Constraint 2.1.1
//
- if (baseAttrUse.fUse == SchemaSymbols.USE_REQUIRED &&
+ if (baseAttrUse.fUse == SchemaSymbols.USE_REQUIRED &&
attrUse.fUse != SchemaSymbols.USE_REQUIRED) {
errorCode = "derivation-ok-restriction.2.1.1";
return errorCode;
@@ -142,15 +173,15 @@
if (! XSConstraints.checkSimpleDerivationOk(attrDecl.fType,
baseAttrDecl.fType,
baseAttrDecl.fType.getFinalSet()) ) {
- errorCode="derivation-ok-restriction.2.1.2";
- return errorCode;
+ errorCode="derivation-ok-restriction.2.1.2";
+ return errorCode;
}
+
-
//
// derivation-ok-restriction. Constraint 2.1.3
//
- if (baseAttrDecl.fConstraintType == XSAttributeDecl.FIXED_VALUE &&
+ if (baseAttrDecl.fConstraintType == XSAttributeDecl.FIXED_VALUE &&
attrDecl.fConstraintType != XSAttributeDecl.FIXED_VALUE) {
errorCode="derivation-ok-restriction.2.1.3";
return errorCode;
@@ -170,8 +201,8 @@
return errorCode;
}
}
- }
-
+ }
+
// Now, check wildcards
//
@@ -187,8 +218,8 @@
return errorCode;
}
}
-
- return null;
+
+ return null;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org