mrglavas 2004/10/28 14:06:19
Modified: java/src/org/apache/xerces/impl/xs/traversers
XSDAbstractTraverser.java
Log:
When an annotation has no <documentation> or <appinfo> children we were
completely losing the annotation component. This is because the schema DOM
stores the textual representation of the annotation on the first child of the
current parent. When <annotation> has element content, that's its first
child. When <annotation> has no element content, that's its parent's first
child. The latter is problematic because only if the annotation is the first
child of its parent will we find the text node there. We need to store the
string representation in a consistent place so it can be reliably retrieved,
perhaps as user data. In the mean time we look for a text child on
annotation if it has no element content. This works for a large number of
cases but not all of them.
Revision Changes Path
1.38 +37 -21
xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java
Index: XSDAbstractTraverser.java
===================================================================
RCS file:
/home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- XSDAbstractTraverser.java 6 Oct 2004 15:14:48 -0000 1.37
+++ XSDAbstractTraverser.java 28 Oct 2004 21:06:19 -0000 1.38
@@ -105,28 +105,44 @@
fAttrChecker.returnAttrArray(attrValues, schemaDoc);
String contents = null;
- for (Element child = DOMUtil.getFirstChildElement(annotationDecl);
- child != null;
- child = DOMUtil.getNextSiblingElement(child)) {
- String name = DOMUtil.getLocalName(child);
+ Element child = DOMUtil.getFirstChildElement(annotationDecl);
+ if (child != null) {
+ do {
+ String name = DOMUtil.getLocalName(child);
- // the only valid children of "annotation" are
- // "appinfo" and "documentation"
- if (!((name.equals(SchemaSymbols.ELT_APPINFO)) ||
- (name.equals(SchemaSymbols.ELT_DOCUMENTATION)))) {
- reportSchemaError("src-annotation", new Object[]{name}, child);
- } else { // the annotation, as we currently know it, is a Text child
- Node textContent = child.getFirstChild();
- if(textContent != null && textContent.getNodeType() ==
Node.TEXT_NODE) {
- contents = ((Text)textContent).getData();
+ // the only valid children of "annotation" are
+ // "appinfo" and "documentation"
+ if (!((name.equals(SchemaSymbols.ELT_APPINFO)) ||
+ (name.equals(SchemaSymbols.ELT_DOCUMENTATION)))) {
+ reportSchemaError("src-annotation", new Object[]{name}, child);
+ } else { // the annotation, as we currently know it, is a Text child
+ Node textContent = child.getFirstChild();
+ if(textContent != null && textContent.getNodeType() ==
Node.TEXT_NODE) {
+ contents = ((Text)textContent).getData();
+ }
}
- }
- // General Attribute Checking
- // There is no difference between global or local appinfo/documentation,
- // so we assume it's always global.
- attrValues = fAttrChecker.checkAttributes(child, true, schemaDoc);
- fAttrChecker.returnAttrArray(attrValues, schemaDoc);
+ // General Attribute Checking
+ // There is no difference between global or local
appinfo/documentation,
+ // so we assume it's always global.
+ attrValues = fAttrChecker.checkAttributes(child, true, schemaDoc);
+ fAttrChecker.returnAttrArray(attrValues, schemaDoc);
+
+ child = DOMUtil.getNextSiblingElement(child);
+ }
+ while (child != null);
+ }
+ // REVISIT: When an annotation has no <documentation> or
+ // <appinfo> children the text child is stored on the first child of its
+ // parent. Only if the annotation is the first child will we find the
+ // text node there. See SchemaDOM. We need to store the string
representation
+ // in a consistent place so it can be reliably retrieved, perhaps as
+ // user data. -- mrglavas
+ else {
+ Node textContent = annotationDecl.getFirstChild();
+ if(textContent != null && textContent.getNodeType() == Node.TEXT_NODE) {
+ contents = ((Text)textContent).getData();
+ }
}
// if contents was null, must have been some kind of error;
// nothing to contribute to PSVI
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]