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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:38:09+00:00 2026-06-18T03:38:09+00:00

I want to bind the incoming XML to a JavaType <?xml version=1.0 encoding=UTF-8?> <apiKeys

  • 0

I want to bind the incoming XML to a JavaType

<?xml version="1.0" encoding="UTF-8"?>
<apiKeys uri="http://api-keys">
<apiKey uri="http://api-keys/1933"/>
<apiKey uri="http://api-keys/19334"/>
</apiKeys>

I wish to use JAXB, so I have defined an XSD. My XSD is incorrect, and the created objects – whilst being created – are empty.

My XSD:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="apiKeys" type="ApiKeysResponseInfo2" />

<xsd:complexType name="ApiKeysResponseInfo2">
<xsd:sequence>
<xsd:element name="uri" type="xsd:anyURI" minOccurs="1" maxOccurs="1">
</xsd:element>
<xsd:element name="apiKey" type="xsd:anyURI" minOccurs="1" maxOccurs="unbounded">
</xsd:element>
</xsd:sequence>
</xsd:complexType>  
</xsd:schema>

Obviously my element definitions are wrong. Any help much appreciated. Thanks.

  • 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-18T03:38:11+00:00Added an answer on June 18, 2026 at 3:38 am

    I wish to use JAXB, so I have defined an XSD.

    JAXB does not require an XML schema. We designed it to start from Java objects, the ability to generate an annotated model from an XML schema was added as a convenience mechanism.


    I want to bind the incoming XML to a JavaType

    You could use the object model below:

    ApiKeys

    import java.util.List;
    import javax.xml.bind.annotation.*;
    
    @XmlRootElement
    public class ApiKeys {
    
        private String uri;
        private List<ApiKey> apiKey;
    
        @XmlAttribute
        public String getUri() {
            return uri;
        }
    
        public void setUri(String uri) {
            this.uri = uri;
        }
    
        public List<ApiKey> getApiKey() {
            return apiKey;
        }
    
        public void setApiKey(List<ApiKey> apiKey) {
            this.apiKey = apiKey;
        }
    
    }
    

    ApiKey

    import javax.xml.bind.annotation.XmlAttribute;
    
    public class ApiKey {
    
        private String uri;
    
        @XmlAttribute
        public String getUri() {
            return uri;
        }
    
        public void setUri(String uri) {
            this.uri = uri;
        }
    
    }
    

    Demo

    import java.io.File;
    import javax.xml.bind.*;
    
    public class Demo {
    
        public static void main(String[] args) throws Exception {
            JAXBContext jc = JAXBContext.newInstance(ApiKeys.class);
    
            Unmarshaller unmarshaller = jc.createUnmarshaller();
            File xml = new File("src/forum14643483/input.xml");
            ApiKeys apiKeys = (ApiKeys) unmarshaller.unmarshal(xml);
    
            Marshaller marshaller = jc.createMarshaller();
            marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
            marshaller.marshal(apiKeys, System.out);
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want bind a xml file to my DropDownList and I want use the
I want to bind() to my base class's version of a function from the
I want to bind data from an xml file? how can I do that
I want to bind some of IntelliJ IDEA shortcut keys, but at the same
I want to bind a function to an event but I want to change
I want to bind a string value to a text box but only if
I want to bind Groupboxes to my stackpanel. c#: internal ObservableCollection<GroupBox> BindingTest { get
I want to bind to a value in a dictionary property of an object.
I want to bind my ListView control to a generic list of objects? I
I want to bind Ctrl-Alt-N to an External Tool (Nant build) in SharpDevelop, how

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.