Jacob,

Thanks for replying, 

I'm creating the document from scratch using the code generated from the
schema.

I'm wondering if it's my use of XmlDateTime that is actually wrong!

I created a simple schema which I've included below for reference, with
a single xsd:dateTime. Then generated the jar file using scomp.

My java code looks like this, to create the document and initialise the
XmlDateTime.

    EXTSYS2CERSPortReport rep =
EXTSYS2CERSPortReport.Factory.newInstance();
    PortHeaderType header = rep.addNewHeader();
    header.setCERSId("CERSID");
    header.setExtId("ME");


        GDate g = new org.apache.xmlbeans.GDate("2008-05-16T09:41:41");
      XmlDateTime xdatetime = XmlDateTime.Factory.newInstance();
      xdatetime.setGDateValue(g);


When setting the values, this worked

    header.setTimestamp(xdatetime.calendarValue());

(<Header Timestamp="2008-05-16T09:47:06" ExtId="ME" CERSId="CERSID"
xmlns="urn:port/types"/>)

but the next statement didn't work, yet xdatetime is an XmlDateTime
object, correctly initialised.

header.xsetTimestamp(xdatetime);
(<Header Timestamp="" ExtId="ME" CERSId="CERSID"
xmlns="urn:port/types"/>)

So, I ended up calling getCalenderValue() on the xmldatetime object and
using the non-xml set method which takes in a calendar to get it
working.

This is fine for me, as it removes the time-zone from the standard
calendar, so it works, but is this the way I should use it?

Pete



<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:tns="urn:port/types"
xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
xmlns="http://www.w3.org/2001/XMLSchema";
targetNamespace="urn:port/types" elementFormDefault="qualified">
        <xsd:complexType name="EXTSYS2CERSPortReport">
                <xsd:sequence>
                        <xsd:element name="Header"
type="tns:portHeaderType"/>
                </xsd:sequence>
        </xsd:complexType>
        <xsd:complexType name="portHeaderType">
                <xsd:attribute name="ExtId" type="xsd:string"
use="required"/>
                <xsd:attribute name="CERSId" type="xsd:string"/>
                <xsd:attribute name="ParentId" type="xsd:string"/>
                <xsd:attribute name="Timestamp" type="xsd:dateTime"
use="required"/>
                <xsd:attribute name="Originator" type="xsd:string"
use="required"/>
                <xsd:attribute name="Priority" type="xsd:string"/>
                <xsd:attribute name="MsgType" type="xsd:string"
use="required"/>
                <xsd:attribute name="MsgSubType" type="xsd:string"
use="required"/>
        </xsd:complexType>
</xsd:schema>

-----Original Message-----
From: Jacob Danner [mailto:[EMAIL PROTECTED] 
Sent: 16 May 2008 00:38
To: user@xmlbeans.apache.org
Subject: Re: XMLBeans 1.0.4 Question about XmlDateTime & xSet* methods

Interesting issue, I don't have 1.0.4 locally, but maybe you can try
something for me.
Can you validate your data and see if there are any errors?
Thanks,
-jacobd

On Thu, May 15, 2008 at 3:30 PM, Inman, Peter <[EMAIL PROTECTED]>
wrote:
> I have a problem and I'm not sure what's going wrong. I'm using versin
1.0.4
> as I have to fit this into a WebLogic 8.1 app server, version 2.*
isn't an
> option (as far as I know as there are conflicts with jar's)
>
>
>
> Anyway, I have a schema which has been defined using xsd:dateTime
formats.
> XMLB has converted these and provided set methods as it should, for
example
> setETA(Calendar cal)
>
>
>
> The problem I have is that the setETA() method takes in a calendar,
and when
> this is converted to XML, it includes the time-zone information and I
> actually need a specific format for the date in the created XML.
>
>
>
> I then looked at the xsetETA() method, which takes in an XmlDateTime,
and
> this looks like it will do the job, but when I call it, the value
doesn't
> get set when I print out the xml. The XmlDateTime is correctly
initialised.
>
>
>
> Has anyone any ideas?
>
>
>
> I could change the generated source code, and make the setETA method
> actually take in a string - that's what I want in the XML anyway, but
I'd
> rather not do this if I can avoid it.
>
>
>
> I'd be grateful for any assistance.
>
>
>
> Pete



-- 
I'm competing in a Half-Ironman distance triathlon to raise money for
the fight against cancer!
Please help support my efforts by going to:
http://www.active.com/donate/tntwaak/jacobd

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