Hello,
in my xsd i have declared that an
string attribute has a default value "a". Additionally I have set its length-restriction to "1". :
My understanding of this would be: "The attribute
test is optional. If it is not existent in the xml, the JAVA-Pojo object will be initialised with "a" (or at least will return "a" when getTest() is called). If the attribute test is existent, then it must have the lenght=1" CORRECT??
However, when unmarshalling an xml where this attribute is not existent, I get the following error:
Caused by: org.xml.sax.SAXParseException: cvc-length-valid: Value '' with length = '0' is not facet-valid with respect to length '1' for type '#AnonType_testFoo'.
Can you help??...Apparently he complains because the (non-existing) attribute does not meet the length restriction of 1, but that i find astonishing?...I mean, it should only apply the length restriction if the xml actually contains the attribute, or not??...Well, it could also be that the default-value is not applied at all??-->why?? (the surrounding xml element is existent of course..)
Or in other words: How do i have to specify the xsd so that an attribute may be optional, but if it is existent certain length restrictions apply??...
THANKS a lot for your help.