You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by Srinath Perera <he...@gmail.com> on 2006/07/28 15:50:17 UTC

Fwd: XMLSchema bug

---------- Forwarded message ----------
From: Virginijus Kandrotas <vk...@inubit.com>
Date: Jul 28, 2006 9:45 AM
Subject: XMLSchema bug
To: hemapani@apache.org



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: vk@inubit.com

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: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org


Re: Fwd: XMLSchema bug

Posted by Brent Ulbricht <ul...@us.ibm.com>.
Hi,

I believe the NPE you are seeing was fixed by WSCOMMONS-31.

http://issues.apache.org/jira/browse/WSCOMMONS-31


Brent Ulbricht
WebSphere FVT
IBM Corporation
512-838-1497
ulbricht@apache.org




"Srinath Perera" <he...@gmail.com> 
07/28/2006 08:50 AM
Please respond to
commons-dev@ws.apache.org


To
commons-dev@ws.apache.org
cc

Subject
Fwd: XMLSchema bug






---------- Forwarded message ----------
From: Virginijus Kandrotas <vk...@inubit.com>
Date: Jul 28, 2006 9:45 AM
Subject: XMLSchema bug
To: hemapani@apache.org



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: vk@inubit.com

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: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org