Click here to Skip to main content
15,889,527 members
Home / Discussions / C#
   

C#

 
AnswerRe: How do you check to see if a web service is running or not? Pin
Dave Kreskowiak1-Oct-09 11:14
mveDave Kreskowiak1-Oct-09 11:14 
AnswerRe: How do you check to see if a web service is running or not? Pin
PIEBALDconsult1-Oct-09 14:55
mvePIEBALDconsult1-Oct-09 14:55 
GeneralRe: How do you check to see if a web service is running or not? Pin
Dave Kreskowiak1-Oct-09 16:23
mveDave Kreskowiak1-Oct-09 16:23 
GeneralRe: How do you check to see if a web service is running or not? Pin
PIEBALDconsult2-Oct-09 3:42
mvePIEBALDconsult2-Oct-09 3:42 
QuestionException while creating table in azure. Pin
VasntKrish1-Oct-09 9:23
VasntKrish1-Oct-09 9:23 
QuestionXML, XSD VALIDATION Pin
waqasm1-Oct-09 8:16
waqasm1-Oct-09 8:16 
AnswerRe: XML, XSD VALIDATION Pin
Henry Minute1-Oct-09 10:50
Henry Minute1-Oct-09 10:50 
GeneralRe: XML, XSD VALIDATION Pin
waqasm1-Oct-09 11:09
waqasm1-Oct-09 11:09 
Thanks Mr Minute for your response. I will keep that in mind for sure.

So i tried debugging my code, and I notice that the code does not go anywhere once I click on the validate button. Meaning it does not go to the validate function. It shows me error as follows "Illegal character paths"
I think the problem is with this function paramters "ValidateXML(strXML, strXSD, "urn:bookstore-schema");"


using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Xml;
using System.Xml.Schema;

//void ValidateXML(string strXML,string strXSD,string strXSDNS)
namespace ValidateXML
{
      
    public partial class Form1 : Form
    
      {
         
        public Form1()
        {
        InitializeComponent();
        }
                
       string strXML; //- In put XML file
       string strXSD; //- In put XSD file
       string strXSDNS;

        void ValidateXML(string strXML, string strXSD, string strXSDNS)
        {
            
            //Create a XmlValidatingReader, XmlSchemaCollection and ValidationEventHandler objects to be used to validate the XML against an XSD file
           //XmlValidatingReader r = XmlValidatingReader.Create;
            
            XmlValidatingReader reader = null;
            XmlSchemaCollection myschema = new XmlSchemaCollection();
            //ValidationEventHandler eventHandler = new ValidationEventHandler(ShowCompileErrors);
            //string strXML = null;
            //string strXSD = null;
            
            try
            {
                //Create the XML fragment to be parsed.
                //strXML = "C:/Umar/1234_H1N1_00002.xml";
                //doc.Load("C:/Umar/1234_H1N1_00002.xml");

                StreamReader streamReader = new StreamReader("C:/Umar/1234_H1N1_00002.xml");
                strXML = streamReader.ReadToEnd();
                streamReader.Close();

                StreamReader streamReader1 = new StreamReader("C:/Umar/H1N1_Schema.xsd");
                strXSD = streamReader1.ReadToEnd();
                streamReader.Close();
                                                  
                XmlDocument doc = new XmlDocument();
                doc.Load(strXML);
                string xmlFrag = doc.InnerXml;
                           
                //Create an XmlParserContext object for use with the XMLValidatingReader:
                //String xmlFrag = "<author  xmlns='urn:bookstore-schema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" +
                // "<first-name>Herman</first-name>" +
                // "<last-name>Melville</last-name>" +
                //"</author>";
                //Create the XmlParserContext.
              
                XmlParserContext context = new XmlParserContext(null, null, "", XmlSpace.None);

                //Implement the reader. 
                reader = new XmlValidatingReader(xmlFrag, XmlNodeType.Element, context);

                // Add the relevant schema files (.XSD) to the name space we are checking
                //against and repeat until all the schema's have an associated XSD file with them.

                //Add the schema.
                myschema.Add(strXSD, strXSD);

                //Set the schema type and add the schema to the reader.
                reader.ValidationType = ValidationType.Schema;
                reader.Schemas.Add(myschema);
                // Read in the XML Data:
                
                while (reader.Read())
                {

                }
               
              //If there is no exception, display "Completed Validating" or return a value indicating success

                output.Text = "Completed validating " + strXML;
                
            }
            //Watch out for exceptions within the XML file and display them appropriately to the user:

            catch (XmlException XmlExp)
            {
                output.Text = "XMLException " + XmlExp.Message;
            }

           //XMLSchemaExceptions are thrown when the XML document does not match the schema provided.

            catch (XmlSchemaException XmlSchExp)
            {
                output.Text = "XMLSchemaException " + XmlSchExp.Message;
            }

            //Catch all other exceptions and report them to the user:

            catch (Exception GenExp)
           {
                output.Text = "Exception " + GenExp.Message;
           }
      }
          
