Results 1 to 2 of 2
  1. #1
    alfonz19 is offline Member
    Join Date
    Jan 2011
    Posts
    6
    Rep Power
    0

    Default 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?

  2. #2
    jshrader is offline Member
    Join Date
    Mar 2012
    Posts
    1
    Rep Power
    0

    Default Re: xsd && jaxb: how to read optional fixed attribute?

    Anyone by chance stumble across an answer for this?

Similar Threads

  1. Fixed location
    By Dipke in forum New To Java
    Replies: 4
    Last Post: 08-13-2010, 11:25 AM
  2. How to read a fixed number of bytes in a DataInputStream
    By Michailangelo in forum Networking
    Replies: 4
    Last Post: 06-29-2010, 03:13 AM
  3. how to read an attribute of an xml tag in jsp.
    By himacherla in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 07-21-2009, 07:27 AM
  4. Error FIxed type attribute not equal
    By phoenix_yadu in forum Advanced Java
    Replies: 2
    Last Post: 04-23-2009, 05:36 PM
  5. regex problem - allowing optional space
    By Norm in forum Advanced Java
    Replies: 26
    Last Post: 10-06-2008, 05:38 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •