Hi folks,
 
I have a problem unmarshalling xml-nodes to AnyObject!
I want to create a Java object representation of XML with <any> in my  schema:
 
<xsd:element name="xxx" type="xxxType"/>
<xsd:complexType name="xxxType">
<xsd:sequence>
<xsd:any namespace="##any" minOccurs="0" maxOccurs="unbounded" processContents="lax" />
</xsd:sequence>
</xsd:complexType >
 
Generating the java-stubs worked correctly. The generated bean als contains a property "private java.util.ArrayList _anyObject;" which seams to be correct.
Then I tried to unmarshal a test-xml wich worked correctly:
 
<xxx>
    <MyData>
        <aaa>111</aaa>
    </MyData>
</xxx>
 
==============================
Now the problem with the following XML:
==============================
 
<xxx>
    <MyData>
        <aaa>111</aaa>
        <bbb>222</bbb>
    </MyData>
</xxx>
 

When unmarshalling the xml-file I receive a NullpointerException in SAX2Any.java when endelement of 'MyData' is called. (the endElement-calls of 'aaa' and 'bbb' just before are correct):
 
public void endElement(String name) throws SAXException {
  String prefix = "";
  String namespaceURI = null;
  int idx = name.indexOf(':');
  if (idx >= 0) {
    prefix = name.substring(0,idx);
  }
 
----->>>> namespaceURI = _context.getNamespaceURI(prefix); <<<<--------------
 
  endElement(namespaceURI,getLocalPart(name), name);
  _context = _context.getParent();
}
 
The _context is null. I don't understand, where the _context get lost, so that it is at this point null.
Do I have to change the schma or is it a bug ?
 
Thanks for any help!!!
 
Harald.

Reply via email to