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 22:38:23 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/impl/v2 XSDComplexTypeTraverser.java XSDAbstractTraverser.java XSAttributeGroupDecl.java
sandygao 01/10/22 13:38:23
Modified: java/src/org/apache/xerces/impl/v2
XSDComplexTypeTraverser.java
XSDAbstractTraverser.java XSAttributeGroupDecl.java
Log:
Report error when there are more than one attribute uses of type ID.
Revision Changes Path
1.33 +8 -3 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.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- XSDComplexTypeTraverser.java 2001/10/22 19:27:15 1.32
+++ XSDComplexTypeTraverser.java 2001/10/22 20:38:22 1.33
@@ -80,7 +80,7 @@
* ((group | all | choice | sequence)?,
* ((attribute | attributeGroup)*, anyAttribute?))))
* </complexType>
- * @version $Id: XSDComplexTypeTraverser.java,v 1.32 2001/10/22 19:27:15 elena Exp $
+ * @version $Id: XSDComplexTypeTraverser.java,v 1.33 2001/10/22 20:38:22 sandygao Exp $
*/
class XSDComplexTypeTraverser extends XSDAbstractParticleTraverser {
@@ -713,8 +713,13 @@
existingAttrUse = toAttrGrp.getAttributeUse(attrUseS[i].fAttrDecl.fTargetNamespace,
attrUseS[i].fAttrDecl.fName);
if (existingAttrUse == null) {
- toAttrGrp.addAttributeUse(attrUseS[i]);
- }
+ String idName = toAttrGrp.addAttributeUse(attrUseS[i]);
+ if (idName != null) {
+ reportGenericSchemaError("Two distinct members of the {attribute uses} '" +
+ idName + "' and '" + attrUseS[i].fAttrDecl.fName +
+ "' have {attribute declaration}s both of whose {type definition}s are or are derived from ID");
+ }
+ }
else {
if (extension) {
//REVISIT - should create a msg in properties file
1.37 +15 -5 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.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- XSDAbstractTraverser.java 2001/10/22 19:27:15 1.36
+++ XSDAbstractTraverser.java 2001/10/22 20:38:23 1.37
@@ -77,7 +77,7 @@
* @author Elena Litani, IBM
* @author Rahul Srivastava, Sun Microsystems Inc.
*
- * @version $Id: XSDAbstractTraverser.java,v 1.36 2001/10/22 19:27:15 elena Exp $
+ * @version $Id: XSDAbstractTraverser.java,v 1.37 2001/10/22 20:38:23 sandygao Exp $
*/
abstract class XSDAbstractTraverser {
@@ -290,7 +290,7 @@
// ---------------------------------------------
fPattern.append("|");
fPattern.append(DOMUtil.getAttrValue(content, SchemaSymbols.ATT_VALUE ));
-
+
Element child = DOMUtil.getFirstChildElement( content );
if (child != null) {
// traverse annotation if any
@@ -353,7 +353,7 @@
flags |= facetType;
}
fFacetData.put(facet,content.getAttribute( SchemaSymbols.ATT_VALUE ));
-
+
Element child = DOMUtil.getFirstChildElement( content );
if (child != null) {
// traverse annotation if any
@@ -407,7 +407,12 @@
if (tempAttrUse == null) break;
if (attrGrp.getAttributeUse(tempAttrUse.fAttrDecl.fTargetNamespace,
tempAttrUse.fAttrDecl.fName)==null) {
- attrGrp.addAttributeUse(tempAttrUse);
+ String idName = attrGrp.addAttributeUse(tempAttrUse);
+ if (idName != null) {
+ reportGenericSchemaError("Two distinct members of the {attribute uses} '" +
+ idName + "' and '" + tempAttrUse.fAttrDecl.fName +
+ "' have {attribute declaration}s both of whose {type definition}s are or are derived from ID");
+ }
}
else {
// REVISIT: what if one of the attribute uses is "prohibited"
@@ -426,7 +431,12 @@
existingAttrUse = attrGrp.getAttributeUse(attrUseS[i].fAttrDecl.fTargetNamespace,
attrUseS[i].fAttrDecl.fName);
if (existingAttrUse == null) {
- attrGrp.addAttributeUse(attrUseS[i]);
+ String idName = attrGrp.addAttributeUse(attrUseS[i]);
+ if (idName != null) {
+ reportGenericSchemaError("Two distinct members of the {attribute uses} '" +
+ idName + "' and '" + attrUseS[i].fAttrDecl.fName +
+ "' have {attribute declaration}s both of whose {type definition}s are or are derived from ID");
+ }
}
else {
// REVISIT: what if one of the attribute uses is "prohibited"
1.10 +20 -5 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.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- XSAttributeGroupDecl.java 2001/10/22 18:53:02 1.9
+++ XSAttributeGroupDecl.java 2001/10/22 20:38:23 1.10
@@ -66,7 +66,7 @@
* @author Sandy Gao, IBM
* @author Rahul Srivastava, Sun Microsystems Inc.
*
- * @version $Id: XSAttributeGroupDecl.java,v 1.9 2001/10/22 18:53:02 sandygao Exp $
+ * @version $Id: XSAttributeGroupDecl.java,v 1.10 2001/10/22 20:38:23 sandygao Exp $
*/
public class XSAttributeGroupDecl {
@@ -84,15 +84,30 @@
// whether there is an attribute use whose type is or is derived from ID.
public String fIDAttrName = null;
- void addAttributeUse(XSAttributeUse attrUse) {
+ // add an attribute use
+ // if the type is derived from ID, but there is already another attribute
+ // use of type ID, then return the name of the other attribute use;
+ // otherwise, return null
+ String addAttributeUse(XSAttributeUse attrUse) {
if (fAttrUseNum == fAttributeUses.length) {
fAttributeUses = resize(fAttributeUses, fAttrUseNum*2);
}
fAttributeUses[fAttrUseNum++] = attrUse;
- if (fIDAttrName == null &&
- attrUse.fAttrDecl.fType instanceof IDDatatypeValidator) {
- fIDAttrName = attrUse.fAttrDecl.fName;
+
+ // if this attribute use is prohibited, then don't check whether it's
+ // of type ID
+ if (attrUse.fUse == SchemaSymbols.USE_PROHIBITED)
+ return null;
+
+ if (attrUse.fAttrDecl.fType instanceof IDDatatypeValidator) {
+ // if there is already an attribute use of type ID, return it' sname
+ if (fIDAttrName == null)
+ fIDAttrName = attrUse.fAttrDecl.fName;
+ else
+ return fIDAttrName;
}
+
+ return null;
}
public XSAttributeUse getAttributeUse(String uri, String localpart) {
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org