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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:34:36+00:00 2026-05-30T07:34:36+00:00

How can I get JAXB to marshall a string or primitive data type and

  • 0

How can I get JAXB to marshall a string or primitive data type and set the type=”string”, or type=”int” in the resulting XML. I have tried specifying a specific type for each field

@XmlSchemaType(name = "string",namespace = "http://www.w3.org/2001/XMLSchema",type = String.class)

But this makes no difference the resulting XML is without type.

Thanks for reading

Update
this is basically what I have in a JaxB class:

@XmlElement(required = true)
protected Keys keys;
protected String workflowID;
    protected String fromFigure;
    protected String fromPort;

This is the resulting XML

        <keys type="draw2d.ArrayList">
            <data type="Array">
                <element type="draw2d.FlowConnectionModel">
                    <workflowID>d8f71b92-dc69-4115-9095-d748265d4e68</workflowID>
                    <fromFigure>706531d9-cd03-4347-9ba2-d9b525035e0d</fromFigure>
                    <fromPort>out_right_initialState</fromPort>

Notice that there is a type set for the keys, data and element types but none for the primitive data types of workflowID, fromFigure and fromPort. What I want is this:

        <keys type="draw2d.ArrayList">
            <data type="Array">
                <element type="draw2d.FlowConnectionModel">
                    <workflowID type="string">d8f71b92-dc69-4115-9095-d748265d4e68</workflowID>
                    <fromFigure type="string">706531d9-cd03-4347-9ba2-d9b525035e0d</fromFigure>
                    <fromPort type="string">out_right_initialState</fromPort>
  • 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-30T07:34:37+00:00Added an answer on May 30, 2026 at 7:34 am

    In the end I had to change the schema to use complex types as opposed to simple types.
    A snippet from the original schema

         <xs:element name="layoutWorkflowID" type="xs:string" minOccurs="1" maxOccurs="1"/>
        <xs:element name="layoutInstanceID" type="xs:string" minOccurs="1" maxOccurs="1"/>
    

    Changed to this

        <xs:element ref="layoutWorkflowID" minOccurs="1" maxOccurs="1"/>
        <xs:element ref="layoutInstanceID" minOccurs="1" maxOccurs="1"/>
    

    With extra complex types

      <xs:element name="layoutWorkflowID">
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base="xs:NCName">
          <xs:attribute name="type" use="required" type="xs:NCName"/>
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
    

    And now I get what I need when marshalling with every type specified.

    <layoutWorkflowID type="string">WorkflowHTML</layoutWorkflowID>
    <layoutInstanceID type="string">6</layoutInstanceID>
    

    Thanks for those that responded and read.

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

Sidebar

Related Questions

I have to generate a xml element that can have as value any primitive
How can I get jaxb to bind to my Vector? I cannot seem to
How can one ignore Unexpected element situation in JAXB ans still get all other
Logging can get complicated, quickly. Considering that you have some code, how do you
We're parsing an XML document using JAXB and get this error: [org.xml.sax.SAXParseException: Invalid byte
I'm starting learning JAXB, so my question can be very silly. Now I have
In the last couple of days I have tried to make support for XML
I have an Object that is being marshalled to XML using JAXB. One element
Need: take in XML and save data to database. Currently using: JAXB to convert
I'm rather new to JAXB and have come across a problem which I can't

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.