Hi Lawrence,

 

I see.  That’s a bit of a let down.  For me the whole purpose of having a default value in the schema was so that I didn’t have to explicitly set it via the setMethod() call.  But if that is not possible I’ll have to work around it.  Thanks any way.

 

Regards,

 

Artem

 


From: Lawrence Jones [mailto:[EMAIL PROTECTED]
Sent: Friday, March 03, 2006 5:03 PM
To: [email protected]
Subject: RE: Default attribute value and serialization

 

Hi Artem

 

Ah – so it’s not that the attribute has a empty value (i.e. <def:Section … method=”” >) - rather that the attribute is missing altogether. In that case I think what you are seeing is the expected behavior. If you fail to set an attribute but that attribute has a default value then for infoset validation purposes that attribute is present (see http://www.w3.org/TR/xmlschema-1/#sic-attrDefault) and hence if you call getMethod() you will get back the default value even though the attribute is not present.

 

If you explicitly want it to be present you can simply call setMethod() – after that the attribute (and its value) will show up in the output XML. If you simply want to check whether it is actually present or not you can use the isSetMethod() method.

 

Cheers,

 

Lawrence

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Friday, March 03, 2006 10:33 AM
To: [email protected]
Subject: RE: Default attribute value and serialization

 

Here’s a shortened version of the code.  I left out everything that didn’t have to do with the attribute in question.

 

    ConsolePageDocument doc = ConsolePageDocument.Factory.newInstance();

    ConsolePage consolePage = doc.addNewConsolePage();

    Right right = consolePage.addNewRight();

    SectionType section = right.addNewSection();

    section.setName("S/MIME Provider Settings");

    section.setHelp("Settings to enable the use of Secure Multipurpose Internet Mail Extensions");

    section.setStyle(SectionType.Style.FIELDSET);

    section.setForm("setSMIME");

    HTTPMethod.Enum m = section.getMethod(); // getting back HTTPMethod.POST

 

    // serialize document

    ByteArrayOutputStream result = new ByteArrayOutputStream();

    doc.save(result);

 

Here is what the Section node looks like when serialized…

 

<def:Section name="S/MIME Provider Settings" help="Settings to enable the use of Secure Multipurpose Internet Mail Extensions" style="fieldset" form="setSMIME">

 

Thanks,

 

Artem

 


From: Lawrence Jones [mailto:[EMAIL PROTECTED]
Sent: Friday, March 03, 2006 12:57 PM
To: [email protected]
Subject: RE: Default attribute value and serialization

 

Hi Artem

 

Can you send the code you are using to create your document please?

 

Cheers,

 

Lawrence

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Friday, March 03, 2006 9:14 AM
To: [email protected]
Subject: Default attribute value and serialization

 

Hi,

 

There appears to be a problem in XMLBeans with handling of default values for attributes.  I have an attribute in my schema that has a type of enumeration and also has a default value

 

             <xs:attribute name="method" type="com:HTTPMethod" default="POST"/>

 

       <xs:simpleType name="HTTPMethod">

             <xs:restriction base="xs:string">

                    <xs:enumeration value="GET"/>

                    <xs:enumeration value="POST"/>

             </xs:restriction>

       </xs:simpleType>

 

When I create my document using XMLBeans and serialize it via save(OutputStream), I end up with the method attribute having an empty value.  However, if I make a call to getMethod(), I’m getting the expected default value.  What am I doing wrong?

 

Thank you,

 

Artem

_______________________________________________________________________
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.
_______________________________________________________________________
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.

Reply via email to