I have a JAXB generated class PersonType with the properties name, phone, address. In the XSD I define that "phone" minoccurs="1". How can I test programatically(i.e. via reflection, etc), in Java code, if the property "phone" is required or not in the XSD?
Later edit: The JAXB generator creates a class without any "required", etc. attributes. So there's no annotation on the class or it's fields to indicate if it's required or not. However, there's the @XmlElement annotation on the field specifying the XSD equivalent element. So I guess the only solution is to inspect this annotation and then make an XPath or something against the XSD?
Thank you!
@XmlElement(required=true)
or you want to test that an instance of the class has the requirename
element? – bdoughan