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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:55:27+00:00 2026-06-14T23:55:27+00:00

I would like to unmarshal an XML file with this xsd definition using jaxb.

  • 0

I would like to unmarshal an XML file with this xsd definition using jaxb.

I have generated java classes using eclipse right click, generate jaxb classes, etc. I have no problems unmarshalling XML files.

enter image description here

The problem is that I don’t know how to un marshal (map?) MetadataType. Below is the xsd definition for metadataType and the class generated:

<complexType name="metadataType">
    <annotation>
      <documentation>Metadata must be expressed in XML that complies
       with another XML Schema (namespace=#other). Metadata must be 
       explicitly qualified in the response.</documentation>
    </annotation>
    <sequence>
      <any namespace="##other" processContents="strict"/>
    </sequence>
  </complexType>

Generated class for this Type is:

//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
// Any modifications to this file will be lost upon recompilation of the source schema. 
// Generated on: 2012.11.08 at 05:28:26 PM PST 
//


import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlType;


/**
 * Metadata must be expressed in XML that complies
 *        with another XML Schema (namespace=#other). Metadata must be 
 *        explicitly qualified in the response.
 * 
 * <p>Java class for metadataType complex type.
 * 
 * <p>The following schema fragment specifies the expected content contained within this class.
 * 
 * <pre>
 * &lt;complexType name="metadataType">
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;any namespace='##other'/>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "metadataType", propOrder = {
    "any"
})
public class MetadataType {

    @XmlAnyElement(lax = true)
    protected Object any;

    /**
     * Gets the value of the any property.
     * 
     * @return
     *     possible object is
     *     {@link Object }
     *     
     */
    public Object getAny() {
        return any;
    }

    /**
     * Sets the value of the any property.
     * 
     * @param value
     *     allowed object is
     *     {@link Object }
     *     
     */
    public void setAny(Object value) {
        this.any = value;
    }

}

The external xsd for is here

The unmarshalled XML doc generate this:
unmarshalled XML data

UPDATE:

Also, I’ve generated classes from the external xsd:

OaiDcType.java
ElementType.java

Those classes must contain the data of MetadataType object.

I would like to convert any to my own OaiDcType object, wich is the correct/best way to do this?

  • 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-14T23:55:29+00:00Added an answer on June 14, 2026 at 11:55 pm

    The DOM Element is what you get from an any when the JAXBContext doesn’t know anything about the type of the element it found in the XML. If you have JAXB annotated classes for the element in question and the JAXBContext knows about these as well as the top level OAI-PMH classes then the element will automatically get unmarshalled to the relevant class and getAny will return that object rather than an Element.

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

Sidebar

Related Questions

I have several hand-written Java classes in a REST Server that uses JAXB to
i would like to have bidirectional navigation methods in classes between child object and
would like to know how can this be implemented in Joomla. I have a
Would like to parse IPv4 address from exit-addresses . Format of the file: ExitNode
Would like to make anapplication in Java that will not automatically parse parameters used
Is it possible to use JAXB to unmarshall xml to a specific Java class
I have an XML schema: <xsd:element name=Person> <xsd:complexType> <xsd:sequence> <xsd:element name=name type=xsd:string /> <xsd:element
Would like to sort the following XML by joining the fsxml/formula/ingrrow where itemcode =
Would like to fopen() the latest file in a directory (with naming scheme file1.txt,
would like to create a function that generates graphs using ggplot. For the sake

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.