---------- Forwarded message ----------
From: Virginijus Kandrotas <[EMAIL PROTECTED]>
Date: Jul 28, 2006 9:45 AM
Subject: XMLSchema bug
To: [EMAIL PROTECTED]
hallo,
yesterday I found one bug in org.apache.ws.commons.schema.SchemaBuilder class
(vesrsion 1.0.3). The problem occures with schemas having „redefine"
elements, seems that nobody before have tested this class with redefine
case. The code „redefine.schemaTypes.collection.put(xx, yyy)" allway throws
NullPointerException.
private XmlSchemaRedefine handleRedefine(XmlSchema schema,
Element redefineEl, Element
schemaEl) {
XmlSchemaRedefine redefine = new XmlSchemaRedefine();
redefine.schemaLocation =
redefineEl.getAttribute("schemaLocation");
//redefine has no such thing called a namespace!
redefine.schema =
resolveXmlSchema(null,redefine.schemaLocation);
for (Element el = XDOMUtil.getFirstChildElementNS(redefineEl,
XmlSchema.SCHEMA_NS)
; el != null;
el = XDOMUtil.getNextSiblingElementNS(el,
XmlSchema.SCHEMA_NS)) {
if (el.getLocalName().equals("simpleType")) {
XmlSchemaType type =
handleSimpleType(schema, el, schemaEl);
redefine..collection.put(type.getQName(),
type);
redefine.items.add(type);
} else if (el.getLocalName().equals("complexType")) {
XmlSchemaType type = handleComplexType(schema, el,
schemaEl);
redefine.schemaTypes.collection.put(type.getQName(),
type);
redefine.items.add(type);
} else if (el.getLocalName().equals("group")) {
XmlSchemaGroup group = handleGroup(schema, el,
schemaEl);
redefine.groups.collection.put(group.name, group);
redefine.items.add(group);
} else if (el.getLocalName().equals("attributeGroup")) {
XmlSchemaAttributeGroup group =
handleAttributeGroup(schema, el, schemaEl);
redefine.attributeGroups.collection.put(group.name, group);
redefine.items.add(group);
} else if (el.getLocalName().equals("annotation")) {
XmlSchemaAnnotation annotation = handleAnnotation(el);
redefine.setAnnotation(annotation);
}
// }
}
return redefine;
}
The reason is „schemaTypes" - null: it is not instanciated in
XmlSchemaRedefine constructor.
I have changed constructor with thsi code:
public XmlSchemaRedefine() {
items = new XmlSchemaObjectCollection();
attributeGroups = new XmlSchemaObjectTable();
groups = new XmlSchemaObjectTable();
schemaTypes = new XmlSchemaObjectTable();
}
now it works for as.
--
Viele Grüße / best regards
Virginijus Kandrotas
Software Development
____________________________________
inubit - integrating your business and IT
inubit AG
Lützowstraße 105-106
D-10785 Berlin
Fon: +49.30. 72 61 12-255
Fax: +49.30. 72 61 12-100
Freecall: 0800-go inubit
Web: www.inubit.com
Mail: [EMAIL PROTECTED]
Zertifiziert nach DIN EN ISO 9001:2000
--
============================
Srinath Perera:
http://www.cs.indiana.edu/~hperera/
http://www.bloglines.com/blog/hemapani
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]