You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by el...@apache.org on 2001/10/09 22:09:46 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/impl/v2 CMBuilder.java XSAttributeChecker.java XSDNotationTraverser.java XSDSimpleTypeTraverser.java
elena 01/10/09 13:09:46
Modified: java/src/org/apache/xerces/impl/v2 CMBuilder.java
XSAttributeChecker.java XSDNotationTraverser.java
XSDSimpleTypeTraverser.java
Log:
Bug fixes (NPE and class cast exceptions).
Revision Changes Path
1.9 +14 -15 xml-xerces/java/src/org/apache/xerces/impl/v2/CMBuilder.java
Index: CMBuilder.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/CMBuilder.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- CMBuilder.java 2001/10/04 16:06:09 1.8
+++ CMBuilder.java 2001/10/09 20:09:46 1.9
@@ -64,7 +64,7 @@
* This class constructs content models for a given grammar.
*
* @author Elena Litani, IBM
- * @version $Id: CMBuilder.java,v 1.8 2001/10/04 16:06:09 neilg Exp $
+ * @version $Id: CMBuilder.java,v 1.9 2001/10/09 20:09:46 elena Exp $
*/
public class CMBuilder {
@@ -296,12 +296,14 @@
}
}
- else if (type == XSParticleDecl.PARTICLE_ALL) {
+ else if (type == XSParticleDecl.PARTICLE_ALL) {
XSParticleDecl left = (XSParticleDecl)particle.fValue;
XSParticleDecl right = (XSParticleDecl)particle.fOtherValue;
XSAllCM allContent = new XSAllCM(false);
+
+ System.out.println("***********"+particle.toString());
gatherAllLeaves (left, allContent);
gatherAllLeaves (right, allContent);
return allContent;
@@ -431,23 +433,20 @@
*/
private void gatherAllLeaves(XSParticleDecl particle,
XSAllCM allContent) {
-
- XSParticleDecl left = (XSParticleDecl) particle.fValue;
- XSParticleDecl right = (XSParticleDecl) particle.fOtherValue;
+ Object left = particle.fValue;
+ Object right = particle.fOtherValue;
int type = particle.fType;
if (type == XSParticleDecl.PARTICLE_ALL) {
// At an all node, visit left and right subtrees
-
- gatherAllLeaves (left, allContent);
- gatherAllLeaves (right, allContent);
+ gatherAllLeaves ((XSParticleDecl)left, allContent);
+ gatherAllLeaves ((XSParticleDecl) particle.fOtherValue, allContent);
}
else if (type == XSParticleDecl.PARTICLE_ELEMENT) {
// At leaf, add the element to list of elements permitted in the all
-
- allContent.addElement ((XSElementDecl)(particle.fValue), false);
+ allContent.addElement ((XSElementDecl)left, false);
}
else if (type == XSParticleDecl.PARTICLE_ZERO_OR_ONE) {
@@ -455,17 +454,17 @@
// that was specified with minOccurs=0, maxOccurs=1
// Add the optional element to list of elements permitted in the all
- if (left.fType == XSParticleDecl.PARTICLE_ELEMENT) {
- allContent.addElement ((XSElementDecl)left.fValue, true);
+ if (((XSParticleDecl)left).fType == XSParticleDecl.PARTICLE_ELEMENT) {
+ allContent.addElement ((XSElementDecl)(((XSParticleDecl)left).fValue), true);
}
else {
- // report error
- throw new RuntimeException("ImplementationMessages.VAL_CST");
+ // report error
+ throw new RuntimeException("ImplementationMessages.VAL_CST");
}
}
else {
// report error
- throw new RuntimeException("ImplementationMessages.VAL_CST");
+ throw new RuntimeException("ImplementationMessages.VAL_CSTA");
}
}
1.25 +16 -16 xml-xerces/java/src/org/apache/xerces/impl/v2/XSAttributeChecker.java
Index: XSAttributeChecker.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSAttributeChecker.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- XSAttributeChecker.java 2001/10/05 19:44:35 1.24
+++ XSAttributeChecker.java 2001/10/09 20:09:46 1.25
@@ -89,7 +89,7 @@
* - use symbol table instead of many hashtables
*
* @author Sandy Gao, IBM
- * @version $Id: XSAttributeChecker.java,v 1.24 2001/10/05 19:44:35 neilg Exp $
+ * @version $Id: XSAttributeChecker.java,v 1.25 2001/10/09 20:09:46 elena Exp $
*/
public class XSAttributeChecker {
@@ -582,6 +582,20 @@
oneEle = new OneElement (attrList);
fEleAttrsMapG.put(SchemaSymbols.ELT_COMPLEXTYPE, oneEle);
+ // for element "notation" - local name
+ attrList = new Hashtable();
+ // id = ID
+ attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
+ // name = NCName
+ attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
+ // public = A public identifier, per ISO 8879
+ attrList.put(SchemaSymbols.ATT_PUBLIC, allAttrs[ATT_PUBLIC_R]);
+ // system = anyURI
+ attrList.put(SchemaSymbols.ATT_SYSTEM, allAttrs[ATT_SYSTEM_N]);
+ oneEle = new OneElement (attrList);
+ fEleAttrsMapG.put(SchemaSymbols.ELT_NOTATION, oneEle);
+
+
// for element "complexType" - local name
attrList = new Hashtable();
// id = ID
@@ -755,19 +769,6 @@
oneEle = new OneElement (attrList);
fEleAttrsMapN.put(SchemaSymbols.ELT_FIELD, oneEle);
- // for element "notation" - local name
- attrList = new Hashtable();
- // id = ID
- attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
- // name = NCName
- attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
- // public = A public identifier, per ISO 8879
- attrList.put(SchemaSymbols.ATT_PUBLIC, allAttrs[ATT_PUBLIC_R]);
- // system = anyURI
- attrList.put(SchemaSymbols.ATT_SYSTEM, allAttrs[ATT_SYSTEM_N]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapN.put(SchemaSymbols.ELT_NOTATION, oneEle);
-
// for element "annotation" - global
attrList = new Hashtable();
// id = ID
@@ -979,7 +980,6 @@
XSDocumentInfo schemaDoc) {
if (element == null)
return null;
-
// update NamespaceSupport
resolveNamespace(element, schemaDoc.fNamespaceSupport);
@@ -1005,6 +1005,7 @@
// get desired attribute list of this element
OneElement oneEle = (OneElement)eleAttrsMap.get(elName);
if (oneEle == null) {
+
reportSchemaError ("s4s-elt-invalid", new Object[] {elName});
return null;
}
@@ -1118,7 +1119,6 @@
attrValues[oneAttr.valueIndex] = oneAttr.dfltValue;
}
}
-
// traverse all required attributes
OneAttr[] reqAttrs = oneEle.attrArray;
for (int i = 0; i < reqAttrs.length; i++) {
1.11 +3 -4 xml-xerces/java/src/org/apache/xerces/impl/v2/XSDNotationTraverser.java
Index: XSDNotationTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSDNotationTraverser.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- XSDNotationTraverser.java 2001/09/24 15:24:55 1.10
+++ XSDNotationTraverser.java 2001/10/09 20:09:46 1.11
@@ -75,7 +75,7 @@
*
* @author Rahul Srivastava, Sun Microsystems Inc.
* @author Elena Litani, IBM
- * @version $Id: XSDNotationTraverser.java,v 1.10 2001/09/24 15:24:55 sandygao Exp $
+ * @version $Id: XSDNotationTraverser.java,v 1.11 2001/10/09 20:09:46 elena Exp $
*/
class XSDNotationTraverser extends XSDAbstractTraverser {
@@ -90,12 +90,11 @@
// General Attribute Checking for elmNode
Object[] attrValues = fAttrChecker.checkAttributes(elmNode, true, schemaDoc);
-
//get attributes
String nameAttr = (String) attrValues[XSAttributeChecker.ATTIDX_NAME];
+
String publicAttr = (String) attrValues[XSAttributeChecker.ATTIDX_PUBLIC];
String systemAttr = (String) attrValues[XSAttributeChecker.ATTIDX_SYSTEM];
-
if (nameAttr.length() == 0) {
//REVISIT: update error message
reportGenericSchemaError("<notation> must have a name");
@@ -129,7 +128,7 @@
XMLErrorReporter.SEVERITY_ERROR);
}
}
-
+ grammar.addGlobalNotationDecl(notation);
fAttrChecker.returnAttrArray(attrValues, schemaDoc);
return notation;
1.20 +2 -2 xml-xerces/java/src/org/apache/xerces/impl/v2/XSDSimpleTypeTraverser.java
Index: XSDSimpleTypeTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSDSimpleTypeTraverser.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- XSDSimpleTypeTraverser.java 2001/10/07 17:17:41 1.19
+++ XSDSimpleTypeTraverser.java 2001/10/09 20:09:46 1.20
@@ -109,7 +109,7 @@
* </union>
*
* @author Elena Litani, IBM
- * @version $Id: XSDSimpleTypeTraverser.java,v 1.19 2001/10/07 17:17:41 lmartin Exp $
+ * @version $Id: XSDSimpleTypeTraverser.java,v 1.20 2001/10/09 20:09:46 elena Exp $
*/
class XSDSimpleTypeTraverser extends XSDAbstractTraverser {
@@ -411,7 +411,7 @@
newDV = new UnionDatatypeValidator(dTValidators);
}
- if (newDV != null) {
+ if (newDV != null && isGlobal) {
newDV.setFinalSet(finalProperty);
((AbstractDatatypeValidator)newDV).fLocalName = nameProperty;
fGrammar.addGlobalTypeDecl(newDV);
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org