Lost Password?

Go Back   CodeCall Programming Forum > Software Development > C# Programming

Vote on your favorite hash algorithm here!

C# Programming C# (pronounced C-sharp) is a new object oriented language from Microsoft and is derived from C and C++. It also borrows a lot of concepts from Java too including garbage collection.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-03-2007, 09:50 AM
hoser2001's Avatar   
hoser2001 hoser2001 is offline
Programmer
 
Join Date: Jul 2006
Posts: 175
Credits: 0
Rep Power: 10
hoser2001 is on a distinguished road
Default Help with Application Logic for .NET 2.0

Here is what I'm trying to do:

1.) I have an application that is able to produce an xml document, and xsd and zips the two files together.
2.) Using remoting I send the contents of the zip file to a server application.
3.) My server application uncompresses the information and now has the xml and xsd file.

My question is how do I now use the xsd to validate the xml. Both files are in memory.

Also: I understand it doesn't make sense to send an xsd with every xml document, but for my purposes it does... don't ask....

I'm not even sure if this is the right area to post this question, if not I'm sorry.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 07-03-2007, 12:23 PM
falco85 falco85 is offline
Programmer
 
Join Date: Apr 2006
Posts: 105
Credits: 2
Rep Power: 10
falco85 is on a distinguished road
Default

This should help you:

XML UI: from XSD to XML
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 08-01-2007, 05:30 PM
OthelloNYC OthelloNYC is offline
Newbie
 
Join Date: Jul 2007
Posts: 15
Credits: 0
Rep Power: 5
OthelloNYC is on a distinguished road
Default

Quote:
Originally Posted by hoser2001 View Post
3.) My server application uncompresses the information and now has the xml and xsd file.
--------------------------------------------------------------------------
Both files are in memory.
Are both files in memory, or do you still have them physically? if the latter, I have this code:
-------------------------------------------------------------------------
Imports System.Xml
Imports System.Xml.Schema

Public Class XMLValidator


Public Sub New()
End Sub

Public Function Validate(ByVal fileName As String) As Boolean
If SchemaCollection Is Nothing Then
Throw New Exception("Property 'Schema' not set")
End If
Dim ValidatingReader As XmlValidatingReader

Try
ValidatingReader = New XmlValidatingReader(New XmlTextReader(fileName))
ValidatingReader.Schemas.Add(SchemaCollection)
ValidatingReader.ValidationType = ValidationType.Schema
' Set the validation event handler
Dim valdel As ValidationEventHandler = New ValidationEventHandler(AddressOf ValidationEvent)

AddHandler ValidatingReader.ValidationEventHandler, valdel

' Read XML data
While ValidatingReader.Read()
End While
Finally
If Not ValidatingReader Is Nothing Then
ValidatingReader.Close()
End If
End Try

Return Message Is Nothing

End Function

Public Sub ValidationEvent(ByVal errorid As Object, ByVal args As ValidationEventArgs)
' Missing schema
If (args.Severity = XmlSeverityType.Warning) Then
Message = Message + "No schema found to enforce validation."
Message = Message + vbCrLf
' Not a well formed XML
ElseIf (args.Severity = XmlSeverityType.Error) Then
Message = Message + args.Message
Message = Message + vbCrLf
End If
' XSD schema validation error
If Not (args.Exception Is Nothing) Then
' Message = Message + args.Exception.ToString()
Message = Message + "My guess. Line#: " + CType(args.Exception.LineNumber - 2, String)
Message = Message + vbCrLf
End If
MessageCount += 1
End Sub

Public ReadOnly Property ErrorMessage() As String
Get
Return Message
End Get
End Property

Public WriteOnly Property Schema() As String
Set(ByVal Value As String)
Try
SchemaCollection = New XmlSchemaCollection
Dim Reader As New XmlTextReader(Value)
If SchemaCollection.Add(Nothing, Reader) Is Nothing Then
Throw New Exception("Schema file not loaded")
End If
Reader.Close()
Catch ex As Exception
SchemaCollection = Nothing
Throw ex
End Try
End Set
End Property
Public ReadOnly Property Errors() As Integer
Get
Return Me.MessageCount
End Get
End Property

Private SchemaCollection As XmlSchemaCollection

Private Message As String = Nothing
Private MessageCount As Integer = 0
End Class
---------------------------------------------------------------------------
If not, you can try messing with the IO streams to make them direct memory strings loaded into streams.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 08-02-2007, 07:04 AM
hoser2001's Avatar   
hoser2001 hoser2001 is offline
Programmer
 
Join Date: Jul 2006
Posts: 175
Credits: 0
Rep Power: 10
hoser2001 is on a distinguished road
Default

thank you
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 08-02-2007, 08:38 AM
OthelloNYC OthelloNYC is offline
Newbie
 
Join Date: Jul 2007
Posts: 15
Credits: 0
Rep Power: 5
OthelloNYC is on a distinguished road
Default

No problem. Let me know how much you had to adapt that!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 08-03-2007, 10:08 AM
hoser2001's Avatar   
hoser2001 hoser2001 is offline
Programmer
 
Join Date: Jul 2006
Posts: 175
Credits: 0
Rep Power: 10
hoser2001 is on a distinguished road
Default

I already have something simliar that uses file paths so between all the references I have, I'm sure I'll come up with something.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Two ASP.NET application in one virtual folder pepe123 C# Programming 0 07-12-2007 05:18 AM
Application Starts Minimized Lop C# Programming 2 05-01-2007 11:55 PM
MS-SQL deadlock and hang the Java application reachpradeep Database & Database Programming 1 03-11-2007 04:20 AM
capture screen shot from an application during run time engr Visual Basic Programming 1 01-29-2007 03:38 PM
Make application skinnable Frantic C# Programming 2 09-28-2006 07:27 AM


All times are GMT -5. The time now is 07:06 PM.

Contest Stats

Xav ........ 1455.48
MeTh0Dz|Reb0rn ........ 1089.45
WingedPanther ........ 977.76
marwex89 ........ 962.9
morefood2001 ........ 911.18
John ........ 910.37
Brandon W ........ 822.79
chili5 ........ 312.39
Steve.L ........ 276.28
dcs ........ 253.49

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 84%

Ads