Unable to set datetimes in KML 2.2

Nov 15, 2010 at 12:38 AM

Hi all,

  I'm using this to build a KML feed.  I've reverse generated this schema with the default options.  http://schemas.opengis.net/kml/2.2.0/ogckml22.xsd.  I'm unable to use the following calls.

 

when when = new when(point.CreatedDate.ConvertToUtc());

TimeStamp timestamp = new TimeStamp();
timestamp.when = when;

placemark.AbstractTimePrimitiveGroup = timestamp;

 

I receive this error on the timestamp.when = when assignment.

 

[LinqToXsdException: Failed to set value on the property "when". Possible reason: The Given Value 2010-10-28T02:30:40Z Violates Restrictions: Union Type: No Matching Member Type Was Found. Valid Types  = (DateTime Date GYearMonth GYear)]
   Xml.Schema.Linq.XTypedElement.SetUnionCatchAll(Object value, String propertyName, XTypedElement container, XName itemXName, SimpleTypeValidator typeDef, SchemaOrigin origin) +285
   Xml.Schema.Linq.XTypedElement.SetUnionElement(Object value, String propertyName, XTypedElement container, XName itemXName, SimpleTypeValidator typeDef) +51
   www.opengis.net.kml.Item2.Item2.TimeStampType.set_when(when value) in C:\development\spidertracks\WebModel\Model\KmlGIS\ogckml22.cs:12676
   www.opengis.net.kml.Item2.Item2.TimeStamp.set_when(when value) in C:\development\spidertracks\WebModel\Model\KmlGIS\ogckml22.cs:40193
   WebModel.Model.KmlGIS.TrackKmlBuilder.AddPoints(FolderType folder, Track track) in C:\development\spidertracks\WebModel\Model\KmlGIS\TrackKmlBuilder.cs:181


I'm unsure how to get around this, the schema defines the time of "when" as xsd:dateTime, xsd:date, or 2 google custom date types.  I thought since it uses the standard xsd:dateTime, I would be able to assign it the .NET DateTime object.  Is this not the case?

 

Thanks,

Todd

 

Nov 19, 2012 at 8:21 PM
Edited Nov 19, 2012 at 8:21 PM

I'm experiencing the same issue.  Did you ever resovle this?

Nov 27, 2012 at 9:31 AM

I've loaded the schema in XMLSpy, but it's failing to parse the schema at:

<import namespace="http://www.w3.org/2005/Atom" schemaLocation="atom-author-link.xsd"/>