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

  • Home
  • SEARCH
  • 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 6378187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:58:23+00:00 2026-05-25T01:58:23+00:00

JAXB generated from XSD base64Binary and hexBinary to byte array. I have xsd element

  • 0

JAXB generated from XSD base64Binary and hexBinary to byte array. I have xsd element with base64Binary. This is strict and cannot be changed. But in this element we has value of hexBinary (yea a little bit confused). And now where it is problem. I dont dont how is JAXB unmarshaling these element but there is something not sutaible to me. So if there could be hexBinary in my element it unmarshaling right. But im my case element has type base64Binary and JAXB unmarshaling these element something else what is wrong to me. Is there a way to change how JAXB handle with these element and tell him to handle as these element would be hexBinary.
maybe confusing question but I need help with these.

so in shortly way I have element base64Binary but I wanna to tell JAXB to unmarshaling as these will be hexBinary

I read something that I have to create new XmlAdapter but I dont know where should I use it because I have just classes which generated JAXB

UPDATE:

I found where is a problem. when element is base64Binary in generated class it created this

XmlElement(name="name") protected byte[] element

but when it is hexBinary it create

XmlJavaTypeAdapter(HexBinaryAdapter.class) XmlElement(name="name") protected byte[] element

so now I need to know how to say jaxb to use these adapter when I have base64Binary
protected byte[] element

  • 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-25T01:58:24+00:00Added an answer on May 25, 2026 at 1:58 am

    UPDATE

    You should be able to do what you want using a JAXB schema bindings file like the following:

    <jxb:bindings 
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
        version="2.1">
        <jxb:bindings schemaLocation="YourSchema.xsd">
            <jxb:bindings node="//xs:element[@name='element']">
                <jxb:property>
                    <jxb:baseType>
                        <jxb:javaType name="byte[]"
                            parseMethod="javax.xml.bind.DatatypeConverter.parseHexBinary" 
                            printMethod="javax.xml.bind.DatatypeConverter.printHexBinary"/>
                    </jxb:baseType>
                </jxb:property>
            </jxb:bindings>
        </jxb:bindings>
    </jxb:bindings>
    

    There are a couple of options:

    Option #1 – @XmlSchemaType

    You can use the @XmlSchemaType annotation to control the schema representation;

    @XmlSchemaType(name="hexBinary")
    private byte[] hexBinary;
    
    @XmlSchemaType(name="base64Binary")
    private byte[] base64Binary;
    

    Option #2 – XmlAdapter

    If you want to generate your model from an XML schema and leverage an XmlAdapter instead, the following example demonstrates how it could be done:

    • http://blog.bdoughan.com/2011/08/xml-schema-to-java-generating.html
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some jaxb objects (instantiated from code generated from xsd by jaxb) that
I have this Maven task to generate Java classes from an XSD file using
Do you know of a JAXB setting to prevent standalone=yes from being generated in
I use JAXB 2.1 to generate Java classes from several XSD files that I
I am working on generating Java objects from an XSD file using JAXB 2.1.
I use Hyperjaxb3 to generate JPA entities from XSD schema. I have a xsd:string
JAXB Generated classes only capture the structural information from the XML schema that is
What is the best way to represent a byte array as an XSD schema?
I am trying to generate some beans from several xsd's. Unfortunately they all have
How to configure JAXB unmarshaller so it will trim leading and trailing whitespaces from

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.