reportSchemaError("s4s-att-must-appear", new Object[]{"group (global)", "name"}, elmNode);
}
// Create the group defi up-front, so it can be passed
// to the traversal methods
XSGroupDecl group = new XSGroupDecl();
XSParticleDecl particle = null;
// must have at least one child
Element l_elmChild = DOMUtil.getFirstChildElement(elmNode);
XSAnnotationImpl annotation = null;
if (l_elmChild == null) {
reportSchemaError("s4s-elt-must-match.2",
new Object[]{"group (global)", "(annotation?, (all | choice | sequence))"},
elmNode);
} else {
String childName = l_elmChild.getLocalName();
if (childName.equals(SchemaSymbols.ELT_ANNOTATION)) {
annotation = traverseAnnotationDecl(l_elmChild, attrValues, true, schemaDoc);
l_elmChild = DOMUtil.getNextSiblingElement(l_elmChild);
if (l_elmChild != null)
childName = l_elmChild.getLocalName();
}
else {
String text = DOMUtil.getSyntheticAnnotation(elmNode);
if (text != null) {
annotation = traverseSyntheticAnnotation(elmNode, text, attrValues, false, schemaDoc);
}
}
if (l_elmChild == null) {
reportSchemaError("s4s-elt-must-match.2",
new Object[]{"group (global)", "(annotation?, (all | choice | sequence))"},
elmNode);
} else if (childName.equals(SchemaSymbols.ELT_ALL)) {
particle = traverseAll(l_elmChild, schemaDoc, grammar, CHILD_OF_GROUP, group);
} else if (childName.equals(SchemaSymbols.ELT_CHOICE)) {
particle = traverseChoice(l_elmChild, schemaDoc, grammar, CHILD_OF_GROUP, group);
} else if (childName.equals(SchemaSymbols.ELT_SEQUENCE)) {
particle = traverseSequence(l_elmChild, schemaDoc, grammar, CHILD_OF_GROUP, group);
} else {
reportSchemaError("s4s-elt-must-match.1",
new Object[]{"group (global)", "(annotation?, (all | choice | sequence))", DOMUtil.getLocalName(l_elmChild)},
l_elmChild);
}
if (l_elmChild != null &&
DOMUtil.getNextSiblingElement(l_elmChild) != null) {
reportSchemaError("s4s-elt-must-match.1",
new Object[]{"group (global)", "(annotation?, (all | choice | sequence))",
DOMUtil.getLocalName(DOMUtil.getNextSiblingElement(l_elmChild))},
DOMUtil.getNextSiblingElement(l_elmChild));
}
}
// add global group declaration to the grammar
if (strNameAttr != null) {
group.fName = strNameAttr;
group.fTargetNamespace = schemaDoc.fTargetNamespace;
if (particle == null) {
particle = XSConstraints.getEmptySequence();
}
group.fModelGroup = (XSModelGroupImpl)particle.fValue;
XSObjectList annotations;
if (annotation != null) {
annotations = new XSObjectListImpl();
((XSObjectListImpl) annotations).addXSObject(annotation);
} else {
annotations = XSObjectListImpl.EMPTY_LIST;
}
group.fAnnotations = annotations;
// Add group declaration to grammar
if (grammar.getGlobalGroupDecl(group.fName) == null) {
grammar.addGlobalGroupDecl(group);
}
// also add it to extended map
final String loc = fSchemaHandler.schemaDocument2SystemId(schemaDoc);
final XSGroupDecl group2 = grammar.getGlobalGroupDecl(group.fName, loc);
if (group2 == null) {
grammar.addGlobalGroupDecl(group, loc);
}
// handle duplicates