我正在创建一个Spring Batch作业,需要从外部源发送的XML文件中读取数据。如果我有一个结构如下的XML文档:
<?xml version="1.0" encoding="UTF-8" ?>
<RootElement rootAttribute="attribute value">
<HeaderInformation>
<HeaderItem>Value</HeaderItem>
<SomeElement>Value</SomeElement>
</HeaderInformation>
<Records>
<RecordItem>
<ElementOne>Value</ElementOne>
<ElementTwo>Value</ElementTwo>
</RecordItem>
<RecordItem>
<ElementOne>Value</ElementOne>
<ElementTwo>Value</ElementTwo>
</RecordItem>
<RecordItem>
<ElementOne>Value</ElementOne>
<ElementTwo>Value</ElementTwo>
</RecordItem>
</Records>
</RootElement>
我可以使用StaxEventItemReader和Jaxb2Marshaller轻松读取必要的RecordItem。然而,问题出现了,我需要能够参考这个&#34;记录&#34;之外的一些信息。采集。例如,是否可以通过Jaxb绑定或Spring ItemReader配置从RootElement中提取rootAttribute值?
使用给定的示例,我要查找的最终结果是能够将ElementOne,ElementTwo和rootAttribute写入每个RecordItem的数据库。