dataset and xsl transformation

G

Guest

We have a webservice that has a method and this method returns a dataset. In
the client we can change values of this dataset and send it back to
webservices which in turn updates a database. Well we discovered a problem
with the datasets (I don’t know if it’s a problem or not actually). It seems
when you have a datetime field in a dataset, it’s value is stored along with
the local time zone info. The problem arises if the webservice and the client
are in different time zones. Let’s say if the web service is in Eastern and
the client is in Central time zone. A value “2/2/2005 00:00:000000-05:00†in
the webservices when sent to the client displayed as “2/1/2005
23:00:000000-06:00â€. Dataset is basically doing a little transformation when
it’s deserializing in the client. This is not desirable for us. We want
everyone to see the value as it’s in the database. So we came up with a
solution. I’m not passing dataset to the client anymore, but I’m xml
serializing the dataset and pass the string to the client. Then in the client
before I desearialize the dataset, I stript out the timezone information.
After the deserialization, we see that the process slugs in local time zone
information in the datetime field values and now we see “2/2/2005
00:00:000000-06:00†as our value. This is our ideal solution. But we want to
optimize the process of striping time zone info out of serialized dataset. We
can traverse it using xml dom, but I think we can also use XSLT as well. So
how can do this transformation with using XSLT.
 
K

Kevin Yu [MSFT]

Hi,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to keep the time zone format
of certain DateTime column. If there is any misunderstanding, please feel
free to let me know.

IMO, it is not recommended to modify the raw data in the DataSet xml. This
might mix up the data in this DataSet. So I suggest you try the following:

1. Get the server time zone offset by calling
System.TimeZone.CurrentTimeZone.GetUtcOffset() in a web method.
2. Get the client side time zone offset and caculate the time difference
between server side and client side.
3. When getting the date time data on client side, it is in the local zone.
We just add or subtract the time difference and display it to user. It is
now in server side zone.
4. After modification, we then change it back to local zone, and then
serialize it and update to server.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
G

Guest

We want to remove the time zone from the XML. Actually, form the dataset,
but currently .NET doesn't support this.

What about when there are multiple servers, potentially in different time
zones? Isn't clear to me that a request for the "server" zone will be for
the same server where the Web services are running when the data are sent
from the client to IIs machine(s). Bottom line is we need to strip out the
TZ so what date/time the user enters is what gets put in the database and
what is returned when people in different time zones look at the record. The
"favor" being done of converting date/time isn't always a good thing! If you
have a way to turn this off I'd sure like to know it!
 
K

Kevin Yu [MSFT]

Hi,

If we have multiple web servers, we can still use this method to caculate
the time. When the DataSet is filled at the web server, the date time are
all in the web server's time zone. We also get the timezone information
together with the DataSet, and then can convert the time to server timezone.

If you need to cut the time zone information directly in xml, we can use
XSLT or go throught each node of the xml. Here is a KB article on this.

http://support.microsoft.com/?id=330597

Also if we use XSLT, we can pass node sets to inline XSLT script functions.
Check the following KB for more information.

http://support.microsoft.com/?id=330602

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top