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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:14:56+00:00 2026-06-18T01:14:56+00:00

Consider the following xml: <Config> <Paths> <Path reference=WS_License/> </Paths> <Steps> <Step id=WS_License title=License Agreement

  • 0

Consider the following xml:

<Config>
    <Paths>
        <Path reference="WS_License"/>
    </Paths>

    <Steps>
        <Step id="WS_License" title="License Agreement" />
    </Steps>
</Config>

The following JAXB classes:

public class Path {

    private String _reference;

    public String getReference() {
        return _reference;
    }

    @XmlAttribute
    public void setReference( String reference ) {
        _reference = reference;
    }

}

And

public class Step {

    private String _id;
    private String _title;

    public String getId() {
        return _id;
    }

    @XmlAttribute
    public void setId( String id ) {
        _id = id;
    }

    public String getTitle() {
        return _title;
    }

    @XmlAttribute
    public void setTitle( String title ) {
        _title = title;
    }

}

Instead of storing the reference in the Path object as String, I’d like to hold it as a Step object. The link between those objects is the reference and id attributes. Is the @XMLJavaTypeAdapter attribute the way to go? Could anyone be so kind to provide an example of the correct usage?

Thanks!

EDIT:

I’d also would like to do the same technique with an element.

Consider the following xml:

<Config>
    <Step id="WS_License" title="License Agreement">
        <DetailPanelReference reference="DP_License" />
    </Step>

    <DetailPanels>
        <DetalPanel id="DP_License" title="License Agreement" />
    </DetailPanels>
</Config>

The following JAXB classes:

@XmlAccessorType(XmlAccessType.FIELD)
public class Step {

    @XmlID
    @XmlAttribute(name="id")
    private String _id;

    @XmlAttribute(name="title")
    private String _title;

    @XmlIDREF
    @XmlElement(name="DetailPanelReference", type=DetailPanel.class)
    private DetailPanel[] _detailPanels; //Doesn't seem to work

}

@XmlAccessorType(XmlAccessType.FIELD)
public class DetailPanel {

    @XmlID
    @XmlAttribute(name="id")
    private String _id;

    @XmlAttribute(name="title")
    private String _title;

}

The property _detailPanels in the Step-object is empty and the link doesn’t seems to work. Is there any option to create a link without creating a new JAXB object holding only the reference to the DetailPanel?

Thanks again : )!

  • 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-18T01:14:58+00:00Added an answer on June 18, 2026 at 1:14 am

    You can use @XmlID to map a property as the key and @XmlIDREF to map the reference to the key for this use case.

    Step

    @XmlAccessorType(XmlAccessType.FIELD)
    public class Step {
    
        @XmlID
        @XmlAttribute
        private String _id;
    
    }
    

    Path

    @XmlAccessorType(XmlAccessType.FIELD)
    public class Path {
    
        @XmlIDREF
        @XmlAttribute
        private Step _reference;
    
    }
    

    For More Information

    • http://blog.bdoughan.com/2010/10/jaxb-and-shared-references-xmlid-and.html

    UPDATE

    Thanks! I Completely missed your article. I’ve extended my question,
    do you have any clue if this is possible too? I do not want to create
    a class with only holding the reference, I’d like to store it inside
    the step class.

    Note: I’m the EclipseLink JAXB (MOXy) lead and a member of the JAXB (JSR-222) expert group.

    If you are using MOXy as your JAXB (JSR-222) provider then you could leverage the @XmlPath annotation for your use case.

    import javax.xml.bind.annotation.*;
    import org.eclipse.persistence.oxm.annotations.XmlPath;
    
    @XmlAccessorType(XmlAccessType.FIELD)
    public class Step {
    
        @XmlID
        @XmlAttribute
        private String id;
    
        @XmlPath("DetailPanelReference/@reference")
        @XmlIDREF
        // private List<DetailPanel> _detailPanels; // WORKS
        private DetailPanel[] _detailPanels; // See bug:  http://bugs.eclipse.org/399293
    
    }
    

    For More Information

    • http://bugs.eclipse.org/399293
    • http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as-your.html
    • http://blog.bdoughan.com/2010/07/xpath-based-mapping.html
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following XML: <root> <steps> <step>1</step> <step>2</step> <step>3</step> <step>4</step> </steps> <stepDetails step=1>Details</stepDetails> <stepDetails
Consider the following XML: <?xml version=1.0 encoding=ISO-8859-1?> <catalog> <cd> <title>Empire Burlesque</title> <artist> <name>Bob</name> <surname>Dylan</surname>
let us consider the following web.config file <?xml version=1.0?> <configuration> <configSections> <section name=hibernate-configuration type=NHibernate.Cfg.ConfigurationSectionHandler,
consider following codes and classes: using System.Collections.Generic; using System.IO; using System.Linq; using System.Xml.Serialization; namespace
Consider following XML document fragment: <Book> <Title>Example</Title> <Content> Some line </Content> <TOC> Again some
Consider the following XML: <?xml version=1.0 encoding=ISO-8859-1?> <CATALOG> <CD> <TITLE>Empire Burlesque</TITLE> <ARTIST>Bob Dylan</ARTIST> <COUNTRY>USA</COUNTRY>
Using MSSQL 2008 and XQUERY Consider the following XML stored in a table: <ROOT>
Consider the following code: $xml = <<<XML <root> <region id='thisRegion'></region> <region id='thatRegion'></region> </root> XML;
consider my 'destinationURLLookUp.xml' file has the following structure <?xml version=1.0 encoding=UTF-8?> <destinationURLs xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance> <destinationURL
Consider this scenario: I've an XML file called person.xml with the following data in

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.