Bind complicated XML form with JAXB annotations

xyleli8gas

New Member
I'm having problem to bind an XML retrieved from a OAI-PMH service provider.It uses namespaces with different prefixes and I can't figure out how to map the xml to my JaxB classes.Here is the xml retrieved from the service provider:\[code\] <external_metadata> <timestamp>1342393215.0</timestamp> <record xmlns="http://www.openarchives.org/OAI/2.0/"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <header xmlns:xs="http://www.w3.org/2001/XMLSchema"> <datestamp>1989-12-31T23:00:00Z</datestamp> </header> <metadata> <oai_dc:dc xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd"> <dc:title>My title </dc:title> . . </metadata> </external_metadata>\[/code\]I know that i can write into the package-info.java something as the following:\[code\] @javax.xml.bind.annotation.XmlSchema ( namespace="http://www.openarchives.org/OAI/2.0/", elementFormDefault=XmlNsForm.QUALIFIED, xmlns = { @javax.xml.bind.annotation.XmlNs( prefix="", namespaceURI="http://www.openarchives.org/OAI/2.0/" ), @javax.xml.bind.annotation.XmlNs( prefix="xsi" , namespaceURI="http://www.w3.org/2001/XMLSchema-instance" ) }) package web.model; import javax.xml.bind.annotation.XmlNsForm;\[/code\]But in the XML i provide i need to create 3 different packages and implement this process. One for the record, one for the header and one for the oai_dc.Question: is there a way that will allow me to create the appropriate xmlns format into the class? I want to do this in order to avoid the creation of many different packages.I was thinking to use the @XmlType but i look at the documentation and i didn't find that can support something similar to the prefix. Is it possible to combine class and package level annotations to suceed this?
 
Back
Top