Forums Register Login

why JAXB ?

+Pie Number of slices to send: Send
I am learning JAXB, I know it could convert data between java and XML. But in real world, what is usage for this API ?

1. Why will we need to convert java to XML ? storage ? No, we could directly save data into relational database.

2. Why will we need to convert XML to java ? In J2EE, if we have XML data, then we could directly generate page using JSTL xml tag.

I don't know if the higher level API, like Hibernate, is using JAXB ? Or java web service is using it in the lower level. Maybe this is only usage. But for regular developer, JAXB has nothing usage.

If I am wrong, please correct me.

Thanks.
+Pie Number of slices to send: Send


1. Why will we need to convert java to XML ? storage ? No, we could directly save data into relational database.



XML is easily portable and can be used interoperability between systems. sometimes it can be used as common protocol to 2 different system communicate.


I know it could convert data between java and XML. But in real world, what is usage for this API ?



Well say your application receives inbound XML from various systems and you need to do some calculations and store certain values to DB. you should probably use JAXB to convert XML to java objects and retrieve the objects to perform operations and store it in DB.
+Pie Number of slices to send: Send
Examples use cases:
  • Export model to XML
  • Import XML to model


  • Anyway, you don't need to use JAXB, you can use any Java-XML mapping tools.
    And then the entire population worshiped me like unto a god. Well, me and this tiny ad:
    a bit of art, as a gift, that will fit in a stocking
    https://gardener-gift.com


    reply
    reply
    This thread has been viewed 2105 times.
    Similar Threads
    HOW TO CONVERT TEXT FILE TO XML FILE GENERICALLY
    JAXB XPATH API
    XML API choices, survey
    JAXP(SAX & DOM) vs JAXB
    Cannot use JAXP and JAXB because they are not thread-safe?
    More...

    All times above are in ranch (not your local) time.
    The current ranch time is
    Mar 28, 2024 17:15:16.