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

C#

 
QuestionListBox SelectedItem Pin
Illegal Operation9-May-10 15:08
Illegal Operation9-May-10 15:08 
AnswerRe: ListBox SelectedItem Pin
Paramhans Dubey9-May-10 19:14
professionalParamhans Dubey9-May-10 19:14 
QuestionMessage Removed Pin
9-May-10 11:05
mrkeivan9-May-10 11:05 
AnswerRe: Opening and printing PDF Pin
Not Active9-May-10 13:56
mentorNot Active9-May-10 13:56 
GeneralRe: Opening and printing PDF Pin
mrkeivan9-May-10 19:45
mrkeivan9-May-10 19:45 
GeneralRe: Opening and printing PDF Pin
Not Active10-May-10 1:51
mentorNot Active10-May-10 1:51 
GeneralRe: Opening and printing PDF Pin
Luc Pattyn10-May-10 2:47
sitebuilderLuc Pattyn10-May-10 2:47 
QuestionReading Xml files based on Xsd schema Pin
WebMaster9-May-10 8:30
WebMaster9-May-10 8:30 
Hello,

I'm developing an IDE, in which I need my users to write Xml files. Since I'm providing code completion, I need to know what elements and attributes are available to my users depending on what element they are in, based on an Xsd schema.

Currently I am trying to do this with a schema file, an xml file and a XmlReader. The way I was going to do it was to make the XmlReader generate a tree of available elements/attributes based on the given schema file. However, so far my debugging results show me that none of the, IMO, logical properties have the current node's name, child attributes and child elements. Here's my C# code:

using System;
using System.IO;
using System.Xml;
using System.Xml.Schema;
namespace Moonlite.Controls.Xsd {
  public static class XsdReader {
    public static XsdNodeCollection Read(Stream stream, Stream schema) {
      XsdNodeCollection nodes = new XsdNodeCollection();
      XmlReaderSettings settings = new XmlReaderSettings();
      settings.ValidationType = ValidationType.Schema;
      XmlSchemaSet schemas = new XmlSchemaSet();
      settings.Schemas = schemas;
      settings.IgnoreWhitespace = true;
      settings.IgnoreComments = true;
      schemas.Add(null, XmlReader.Create(schema));
      XmlReader reader = XmlReader.Create(stream, settings);
      try {
        while (reader.Read()) {
          string currentNode = reader.Value;
        }
      }
      finally {
        reader.Close();
        stream.Close();
        schema.Close();
      }

      return nodes;
    }

    public static XsdNodeCollection Read(string filename, Stream schema) {
      return Read(File.Open(filename, FileMode.Open), schema);
    }
  }
}


reader.Value has so far only returned values such as the generic Xml header ("<? xml... ?>"), "" and "\n".
Please bear with me, as this is the first time I am working with data validation.

Thanks,

Theo
QuestionDatabase Question Pin
matris20109-May-10 6:03
matris20109-May-10 6:03 
AnswerRe: Database Question Pin
OriginalGriff9-May-10 6:10
mveOriginalGriff9-May-10 6:10 
Questionbinary database Pin
Jassim Rahma9-May-10 5:02
Jassim Rahma9-May-10 5:02 
AnswerRe: binary database Pin
OriginalGriff9-May-10 5:53
mveOriginalGriff9-May-10 5:53 
GeneralRe: binary database Pin
harold aptroot9-May-10 6:09
harold aptroot9-May-10 6:09 
AnswerRe: binary database Pin
Alex Manolescu9-May-10 9:11
Alex Manolescu9-May-10 9:11 
Questionhow to insert a new line in a table of a .sdf file smart device application Pin
bacem smari9-May-10 4:47
bacem smari9-May-10 4:47 
AnswerRe: how to insert a new line in a table of a .sdf file smart device application Pin
Stanciu Vlad9-May-10 9:13
Stanciu Vlad9-May-10 9:13 
GeneralRe: how to insert a new line in a table of a .sdf file smart device application Pin
bacem smari9-May-10 20:26
bacem smari9-May-10 20:26 
GeneralRe: how to insert a new line in a table of a .sdf file smart device application Pin
Stanciu Vlad9-May-10 20:28
Stanciu Vlad9-May-10 20:28 
GeneralRe: how to insert a new line in a table of a .sdf file smart device application Pin
bacem smari9-May-10 21:06
bacem smari9-May-10 21:06 
GeneralRe: how to insert a new line in a table of a .sdf file smart device application Pin
Stanciu Vlad9-May-10 21:25
Stanciu Vlad9-May-10 21:25 
GeneralRe: how to insert a new line in a table of a .sdf file smart device application Pin
bacem smari9-May-10 21:37
bacem smari9-May-10 21:37 
GeneralRe: how to insert a new line in a table of a .sdf file smart device application Pin
Stanciu Vlad9-May-10 21:57
Stanciu Vlad9-May-10 21:57 
GeneralRe: how to insert a new line in a table of a .sdf file smart device application Pin
bacem smari9-May-10 22:15
bacem smari9-May-10 22:15 
GeneralRe: how to insert a new line in a table of a .sdf file smart device application Pin
Stanciu Vlad9-May-10 22:23
Stanciu Vlad9-May-10 22:23 
GeneralRe: how to insert a new line in a table of a .sdf file smart device application Pin
bacem smari9-May-10 22:31
bacem smari9-May-10 22:31 

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.