Validating xml against xsd c

There is some sample XML data and related schemas below.

I have looked at many posts to see how to use the XML validating reader (Now just XMLReader. The data validates 100% using XML Spy from Altova but not using the XMLReader in C#. The error that occurs trying to find the type String20, which is my first custom data type in my schema.

hi guys I need your suggestions / opinion for doing this the right way. if the Attribute is missing or invalid in the following element then it should say ID attribute invalid for "Watch" Element. "Shailendra Batham" wrote: hi guys I need your suggestions / opinion for doing this the right way. if the Attribute is missing or invalid in the following element then it should say ID attribute invalid for "Watch" Element.

I have a XML and a Schema for the same What I want is when its validated against the schema, it should give custom errors saying what happened and where...... Right now the validation works but the error returning our very vague, I need a way where I can customize the error or at least let the user know where the error is at what element and which attribute. Schema Validation Event Handler Validation Event Args Xml Text Reader xmlreader = new Xml Text Reader("test.xml"); Xml Validating Reader valid = new Xml Validating Reader(xmlreader); valid. I have a XML and a Schema for the same What I want is when its validated against the schema, it should give custom errors saying what happened and where...... Right now the validation works but the error returning our very vague, I need a way where I can customize the error or at least let the user know where the error is at what element and which attribute.

Validation Event Handler = new Validation Event Handler (Validation Handler); System. An error occurred at file:///c:/My Data Set.xsd, (2, 2).

Xml Schema Exception: The attribute target Namespace does not match the designated namespace URI.

I would suggest you try running the SAX2Print sample application in the debugger and see what that code does.

Dave --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] We've tried the above code and it does not validate the XML file. Here is the hacked code: /* initialize xerces system before usig API: DOM, SAX, SAX2 */ try catch (const XMLException &e) /* actual xerces work */ char *xml_file = "D:\Development\Chronicle\Example Schemas and Form Templates\Drill Data_1.xml"; char *xml_schema = "D:\Development\Chronicle\Example Schemas and Form Templates\new Drill Data.xsd"; SAXParser *parser = new SAXParser(); CSax Parser Error Handler error Handler; parser-set Do Namespaces(true); try catch (const XMLException &e) catch(...) delete parser; //delete doc_handler; /* terminate and cleanup */ XMLPlatform Utils:: Terminate(); The XML file purposefully has an extra element which is not allowed by the schema. Here is the quickly knocked together error handler: class CSax Parser Error Handler : public xercesc_3_0:: Error Handler ; void CSax Parser Error Handler::warning(const SAXParse Exception& exc) void CSax Parser Error Handler::error(const SAXParse Exception& exc) void CSax Parser Error Handler::fatal Error(const SAXParse Exception& exc) It looks you didn't read my e-mail; I said "Furthermore, in order to use schema, you should invoke set Do Schema(true) Finally, change the set External Schema Location to be set External No Namespace Schema Location (or, if is using a target Namespace, change the argument of set External Schema Location to be "uri schema.xsd") " Alberto Leif Goodwin ha scritto: These are not valid URLs, because URLS cannot contain the space character, nor the '\' character.

thanks, Shailendra Batham Hi Shailendra, If you are coding in . thanks, Shailendra Batham Thanks for the reply guys.

hey chua I am using C# and I am using the Validation Event Handler, it works fine but this is what error it returns "The 'ID' attribute has an invalid value according to its data type. "Shailendra Batham" wrote: hi guys I need your suggestions / opinion for doing this the right way. if the Attribute is missing or invalid in the following element then it should say ID attribute invalid for "Watch" Element.

Send Validation Event(Xml Schema Exception e, Xml Severity Type severity) at System.

Preprocess(Xml Schema schema, String target Namespace, Compositor compositor, Hashtable processed Schemas) at System.

Leave a Reply