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 6174099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:41:38+00:00 2026-05-23T23:41:38+00:00

Our Java application receives XML messages from a number of external systems and from

  • 0

Our Java application receives XML messages from a number of external systems and from these we want to create domain objects. We do not have schemas for these documents.

Currently we are are using XPaths to pull out strings from the XML and then calling setters on the new domain object. We use a home-baked XmlUtils class to do this.

foo.setBar(XmlUtils.number("/bar", document));

What alternative Java-based approaches are there, which do not require access to the document’s schema?

  • 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-23T23:41:40+00:00Added an answer on May 23, 2026 at 11:41 pm

    Note: I’m the EclipseLink JAXB (MOXy) lead, and a member of the JAXB 2.X (JSR-222) expert group.

    MOXy offers the @XmlPath extension which enables you to do XPath based mapping:

    Path Based Mapping

    Match the bar element under the foo element:

    @XmlPath("foo/bar/text()")
    public int getBar() {
        return bar;
    }
    

    Position Based Mapping

    Match the second bar element:

    @XmlPath("bar[2]/text()")
    public int getBar() {
        return bar;
    }
    

    Predicate Based Mapping

    Match the bar element that has a type attribute with value foo:

    @XmlPath("bar[@type='foo']/text()")
    public int getBar() {
        return bar;
    }
    

    Combined

    All of the above concepts can be used together:

    @XmlPath("foo[2]/bar[@type='foo']/text()")
    public int getBar() {
        return bar;
    }
    

    For More Information

    • http://bdoughan.blogspot.com/2010/07/xpath-based-mapping.html
    • http://bdoughan.blogspot.com/2010/09/xpath-based-mapping-geocode-example.html
    • http://bdoughan.blogspot.com/2011/03/map-to-element-based-on-attribute-value.html
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We want to be able to create log files from our Java application which
On one of our Java application screens, we want to display data loaded from
We want to tune the memory generation pool sizes for our Java application. In
I have a Java application that I want to save the data in XML
I'm trying to create a process to patch our current java application so users
Currently our Java application uses the values held within a tab delimited *.cfg file.
Part of our java application needs to run javascript that is written by non-developers.
I've set up ehcache on our Java application, which uses Spring and Hibernate. However,
I am working on the I18n of our java application and we have decided
We use Tomcat for our java web application. There is a properties file under

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.