开发者

Validating XML against XSD using Silverlight?

So I have been twiddling with a personal project to import my garmin gps data into a local database. The data lives in a GPX xml file, whose schema is defined by an xsd file.

The idea is for the开发者_高级运维 client to upload their GPX file, and the SL client would validate it before sending it to the server. But I ran into some issues here, first that it seems silverlight cannot validate xml against xsd.

So first, is this true or have I just not figured out how to do the validation on the client side? I already wrote the code on the server side (a regular class library) but this code wont compile on the client side if I try to move it there. An error about can't use 'new XmlSchemaSet();' because it is a private constructor.

Secondly, assuming that I do indeed have to do the validation on the server side, how with RIA do I return informative errors to the client?


You could set a pagemethod and via ajax calls on a javascript return to silvelight some error text.

http://forums.silverlight.net/forums/p/199354/477971.aspx

Hope it helps


Silverlight does not support XML validation against XSD. According to MSDN, the XmlSchemaSet class is provided only for interface compatibility.

So the only solutions is

  1. Either send the XML file to be validated in the server
  2. Or implement your custom validator in the client side manually.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