Click here to Skip to main content
15,914,419 members
Home / Discussions / C#
   

C#

 
GeneralRe: c#: Problems with accessing struct field members Pin
brexail23-Apr-08 0:30
brexail23-Apr-08 0:30 
GeneralRe: c#: Problems with accessing struct field members Pin
CPallini23-Apr-08 0:44
mveCPallini23-Apr-08 0:44 
GeneralRe: c#: Problems with accessing struct field members Pin
brexail23-Apr-08 2:47
brexail23-Apr-08 2:47 
QuestionPopulating Tree View.. Recursion?? Pin
Muammar©22-Apr-08 23:34
Muammar©22-Apr-08 23:34 
GeneralRe: Populating Tree View.. Recursion?? Pin
Muammar©22-Apr-08 23:46
Muammar©22-Apr-08 23:46 
GeneralOpen a database--Please disregard the question-i found the answer--Sorry for the trouble Pin
new2pgrmg22-Apr-08 23:31
new2pgrmg22-Apr-08 23:31 
GeneralRe: Open a database--Please disregard the question-i found the answer--Sorry for the trouble Pin
Thomas Stockwell23-Apr-08 8:20
professionalThomas Stockwell23-Apr-08 8:20 
Questionvalidate xml string against XSD Pin
anto200522-Apr-08 22:33
anto200522-Apr-08 22:33 
Hi ,
I create a xml string using a xmldocument (c# 2.0 )
This is my code (more or less)

XmlElement MySearchNode = xmlDoc.CreateElement("MySearch");
xmlDoc.AppendChild(MySearchNode);
...
XmlNode node1 = xmlDoc.SelectSingleNode("/MySearch/Objects");
XmlAttribute nameAttrib = xmlDoc.CreateAttribute("result");
nameAttrib.Value = "012";
node1.Attributes.Append(nameAttrib);
xmlDoc.outerxml

I want to validate the xml string against a XSD :
XmlReader rdr = null;
XmlParserContext context = new XmlParserContext(null, null, "", XmlSpace.None);
XmlTextReader readerXml = new XmlTextReader(p_xml, XmlNodeType.Element, context);
XmlTextReader readerSchema = new XmlTextReader(p_xsdPath);
XmlSchema schema = new XmlSchema();
schema = XmlSchema.Read(readerSchema, new

ValidationEventHandler(Schema_ValidationEventHandler));
XmlReaderSettings ReaderSettings = new XmlReaderSettings();
ReaderSettings.ValidationType = ValidationType.Schema;
ReaderSettings.Schemas.Add(schema);
ReaderSettings.ConformanceLevel = ConformanceLevel.Fragment;
ReaderSettings.ValidationEventHandler += new

ValidationEventHandler(settings_ValidationEventHandler);
rdr = XmlReader.Create(readerXml, ReaderSettings);

this is my XSD
(a part of it)
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="MySearch">
<xs:complexType>
<xs:sequence>
<xs:element name="Objects" type="tObjects" minOccurs="0" maxOccurs="1" />
</xs:sequence>
<xs:attribute name="result" type="xs:string" />
</xs:complexType>
</xs:element>
<xs:complexType name="tObjects">
<xs:sequence>
<xs:element name="House" type="tHouse" minOccurs="0" maxOccurs="unbounded">
</xs:element>
<xs:element name="Garden" type="tGarden" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
....

Note : this is my xml string
<MySearch>
<Objects result = '012' >
<House>
...
</House>
</Objects>
</MySearch>

when I validate I get this error :
The 'result' attribute is not declared.

I see that validation process need :

ReaderSettings.ValidationFlags = XmlSchemaValidationFlags.AllowXmlAttributes;

and

attributeFormDefault="unqualified" .

It doesn't work !! Confused | :confused: I always get the same error ..


Could you help me ? thanks in advance .
QuestionHow to Retun the multiple validation expression in single Regular Expression. Pin
bruze22-Apr-08 22:10
bruze22-Apr-08 22:10 
QuestionIs the .NET framework free? Pin
ptr2void22-Apr-08 21:22
ptr2void22-Apr-08 21:22 
AnswerRe: Is the .NET framework free? Pin
Ashfield22-Apr-08 21:44
Ashfield22-Apr-08 21:44 
GeneralRe: Is the .NET framework free? Pin
Christian Graus22-Apr-08 21:46
protectorChristian Graus22-Apr-08 21:46 
GeneralRe: Is the .NET framework free? Pin
ptr2void22-Apr-08 22:08
ptr2void22-Apr-08 22:08 
GeneralRe: Is the .NET framework free? Pin
Christian Graus22-Apr-08 22:10
protectorChristian Graus22-Apr-08 22:10 
GeneralRe: Is the .NET framework free? Pin
ptr2void22-Apr-08 22:20
ptr2void22-Apr-08 22:20 
GeneralRe: Is the .NET framework free? Pin
CPallini22-Apr-08 22:30
mveCPallini22-Apr-08 22:30 
GeneralRe: Is the .NET framework free? Pin
Reelix23-Apr-08 1:27
Reelix23-Apr-08 1:27 
GeneralRe: Is the .NET framework free? Pin
CPallini23-Apr-08 1:43
mveCPallini23-Apr-08 1:43 
GeneralRe: Is the .NET framework free? Pin
Reelix23-Apr-08 1:56
Reelix23-Apr-08 1:56 
QuestionRe: Is the .NET framework free? Pin
CPallini23-Apr-08 1:58
mveCPallini23-Apr-08 1:58 
GeneralRe: Is the .NET framework free? Pin
Zoltan Balazs22-Apr-08 22:31
Zoltan Balazs22-Apr-08 22:31 
GeneralRe: Is the .NET framework free? Pin
Reelix22-Apr-08 22:13
Reelix22-Apr-08 22:13 
GeneralWaitOne exitContext Pin
George_George22-Apr-08 20:55
George_George22-Apr-08 20:55 
GeneralRe: WaitOne exitContext Pin
Urs Enzler22-Apr-08 22:30
Urs Enzler22-Apr-08 22:30 
GeneralRe: WaitOne exitContext Pin
George_George23-Apr-08 0:01
George_George23-Apr-08 0:01 

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.