Hi Neil, Thanks for the comments.
> 1. I don't know if you noticed, but traverseAnnotation(...) already checks > the attributes of the annotation element. Therefore checkContent should not > do so; if this were to happen, we'd risk running into false detections of > multiple ID attributes with the same value. > There are 2 ways of handling <annotation> elements : 1. the traverser should check if there is an annotation element and if there is one call traverseAnnotationDecl(...) directly. This has to be done if we wish the pass the annotation information to the application. 2. call checkContent(Element parent, Element firstChild, boolean isEmpty) which checks if firstChild is an <annotation> element and if yes, calls traverseAnnotationDecl(firstChild, parentAttrs, isGlobal, schemaDoc) the 'isGlobal' here is always *false* because checkContent(...) is always called to check whether or not the first child is an annotation. So, i believe the above specified situation -- multiple ID attrs... -- doesn't arise as long as the traversers don't try to do both #1 & #2. :-) > 2. checkContent is only useful in cases where s are required to occur as > the first component in a declaration. Since this is not true with elements, > checkContent cannot be called during traversal and so will only ever be > called in a local context. Hence the checks for globalness can be removed. > The globalness check i have made is for the parent element to get its attributes and pass them to traverseAnnotationDecl(...). I think this is needed to get the attributes from the AttributeChecker. But i do have a doubt as to why we are passing the parent's attributes to traverseAnnotationDecl(...). Please clarify. > 3. I don't know how much you've looked into our error-reporting > infrastructure, but before he went on holiday Sandy spent a good bit of > time on this. Hence my feeling is that, whenever possible, we should use > this infrastructure and throw real errors rather than putting lots of > revisits in our code. > Yes, done. Please find the attached file and diff with the changes. Regards, Pavani -- Pavani Mukthipudi Sun Microsystems Inc. Phone: 080 - 2298989 Extn: 87390
XSDAbstractTraverser.java
Description: XSDAbstractTraverser.java
Index: XSDAbstractTraverser.java
===================================================================
RCS file:
/home/cvspublic/xml-xerces/java/src/org/apache/xerces/impl/v2/XSDAbstractTraverser.java,v
retrieving revision 1.20
diff -u -r1.20 XSDAbstractTraverser.java
--- XSDAbstractTraverser.java 2001/09/25 22:46:07 1.20
+++ XSDAbstractTraverser.java 2001/09/28 12:18:19
@@ -232,13 +232,42 @@
// false if must have some element (with possible preceding
<annotation?>)
//
- //REVISIT: Implement
//REVISIT: if we want to expose annotation information to the application,
// then we should never call this method. different traversers
// should call traverseAnnotationDecl() directly, and store the
// returned value.
Element checkContent( Element elm, Element content, boolean isEmpty ) {
- return content;
+
+ if (content == null) {
+ return content;
+ }
+
+ if (content.getLocalName().equals(SchemaSymbols.ELT_ANNOTATION)) {
+ Document doc = DOMUtil.getDocument(content);
+ XSDocumentInfo docInfo = fSchemaHandler.fDoc2XSDocumentMap(doc);
+ boolean isGlobal = false;
+
+ if
+(DOMUtil.getParent(elm).getLocalName().equals(SchemaSymbols.ELT_SCHEMA))
+ isGlobal = true;
+
+ Object[] parentAttrs = fAttrChecker.checkAttributes(elm, isGlobal,
+docInfo);
+
+ traverseAnnotationDecl(content, parentAttrs, false, docInfo);
+
+ fAttrChecker.returnAttrArray(parentAttrs, docInfo);
+ content = DOMUtil.getNextSiblingElement(content);
+
+ // REVISIT : should we make these checks here ??
+
+ if (content == null && !isEmpty) {
+ reportGenericSchemaError("Element '"+ elm.getLocalName() +"' cannot
+have empty content");
+ }
+ else if (content != null && isEmpty) {
+ reportGenericSchemaError("Element '"+ elm.getLocalName() +"' should
+be empty");
+ }
+ }
+
+ return content;
}
/**
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
