Please disregard this question. I was doing something silly: Setting the 
modified date after putting the modified data back into the document. 

-----Original Message-----
From: Chris Dole [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, November 30, 2005 5:22 PM
To: [email protected]
Subject: Problem (re)Setting Dates

Hello,

I have successfully used the generated code from XMLBeans to read and write 
from XML files, with one small caveat. I have a date attribute that gets set to 
the first value that comes in, but subsequent sets do not override the first 
value. I even tried calling the "unset" method first, but to no avail. Textual 
elements and attributes all get new values applied, but not the dates.

Can someone scan the information below and tell me what I need to do 
differently?

Many thanks,
Chris

##############################

A fragment of my schema:

        <xsd:element name="BusObj">
                <xsd:annotation>
                        <xsd:documentation>BusObj is the "base class" that 
contains fields
                        common to all other business 
objects.</xsd:documentation>
                </xsd:annotation>
                <xsd:complexType>
                        <xsd:sequence>
                                <xsd:element ref="boc:Title"/>
                                <xsd:element ref="boc:DescriptionText"/>
                        </xsd:sequence>
                        <xsd:attribute ref="boc:Id"/>
                        <xsd:attribute ref="boc:OwnerId"/>
                        <xsd:attribute ref="boc:Shared"/>
                        <xsd:attribute ref="boc:DateCreated"/>
                        <xsd:attribute ref="boc:DateModified"/>
                </xsd:complexType>
        </xsd:element>
        
        <xsd:attribute name="DateModified" type="xsd:dateTime"/>

It generates a BusObj class with the following salient methods:

        /**
         * Sets the "DateModified" attribute
         */
        public void setDateModified(java.util.Calendar dateModified)
        {
            synchronized (monitor())
            {
                check_orphaned();
                org.apache.xmlbeans.SimpleValue target = null;
                target = 
(org.apache.xmlbeans.SimpleValue)get_store().find_attribute_user(DATEMODIFIED$12);
                if (target == null)
                {
                    target = 
(org.apache.xmlbeans.SimpleValue)get_store().add_attribute_user(DATEMODIFIED$12);
                }
                target.setCalendarValue(dateModified);
            }
        }
        
        /**
         * Sets (as xml) the "DateModified" attribute
         */
        public void xsetDateModified(org.apache.xmlbeans.XmlDateTime 
dateModified)
        {
            synchronized (monitor())
            {
                check_orphaned();
                org.apache.xmlbeans.XmlDateTime target = null;
                target = 
(org.apache.xmlbeans.XmlDateTime)get_store().find_attribute_user(DATEMODIFIED$12);
                if (target == null)
                {
                    target = 
(org.apache.xmlbeans.XmlDateTime)get_store().add_attribute_user(DATEMODIFIED$12);
                }
                target.set(dateModified);
            }
        }
        
        /**
         * Unsets the "DateModified" attribute
         */
        public void unsetDateModified()
        {
            synchronized (monitor())
            {
                check_orphaned();
                get_store().remove_attribute(DATEMODIFIED$12);
            }
        }

Here is my wrapper that I call to set the date using a java.util.Date as the 
input for the XmlCalendar which is then the input for the XML date value.

    // My wrapper around the XMLBeans 
    private BusObj _xmlbObj;
    public void setDateModified(Date dateModified)
    {
        synchronized(_xmlbObj)
        {
            _xmlbObj.unsetDateModified();
            _xmlbObj.setDateModified(new XmlCalendar(dateModified));
        }
    }


Chris Dole                      SAS Institute, Inc.
Member Applications Staff
[EMAIL PROTECTED]               (919) 531-0698
SAS...  The Power to Know



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to