I want to analyze data using JAXB for the following XSD scheme http://www.uniprot.org/support/docs/uniprot.xsd .
Typical XML for this is as follows: http://www.uniprot.org/uniprot/Q8NEJ9.xml
My classes were generated using:
xjc http://www.uniprot.org/support/docs/uniprot.xsd
I can not get JMXB unmarshaller to analyze this data.
xmlInputFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.TRUE); XMLEventReader rx=xmlInputFactory.createXMLEventReader(in); final QName uEntry=new QName("http://uniprot.org/uniprot","entry"); while(rx.hasNext()) { XMLEvent evt=rx.peek(); if(!(evt.isStartElement() && evt.asStartElement().getName().equals(uEntry))) { rx.next(); continue; } JAXBElement<Entry> jaxbElement=uniprotUnmarshaller.unmarshal(rx, Entry.class); Entry entry= jaxbElement.getValue(); (...) }
Each entry entry is left blank. When a record is marshaled in stderr, I get something like:
<ns2:entry xmlns:ns2="http://uniprot.org/uniprot" dataset="Swiss-Prot" created="2011-06-28+01:00" modified="2011-09-21+01:00" version="20"/>
I think because xjc ignores namespaces. It generates:
@XmlRootElement(name = "entry") public class Entry {
instead of (?)
@XmlRootElement(name = "entry",namespace="http://uniprot.org/uniprot") public class Entry {
How can i fix this?
source share