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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:02:51+00:00 2026-06-07T06:02:51+00:00

I have to work with large XML documents which often handle missing attribute data

  • 0

I have to work with large XML documents which often handle missing attribute data incorrectly. Rather than just omitting the attribute with the missing data, the attribute is specified with an empty string value. This causes a problem when unmarshalling, since an empty string is a value.

For example, what should be

<SOME_ELEMENT attr1="someValue"/>

Is instead

<SOME_ELEMENT attr1="someValue" attr2="" attr3=""/>

I’m trying to come up with the “right” way of gracefully handling this poorly formed XML. The goal is to treat an attribute as if it were omitted when the attribute’s value is a blank string, and a blank string is never a valid value for that attribute (e.g. Integers).

I’m currently using XMLAdapters to translate these empty strings to null (as suggested in this post) but this seems like the wrong solution. Many of the attributes in the documents I’m working are already using type adapters shared from other code and there doesn’t appear to be a way to specify more than one XMLAdapter for an attribute.

Is there a standard way to handle this type of situation that I’ve just missed?

Thanks!

EDIT

I’m looking for a solution that does not require me to edit each of the various JAXB mapped classes, since there are several dozen all with the same needs. Ideally, a solution to this problem will allow me to specify a general policy for all attributes, and allow for specific overrides as necessary.

  • 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-06-07T06:02:53+00:00Added an answer on June 7, 2026 at 6:02 am

    Since this has been dormant for a while now, I might as well answer the question with where we left off on it.

    It looks like Skaffman‘s answer JAXB: how to make JAXB NOT to unmarshal empty string to 0 in the link in the description is the best option after all.

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

Sidebar

Related Questions

Consider the apps that large blogs have (which work pretty much like an RSS
Question 1: I have some XML-based layouts which work fine on phones. But when
In my experience I have only had 2 patterns work for large-scale desktop application
In software companies I have seen it's really hard to work on very large
I have a large c# project at work that controls a radar jammer. When
I have to work on a database in which there are many stored-procedures &
I need to pre-compress some very large html/xml/json files (large data dumps) using either
We have a large amount of apps. They all have a build.xml file located
I have a large SSRS 2008 Server Report Project (more than 200 reports). Currently
I have a php script that parses XML files and creates a large SQL

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.