sandygao 2003/02/17 08:37:51
Modified: java/src/org/apache/xerces/impl/xs/traversers
XSDComplexTypeTraverser.java
Log:
Fixing a schema traversal bug: for the following case
<complexType> <sequence> <element minOccurs=maxOccurs=0
according to the spec, the complex type has element-only content (though
it doesn't allow any element). We used to make it an empty content.
Revision Changes Path
1.33 +26 -5
xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java
Index: XSDComplexTypeTraverser.java
===================================================================
RCS file:
/home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- XSDComplexTypeTraverser.java 12 Feb 2003 14:26:30 -0000 1.32
+++ XSDComplexTypeTraverser.java 17 Feb 2003 16:37:50 -0000 1.33
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2001, 2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -844,6 +844,8 @@
Element attrNode = null;
XSParticleDecl particle = null;
+ // whether there is a particle with empty model group
+ boolean emptyParticle = false;
if (complexContentChild != null) {
// -------------------------------------------------------------
// GROUP, ALL, SEQUENCE or CHOICE, followed by attributes, if specified.
@@ -865,7 +867,7 @@
if (particle != null) {
XSModelGroupImpl group = (XSModelGroupImpl)particle.fValue;
if (group.fParticleCount == 0)
- particle = null;
+ emptyParticle = true;
}
attrNode = DOMUtil.getNextSiblingElement(complexContentChild);
}
@@ -875,7 +877,7 @@
if (particle != null && particle.fMinOccurs == 0) {
XSModelGroupImpl group = (XSModelGroupImpl)particle.fValue;
if (group.fParticleCount == 0)
- particle = null;
+ emptyParticle = true;
}
attrNode = DOMUtil.getNextSiblingElement(complexContentChild);
}
@@ -885,7 +887,7 @@
if (particle != null) {
XSModelGroupImpl group = (XSModelGroupImpl)particle.fValue;
if (group.fParticleCount == 0)
- particle = null;
+ emptyParticle = true;
}
attrNode = DOMUtil.getNextSiblingElement(complexContentChild);
}
@@ -893,6 +895,25 @@
// Should be attributes here - will check below...
attrNode = complexContentChild;
}
+ }
+
+ // if the particle is empty because there is no non-annotation chidren,
+ // we need to make the particle itself null (so that the effective
+ // content is empty).
+ if (emptyParticle) {
+ // get the first child
+ Element child = DOMUtil.getFirstChildElement(complexContentChild);
+ // if it's annotation, get the next one
+ if (child != null) {
+ if
(DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
+ child = DOMUtil.getNextSiblingElement(child);
+ }
+ }
+ // if there is no (non-annotation) children, mark particle empty
+ if (child == null)
+ particle = null;
+ // child != null means we might have seen an element with
+ // minOccurs == maxOccurs == 0
}
if (particle == null && isMixed) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]