开发者

Bind XSD element to a Java implementation?

开发者 https://www.devze.com 2023-02-08 08:51 出处:网络
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 rela

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消