Validate XML Against A Schema Online#

Have you ever wanted to validate an xml document against a schema, but didn't have any applications at your disposal to do it?

You can use the schema validate tool on decisionsoft.com:

http://tools.decisionsoft.com/schemaValidate/

You upload a schema and an xml doc, and it will attempte to validate the xml against the schema.

Categories:  | 
Monday, January 14, 2008 8:58:18 AM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Regular Expressions Cheat Sheet#

Here is a cheat sheet that shows some of the main items when using Regular Expressions (RegEx / RegExp)

regular_expressions_cheat_sheet[1].png (80.91 KB)
Categories:  |  |  | 
Wednesday, January 31, 2007 1:28:22 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Using XSD.exe#

.Net has a tool called the XML Schema Definition Tool (XSD.EXE) which can turn XSD schemas into classes.  Also, it will try to make it so those classes will conform to the schema when serialized as XML.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/html/cpconxmlschemadefinitiontoolxsdexe.asp

xsd.exe pathToXSD.xsd /classes /language:VB /outputdir:C:\output

You can then serialize and deserialize the object into/from XML.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemXmlSerializationXmlSerializerClassTopic.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemXmlSerializationXmlSerializerClassDeserializeTopic.asp

 

 

Categories:  |  | 
Friday, August 25, 2006 2:10:35 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Validating XML document against an XML Schema with VB.Net#

It seems like validating an XML document against a schema would be a pretty simple thing to do in the .Net framework, seeing as how they have such deep support for dealing with XML.

But as of yet, I haven't found a simple way to do it.

Here is the code I have been using to validate XML against an XML Schema.

Imports System.IO
Imports System.Xml
Imports System.Xml.Schema


Private schemaValidation As New ValidationEventHandler(AddressOf ValidationHandler)

Private Function ValidateXml(ByVal xmlFileName As String, ByVal xmlSchemaName As String) As Boolean
Using myFile As New FileStream(xmlFileName, FileMode.Open, FileAccess.Read, FileShare.None)
Dim xDoc As New Xml.XmlDocument()
xDoc.Load(myFile)
xDoc.Schemas.Add(GetSchema(xmlSchemaName))
Try
xDoc.Validate(schemaValidation)
Return True
Catch ex As XmlSchemaValidationException
Console.Write(ex.ToString)
Return False
Catch ex As XmlSchemaException
Console.Write(ex.ToString)
Return False
Catch ex As Exception
Console.Write(ex.ToString)
Return False
End Try
End Using
End Function

Private Function GetSchema(ByVal filePath As String) As XmlSchema
Dim schema As XmlSchema
Using s As New System.IO.FileStream(filePath, FileMode.Open)
Using reader As New StreamReader(s)
schema = XmlSchema.Read(reader, Nothing)
End Using
End Using
Return schema
End Function

Private Sub ValidationHandler(ByVal sender As Object, ByVal e As System.Xml.Schema.ValidationEventArgs)
Throw e.Exception
End Sub
 
Categories:  |  |  |  | 
Saturday, July 29, 2006 3:35:25 PM (Central Standard Time, UTC-06:00) #    Comments [2]  | 

 

Sending Datasets and Objects Over the Wire: Serialization and XML#

I have tried to councel against sending datasets across web service calls, but we have a lot of instances where this is being done.

One of the problems with this is that datasets get bloated when converted to XML.

So I set out to compare the sizes of:

  1. Serialized List(Of MyType)
  2. Serialized DataTable
  3. Serialized DataSet
  4. XML Serialized Dataset

I wish I had done some research on this, because I would have quickly been reminded that DataSets always serialize as XML, even if you are using the BinaryFormatter. 

There are lots of people out there coming up with their own ideas for how to improve the serialization of datasets:

Anyway, this isn't really THAT big of a deal, because my real goal wasn't to improve the dataset serialization, but to simply see what it would be, and compare it to some other ways to serialize data, like in a list of business objects or a datatable.

The results are interesting:

Given a list of 1013 Business Objects (Records) the serialization results are as follows:

Method Size (bytes)
List(Of MyType) 290,321
DataTable 819,575
DataSet 693,088
XML Serialzied Dataset 851,614

I have read that you can really decrease the size of the dataset by writing your own logic to do the serialization, but as everyone points out that is kind of a pain.


Categories:  |  |  |  |  | 
Thursday, April 20, 2006 12:44:19 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Sending Data as an XML/HTML Excel Document#
This article shows how to send data as an xml/html Excel document. The user can then view it in IE, or choose to edit it in Excel (all functions come along when you do the Excel editing.
Categories:  |  |  |  | 
Wednesday, November 05, 2003 10:40:51 AM (Central Standard Time, UTC-06:00) #    Comments [1]  | 

 

XML Serialization in .NET#
This article describes how to use XML Serialization to persist objects.

This is the only article on XML Serialization that I have found that shows how to convert the object into a string rather than a file on the hard drive.
Categories:  |  | 
Wednesday, August 06, 2003 1:19:34 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

MSXML XML DOM Reference#
It was a pain in the butt trying to find this. Ok, well it wasn't THAT hard, but I didn't expect it to be so buried on the MSDN site, and of course their search features totally suck.

Here is the MSXML XML DOM Reference page from MSDN.
Categories:  | 
Friday, July 25, 2003 12:51:05 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

All content © 2008, Christopher May, Inc
Open Job Positions
On this page
Google Ads
This site
Calendar
<December 2008>
SunMonTueWedThuFriSat
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910
Archives
Sitemap
Blogroll OPML
Disclaimer

Powered by: newtelligence dasBlog 1.9.6264.0

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Send mail to the author(s) E-mail

Theme design by Jelle Druyts


Pick a theme: