0

I'm using JiBX to unmarshall XML based on a XSD provided by external source; unfortunately, some of the 'required' fields are not always present in the XML, which is causing JiBX to throw 'org.jibx.runtime.JiBXException: Missing required element'.

I know I can edit the XSD files and change the 'required' fields to optional, but since these files are updated periodically I would rather not do this. Is there a setting in JiBX I can change (either at compile/binding time or at runtime) to ignore missing elements at runtime, e.g., by setting the value of a field corresponding to a missing element to null?

EDIT: Change i.e. -> e.g. :)

JD White
  • 807
  • 1
  • 10
  • 15

1 Answers1

0

JD,
The easiest way to create a JiBX binding for a different schema definition is to modify the schema definition to your desired schema.
This can be done easily and cleanly by running an xml transformation on the original schema definition to create your new schema.
Take a look at this example of a maven project that modifies a schema before running JiBX: https://github.com/jibx/schema-library/blob/master/net.webservicex/net.webservicex.currencyconvertor/pom.xml
I know the xml transformation language is a pain, but this solves the problem you have with schema changes in the future. Your xslt command would look something like this:
<xsl:template match="//xs:attributeGroup[@name='FlifoLegAttributes']">
<xs:attributeGroup name="FlifoLegAttributes">
<xs:attribute name="AirRowType" type="OTA_CodeType" use="optional">
</xs:attribute>
</xs:attributeGroup>
</xsl:template>

I hope this helps.
Don

Don Corley
  • 496
  • 2
  • 7
  • Thanks! I didn't think it was very maintainable to manually edit the schema definitions every time they are updated, but a transformer plugin that executes automatically will work perfectly. – JD White Aug 29 '12 at 21:54