in src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java [1327:1375]
Element serializeIdentityConstraint(Document doc, XmlSchemaIdentityConstraint constraintObj,
XmlSchema schema) throws XmlSchemaSerializerException {
Element constraint;
if (constraintObj instanceof XmlSchemaUnique) {
constraint = createNewElement(doc, "unique", schema.getSchemaNamespacePrefix(),
XmlSchema.SCHEMA_NS);
} else if (constraintObj instanceof XmlSchemaKey) {
constraint = createNewElement(doc, "key", schema.getSchemaNamespacePrefix(),
XmlSchema.SCHEMA_NS);
} else if (constraintObj instanceof XmlSchemaKeyref) {
constraint = createNewElement(doc, "keyref", schema.getSchemaNamespacePrefix(),
XmlSchema.SCHEMA_NS);
XmlSchemaKeyref keyref = (XmlSchemaKeyref)constraintObj;
if (keyref.refer != null) {
String keyrefStr = resolveQName(keyref.refer, schema);
constraint.setAttribute("refer", keyrefStr);
}
} else {
throw new XmlSchemaSerializerException("not valid identity " + "constraint");
}
if (constraintObj.getName() != null) {
constraint.setAttribute("name", constraintObj.getName());
}
if (constraintObj.getAnnotation() != null) {
Element annotation = serializeAnnotation(doc, constraintObj.getAnnotation(), schema);
constraint.appendChild(annotation);
}
if (constraintObj.getSelector() != null) {
Element selector = serializeSelector(doc, constraintObj.getSelector(), schema);
constraint.appendChild(selector);
}
List<XmlSchemaXPath> fieldColl = constraintObj.getFields();
if (fieldColl != null) {
int fieldLength = fieldColl.size();
for (int i = 0; i < fieldLength; i++) {
Element field = serializeField(doc, fieldColl.get(i), schema);
constraint.appendChild(field);
}
}
// process extension
processExtensibilityComponents(constraintObj, constraint);
return constraint;
}