xsd && jaxb: how to read optional fixed attribute?
Hi,
I would like to ask you for help. Suppose I've got here some xml, which xsd define attribute on some element to be OPTIONAL, but if present, then it has to have FIXED value. So let's look at xsd fragment (please do not consider xml design problems, I cannot correct them anyway).
<xs:element name="ret">
<xs:complexType>
<xs:all>
<xs:element name="description" type="xs:string" minOccurs="0" />
</xs:all>
<xs:attribute name="ok" type="xs:string" fixed="yes"/>
</xs:complexType>
</xs:element>
when I run xjc I got generated following code for "ok" parameter
public String getOk() {
if (ok == null) {
return "yes";
} else {
return ok;
}
}
which means, that when I access the "ok" parameter to check it's presence (it's optional) it always be there even if it was not specified in xml file.
What can I do to correct it?
Re: xsd && jaxb: how to read optional fixed attribute?
Anyone by chance stumble across an answer for this?