posted 13 years ago
>I am not generating classes for XSD and it should be not touch manually.
The question seems to concern two settings rather than one, namely, the fixed="yes" on an element's text content and the default="eng" again on an element's text content. For the fixed="yes", you may have an impass without touching the source code of the class (Doc.java). For default value, you may have a better chance if you are determined to do that.
It is said, as an excuse or whatever, that the Marshaller will not guarantee or that "there is no requirement that the Java content tree be valid with respect to its original schema in order to marshal it back into XML data." However, default setting concerns with a value constraint that if the marshller first output and then re-unmarshal in tandem, this time with validation in place, to a java content tree, that default value will be recognized and set automatically if the original value (a null) is not altered before marshalling.
Hence, a solution would be to leave it null (do not alter it) and marshal the content tree all done in memory and then unmarshal that output stream (after turning it into an input stream). The resultant content tree will have that default value all set and can be used by the application.