I have an XSD definition as :
<beanio xmlns="http://www.beanio.org/2012/03">
<stream name="udraccess" format="xml">
<parser class="org.beanio.stream.xml.XmlRecordParserFactory" />
.
..lines
..of
..XML code
<segment name="aggregationDimensions" class="java.util.HashMap" collection="list" minOccurs="0" maxOccurs="unbounded">
<segment name="aggregationDimension" class="java.util.HashMap" collection="list" minOccurs="0" maxOccurs="unbounded">
<field name="aggregationDimensionType" xmlType="element" minOccurs="0"/>
<field name="aggregationThresholdDimensionUnitType" xmlType="element" minOccurs="0" />
<field name="aggregationDimensionValue" xmlType="element" minOccurs="0"/>
<segment name="aggregationDimensionAverageInfo" class="java.util.HashMap" collection="list" minOccurs="0" maxOccurs="unbounded">
<field name="averageValueTotal" xmlType="element" minOccurs="0"/>
<field name="averageValueCount" xmlType="element" minOccurs="0"/>
<field name="averageValuePerType" xmlType="element" minOccurs="0"/>
</segment>
</segment>
</segment>
Now in this particular segment: aggregationDimensionAverageInfo
, I need that if this value is not present in the input XML, the output XML file should not have that field at all... Currently I am getting the field as an empty array, I want that it should be skipped completely if missing:
"aggregationDimensions": [
{
"aggregationDimension": [
{
"aggregationDimensionAverageInfo": [],
"aggregationDimensionType": "106",
"aggregationDimensionValue": "15:"
}
]
}
],
If that field is present in the input XML, I get it alright as below:
"aggregationDimensions": [
{
"aggregationDimension": [
{
"aggregationDimensionAverageInfo": [
{
"averageValuePerType": "50",
"averageValueTotal": "50",
"averageValueCount": "1"
}
],
"aggregationDimensionType": "106",
"aggregationDimensionValue": "0:15"
}
]
}
],
I need help with the scenario where its missing from the input XML.