Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4117362
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:49:31+00:00 2026-05-20T22:49:31+00:00

I’ve been going over this in my head and trying out different approaches for

  • 0

I’ve been going over this in my head and trying out different approaches for a few days now and I’ve searched SO (see What is best practice in converting XML to Java object?) and also Google for using JAXB over XSLT but cannot find a suitable answer. Over the years I’ve used Castor, JIBX and XSLT for various projects, so I know a little bit about XML binding.

My problem is that I have a very flat XML structure and I want to unmarshall it to Java classes and persist them directly to a relational database (has to be Oracle). A small example…

<Output>
    <Channel>
        <channelId>1</channelId>
        <genreId>1</genreId>
    </Channel>
    <Channel>
        <channelId>2</channelId>
        <genreId>2</genreId>
    </Channel>
    <Genre>
        <genreId>1</genreId>
        <name>Movies</name>
    </Genre>
    <Genre>
        <genreId>2</genreId>
        <name>Sport</name>
    </Genre>
    <ChannelName>
        <channelId>1</channelId>
        <name>The Movie Channel</name>
    </ChannelName>
    <ChannelName>
        <channelId>2</channelId>
        <name>The Sport Channel</name>
    </ChannelName>
</Output>

What I really want for the XML above is just two simple annotated classes in a OneToOne relationship, that I can persist using JPA. Basically I want classes that reflect the database tables like so:

class Channel {
    Long id;
    String name;
    Genre genre;        
}

class Genre {
    Long id;
    String name;       
}

The XML will only ever be unmarshalled and I am really looking for the simplest solution to this problem which I realise can be a subjective question.

I am a fan of XSLT so am really asking if it’s good design to use XSLT to bend the original XML into a better structure the more closely matches the code and then just use some very simple JAXB annotations to bind to my classes. Or should I opt for doing the “transformation” using JAXB which I think would involve more actual Java code, for example XMLAdapters and more annotations. Basically, what is the benefit, or what else does JAXB give me over XSLT?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T22:49:32+00:00Added an answer on May 20, 2026 at 10:49 pm

    JAXB is the Java object-to-XML binding API.

    XSL-T transforms XML to XML.

    They don’t feel like the same thing to me. The end result might be XML, but the source is different in each case.

    I think the answer depends on your comfort level with each technology. If the XSL-T and JAXB combination feels natural to you, by all means go in that direction – unless it’s a runtime operation that’s performed repeatedly. In that case I’d say that performance might be a concern, depending on the complexity of the transformations.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.