in xmlschema-core/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java [939:1028]
private XmlSchemaAttribute handleAttribute(XmlSchema schema, Element attrEl, Element schemaEl,
boolean topLevel) {
XmlSchemaAttribute attr = new XmlSchemaAttribute(schema, topLevel);
if (attrEl.hasAttribute("name")) {
String name = attrEl.getAttribute("name");
attr.setName(name);
}
if (attrEl.hasAttribute("type")) {
String name = attrEl.getAttribute("type");
attr.setSchemaTypeName(getRefQName(name, attrEl));
}
if (attrEl.hasAttribute("default")) {
attr.setDefaultValue(attrEl.getAttribute("default"));
}
if (attrEl.hasAttribute("fixed")) {
attr.setFixedValue(attrEl.getAttribute("fixed"));
}
if (attrEl.hasAttribute("form")) {
String formValue = getEnumString(attrEl, "form");
attr.setForm(XmlSchemaForm.schemaValueOf(formValue));
}
if (attrEl.hasAttribute("id")) {
attr.setId(attrEl.getAttribute("id"));
}
if (attrEl.hasAttribute("use")) {
String useType = getEnumString(attrEl, "use");
attr.setUse(XmlSchemaUse.schemaValueOf(useType));
}
if (attrEl.hasAttribute("ref")) {
String name = attrEl.getAttribute("ref");
attr.getRef().setTargetQName(getRefQName(name, attrEl));
}
Element simpleTypeEl = XDOMUtil.getFirstChildElementNS(attrEl, XmlSchema.SCHEMA_NS, "simpleType");
if (simpleTypeEl != null) {
attr.setSchemaType(handleSimpleType(schema, simpleTypeEl, schemaEl, false));
}
Element annotationEl = XDOMUtil.getFirstChildElementNS(attrEl, XmlSchema.SCHEMA_NS, "annotation");
if (annotationEl != null) {
XmlSchemaAnnotation annotation = handleAnnotation(annotationEl);
attr.setAnnotation(annotation);
}
NamedNodeMap attrNodes = attrEl.getAttributes();
List<Attr> attrs = new ArrayList<Attr>();
NodeNamespaceContext ctx = null;
for (int i = 0; i < attrNodes.getLength(); i++) {
Attr att = (Attr)attrNodes.item(i);
String attName = att.getName();
if (!RESERVED_ATTRIBUTES.contains(attName)) {
attrs.add(att);
String value = att.getValue();
if (value.indexOf(":") > -1) {
// there is a possibility of some namespace mapping
String prefix = value.substring(0, value.indexOf(":"));
if (ctx == null) {
ctx = NodeNamespaceContext.getNamespaceContext(attrEl);
}
String namespace = ctx.getNamespaceURI(prefix);
if (!Constants.NULL_NS_URI.equals(namespace)) {
Attr nsAttr = attrEl.getOwnerDocument().createAttributeNS(Constants.XMLNS_ATTRIBUTE_NS_URI,
"xmlns:" + prefix);
nsAttr.setValue(namespace);
attrs.add(nsAttr);
}
}
}
}
if (attrs.size() > 0) {
attr.setUnhandledAttributes(attrs.toArray(new Attr[attrs.size()]));
}
// process extra attributes and elements
processExtensibilityComponents(attr, attrEl, true);
return attr;
}