Announcement Announcement Module
Collapse
No announcement yet.
JAXB Attribute Ordering Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JAXB Attribute Ordering

    We are approaching the System Testing phase of a project to redesign an old daily extract job into Spring Batch and would like an easy way of comparing the old xml output with the output of the new Spring Batch job. During initial unit testing we noticed that the order in which the element attributes are written to the xml file are in reverse order of how they are declared in the JAXB class. We confirmed this by taking one JAXB class and reversed the order in which the attributes are declared. However since we have hundreds of JAXB classes this would be a lengthy task we would like if possible to avoid this. We have also tried to use the xmltype annotation in the JAXB class but that didn’t affect the attribute order just the element order.

    Code:
    @XmlType(name = "", propOrder = {“one”,”two”,… })
    I am fully aware that the order isn’t important in xml files as this is solely from a readability perspective and to make the system tester’s job easier as these files are going to be a several GB’s in size.

    So my question is without having to change the schema (as this is already published and cannot be changed) is there an easy programmatic way (in String Batch) to reverse the order in which the element attributes are written to the xml file?

    For reference i'm using the

    Code:
    :
    		<bean id="writer" scope="step" class="org.springframework.batch.item.xml.StaxEventItemWriter">
    			<property name="resource" value="file:#{stepExecutionContext[partitionFolder]}" />
    			<property name="marshaller" ref="JAXB2Marshaller" />
    			<property name="rootTagName" value="DailyExtract" />
    			<property name="overwriteOutput" value="true" />
    		</bean>
    	
    		<bean id="JAXB2Marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
    			<property name="classesToBeBound">
    				<list>...</list>
    			</property>
    			<!--  this turns on validation -->
    <!--			<property name="schema" value="classpath:META-INF/xml_schemas/DailyExtract.xsd"/>-->
    		</bean>
    :
    Thanks in advance
    Dave
Working...
X