       private void btn_Validate_Click(object sender, EventArgs e)
        {
            String a = null;
            String b = null; 
            if (txt_inputXML.Text == String.Empty)
            {
                output.Text = ("Warning: Upload a XML file");
            }
            else if (txt_inputXSD.Text == String.Empty)
            {
                output.Text = ("Warning: Upload a XSD File");
            }
            
            else
            {
                output.Text = "yoo";
                ValidateXML(strXML, strXSD, "urn:bookstore-schema");
                
               
            }
        }

     private void btn_BrowseXML_Click(object sender, EventArgs e)
        {
            //outputtext.Text = "";
            // Create an OpenFileDialog object.
            OpenFileDialog openFile1 = new OpenFileDialog();
            // Initialize the OpenFileDialog to look for text files.
            openFile1.Filter = "(*.xml)|*.xml";

          if (openFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                txt_inputXML.Text = openFile1.FileName;
            }
        }

        private void btn_BrowseXSD_Click(object sender, EventArgs e)
        {
            //outputtext.Text = "";
            // Create an OpenFileDialog object.
            OpenFileDialog openFile1 = new OpenFileDialog();

            // Initialize the OpenFileDialog to look for text files.
            openFile1.Filter = "(*.xsd)|*.xsd";

            if (openFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK)

                txt_inputXSD.Text = openFile1.FileName;
        }    
    }
}

GeneralRe: XML, XSD VALIDATION Pin
Henry Minute1-Oct-09 11:48
Henry Minute1-Oct-09 11:48 
GeneralRe: XML, XSD VALIDATION Pin
waqasm2-Oct-09 3:56
waqasm2-Oct-09 3:56 
GeneralRe: XML, XSD VALIDATION Pin
Henry Minute2-Oct-09 5:29
Henry Minute2-Oct-09 5:29 
GeneralRe: XML, XSD VALIDATION Pin
waqasm7-Oct-09 6:14
waqasm7-Oct-09 6:14 
QuestionSqlServerCeException "There was an error parsing the query" help .... Pin
hande541-Oct-09 6:22
hande541-Oct-09 6:22 
AnswerRe: SqlServerCeException "There was an error parsing the query" help .... Pin
Md. Marufuzzaman1-Oct-09 7:07
professionalMd. Marufuzzaman1-Oct-09 7:07 
GeneralRe: SqlServerCeException "There was an error parsing the query" help .... Pin
hande541-Oct-09 7:57
hande541-Oct-09 7:57 
GeneralRe: SqlServerCeException "There was an error parsing the query" help .... Pin
Md. Marufuzzaman1-Oct-09 8:29
professionalMd. Marufuzzaman1-Oct-09 8:29 
GeneralRe: SqlServerCeException "There was an error parsing the query" help .... Pin
hande541-Oct-09 8:50
hande541-Oct-09 8:50 
GeneralRe: SqlServerCeException "There was an error parsing the query" help .... Pin
Abhishek Sur1-Oct-09 10:31
professionalAbhishek Sur1-Oct-09 10:31 
GeneralRe: SqlServerCeException "There was an error parsing the query" help .... Pin
hande541-Oct-09 10:33
hande541-Oct-09 10:33 
GeneralRe: SqlServerCeException "There was an error parsing the query" help .... Pin
Md. Marufuzzaman1-Oct-09 20:15
professionalMd. Marufuzzaman1-Oct-09 20:15 
Questionsocket problem: works in visual studio, not as release Pin
TimWallace1-Oct-09 5:49
TimWallace1-Oct-09 5:49 
AnswerRe: socket problem: works in visual studio, not as release Pin
Luc Pattyn1-Oct-09 6:22
sitebuilderLuc Pattyn1-Oct-09 6:22 
GeneralRe: socket problem: works in visual studio, not as release Pin
TimWallace1-Oct-09 6:56
TimWallace1-Oct-09 6:56 
GeneralRe: socket problem: works in visual studio, not as release Pin
Luc Pattyn1-Oct-09 7:09
sitebuilderLuc Pattyn1-Oct-09 7:09 
General[SOLVED] Re: socket problem: works in visual studio, not as release Pin
TimWallace1-Oct-09 8:34
TimWallace1-Oct-09 8:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.