I would like to know how to bind an开发者_如何学Python XML tag in a certain namespace to some implementation in Java e.g. the way Mule does with the tags defined in it's various XSD files. Is it related/done with JAXB or is that just for mapping Java beans to XML?
Regards Ola
Check out my article on JAXB and namespaces:
- http://bdoughan.blogspot.com/2010/08/jaxb-namespaces.html
With JAXB you can choose the granularity at which namespace information is provided:
- At the package level using @XmlSchema
- At the type level using @XmlType
- At the field/property level using @XmlElement and @XmlAttribute
I dont fully understad your question. Are you asking about unmarshalling ?
If so try use sth like below:
JAXBContext ctx = JAXBContext.newInstance("some.package");
Unmarshaller u = ctx.createUnmarshaller();
XMLInputFactory inFac = XMLInputFactory.newFactory();
XMLStreamReader reader = inFac.createXMLStreamReader(this.getClass().
getResourceAsStream("inputFile.xml"));
JAXBElement<Mule> freestyleElement = u.unmarshal(reader,Mule.class);
精彩评论