How to create Java objects from XML tags which are referring each other?

后端 未结 3 997
臣服心动
臣服心动 2021-01-05 21:14

I have an XML which has tags corresponding to three types of Java objects which would be created from the XML. The objects are of the form:

A
- static Map<         


        
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-05 21:46

    • Specify the correct XML format with an XSD
    • Generate the JAXB classes

    (You could do it also the other way around, if you are familiar with JAXB annotations and want to control the interface with Java rather than with an XSD).

    Note: static Maps is most likely not what you want to use. If you explain more about what problem you want to solve we might be able to point you out some alternative ways

    Edit:

    Are you talking about the format of the XML? Or why I need XML at all? I need XML for the ability to make my applications configurable outside of Java.

    It looks like you're re-inventing the wheel. Have a look at Spring and see if it fits your needs. If it doesn't, explain why.

提交回复
热议问题