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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:46:27+00:00 2026-06-11T20:46:27+00:00

I am currently using a Spring Batch application to call an API and parse

  • 0

I am currently using a Spring Batch application to call an API and parse out the entire JSON response into an XML to be consumed by another application. Currently we are using a rather large expand query with the API which sometimes times out on elements. The required output format for the results is

<?xml version...?>
<RECORDS>
    <RECORD>
        <PROP NAME="json.path.to.element.name">
            <PVAL>The value for the element</PVAL>
        </PROP>
        <PROP NAME="json.path.to.element2.name">
            <PVAL>The value for the element2</PVAL>
        </PROP>
        ...
    </RECORD>
    <RECORD>
        ...
    </RECORD>
    ...
</RECORDS>

This was being created using a DOMSource and a Transformer. This unfortunately does not take advantage of the Spring Batch chunk processing. I am updating this to extend StaxEventItemWriter and passing a list of mapped objects. My mapped entities are

@XmlElement
public class Record implements Serializable {

    private List<Prop> prop;
}

@XmlElement
public class Prop implements Serializable {

    @XmlAttribute
    private String name;

    @XmlValue
    private String pVal;
}

My Spring Batch XML config for my marshaller is

<bean id="xmlMarshaller" class="org.springframework.oxm.xstream.XStreamMarshaller">
    <property name="aliases">
        <map>
            <entry key="RECORD" value="com...Record"/>
            <entry key="PROP" value="com...Prop" />
        </map>
    </property>
</bean>

The problem I am getting is my output format is not working. I am getting

<?xml version...?>
<RECORDS>
    <RECORD>
        <prop>
            <PROP>
                <name>json.path.to.element1.name"</name>
                <pVal>The value for the element1</pVal>
            </PROP>
                <name>json.path.to.element2.name"</name>
                <pVal>The value for the element2</pVal>
            </PROP>
            ...
        </prop>
    </RECORD>
    <RECORD>
        <prop>
            ...
        </prop>
    </RECORD>
    ...
</RECORDS>

The two things that need to happen is 1) the <prop> entity needs to be removed as directly under the Record are all the <PROP> entities. and 2) the <PROP> needs to be <PROP NAME...>

I have tried messing with the annotations but can’t seem to change the output. I am not even sure what the XSD would be for the desired structure.

  • 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-11T20:46:28+00:00Added an answer on June 11, 2026 at 8:46 pm

    For the second part of your question, the correct annotation for the name field should be as below if you want it to be an attribute.

    @XStreamAsAttribute
    private String name;
    

    Following the XStream annotation documents , the first part should be:

    @XStreamImplicit(itemFieldName="PROP")
    private List<Prop> prop;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently building an application using Tomcat, Spring and JAVA. I am using
I currently scan packages for DAOs and services using Spring 3.1 & Hibernate 4
I'm currently migrating a project that is using Spring MVC without annotations to Spring
I am new to spring and I am currently using ClassPathXmlApplicationContext to getBean inside
My application data access layer is built using Spring and EclipseLink and I am
I have a spring web application (currently packaged as a war file) which I
I am using spring batch to process multiple files using MultiResourcePartitioner and all the
currently using spring 'exposedContextBeanNames' to allow me to display properties in my view but
We are currently using Spring MVC to implement REST web services. We now want
i currently build an application use spring as framework. and i want to test

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.