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

The Archive Base Latest Questions

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

I’m going slowly mad over this. I’m trying to unmarshall an XML document like

  • 0

I’m going slowly mad over this. I’m trying to unmarshall an XML document like this:

<GetDeadlineOffset>
    <deadlineCode>DC1</deadlineCode>
    <parameters>
      <parameter name="P1">Param 1</parameter>
      <parameter name="P2">Param 2</parameter>
    </parameters>
</GetDeadlineOffset>

I have a pair of simple POJOs, GetDeadlineOffsetRequest and Parameter, which look like this:

public class GetDeadlineOffsetRequest {

    private String deadlineCode = null;
    private List<Parameter> parmList = new ArrayList<Parameter>();


    public GetDeadlineOffsetRequest() {
        // Do nothing
    }

    public String getDeadlineCode(){
        return this.deadlineCode;
    }

    public void setDeadlineCode(String deadlineCode){
        this.deadlineCode = deadlineCode;
    }

    public List<Parameter> getParameters() {
        return parmList;
    }

    public void setParameters(List<Parameter> parmList) {
        this.parmList = parmList;
    }

} 

and

public class Parameter {

    private String name = null;
    private String value = null;

    public Parameter() {
        // Do Nothing
    }

    public String getName() {
        return name;
    }

    public String getValue() {
        return value;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setValue(String value) {
        this.value = value;
    }
}

I’m using a mapping file but can’t seem to get those tags unmarshalled into my Parameter list.

This is my latest attempt at a mapping:

<class name="mypkg.GetDeadlineOffsetRequest">
    <map-to xml="GetDeadlineOffset"/>
    <field name="DeadlineCode" type="java.lang.String">
        <bind-xml name="deadlineCode" node="element" />
    </field>
    <field name="Parameters" type="mypkg.Parameter" collection="collection">
        <bind-xml name="parameters" node="element" />
    </field>    
</class>
<class name="mypkg.Parameter">
    <map-to ns-uri="http://services.blah.com/AMM/Deadline/v1"/>
    <field name="Value" type="java.lang.String">
        <bind-xml name="parameter" node="element" /> 
    </field>
    <field name="Name" type="java.lang.String">
        <bind-xml name="name" node="attribute" location="parameter" />  
    </field>
</class>

The problem seems to revolve around the fact that <parameters> is the container element and <parameter> is the repeatable element. The mapping above is telling Castor that <parameters> is repeatable.

I’ve been trying all sorts of combinations of mappings for a couple of days now and I think I’ve worked my way into a corner!

Can anyone see what I’m doing wrong?

I’m using Castor XML 1.3.2.

  • 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-27T07:36:27+00:00Added an answer on May 27, 2026 at 7:36 am

    I’ve managed to have some success with the following mapping:

    <class name="myPkg.GetDeadlineOffsetRequest">
        <map-to xml="GetDeadlineOffset"/>
        <field name="DeadlineCode">
            <bind-xml name="deadlineCode" />
        </field>
        <field name="parameters" type="myPkg.Parameter" collection="collection">
            <bind-xml name="parameter" location="parameters">
                <class name="myPkg.Parameter">
                    <field name="Name">
                        <bind-xml name="name" node="attribute" />
                    </field>
                    <field name="Value">
                        <bind-xml node="text"/>
                    </field>
                </class>
            </bind-xml>
        </field>        
    </class>
    

    The trick was to use location=”parameters” and node=”text” on a couple of the bind-xml elements. I’ve successfully marshalled and unmarshalled using this mapping.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
I would like to count the length of a string with PHP. The string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,

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.