473,406 Members | 2,633 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

ProcessSchemaLocation Validation schemaLocation "Not Working"

After two days I am at wits end, but I am too OCD'ed to give up.
Please tell me what I have got wrong because no Validation Error is
being thrown.

The element: "<datestamp>I should fail</datestamp>"
does not conform to schema. Adding the schema to the
XmlReaderSettings->Schemas field at runtime does result in error being
thrown. As I read it, this step should not be neccessary as the
ProcessSchemaLocation flag should automatically pick up the referenced
schemas in the XML file.

Note: the XML file is actually a node that will be inserted to an
existing XML file.

Below is XML file:

(
"<provenance xmlns=\"http://www.openarchives.org/OAI/
2.0/provenance\"" + "\n" +
"\t" + "xmlns:xsi=\"http://www.w3.org/2001/
XMLSchema-instance\"" + "\n" +
"\t" + "xsi:schemaLocation=\"http://
www.openarchives.org/OAI/2.0/provenance" + "\n" +
"\t" + "http://www.openarchives.org/OAI/2.0/
provenance.xsd\">" + "\n" +
"\t" + "<originDescription harvestDate=
\"2002-02-02T14:10:02Z\" altered=\"true\">" + "\n" +
"\t" + "<baseURL>http://the.oa.org</baseURL>" +
"\n" +
"\t" + "<identifier>oai:r2.org:klik001</
identifier>" + "\n" +
"\t" + "<datestamp>I should fail</datestamp>" +
"\n" +
"\t" + "<metadataNamespace>http://
www.openarchives.org/OAI/2.0/oai_dc/</metadataNamespace>" + "\n" +
"\t" + "\t" + "<originDescription harvestDate=
\"2002-01-01T11:10:01Z\" altered=\"false\">" + "\n" +
"\t" + "\t" + "\t" + "<baseURL>http://some.oa.org</
baseURL>" + "\n" +
"\t" + "\t" + "\t" +
"<identifier>oai:r2.org:klik001</identifier>" + "\n" +
"\t" + "\t" + "\t" + "<datestamp>2001-01-01</
datestamp>" + "\n" +
"\t" + "\t" + "\t" + "<metadataNamespace>http://
www.openarchives.org/OAI/2.0/oai_dc/</metadataNamespace>" + "\n" +
"\t" + "\t" + "</originDescription>" + "\n" +
"\t" + "</originDescription>" + "\n" +
"\t" + "</provenance>");

Here is XML validation class:

public class XmlValidator
{

public static bool isValid;

public static void Validate(String inFile)
{
XmlReader reader = null;
XmlReaderSettings settings = new XmlReaderSettings();

settings.ValidationType = ValidationType.Schema;
settings.ValidationEventHandler += new
ValidationEventHandler(validationEventHandler);

settings.ValidationFlags &=
XmlSchemaValidationFlags.ProcessSchemaLocation;
//settings.ValidationFlags &=
XmlSchemaValidationFlags.ProcessInlineSchema;
settings.ValidationFlags &=
XmlSchemaValidationFlags.ReportValidationWarnings;

System.IO.StringReader strReader = new
System.IO.StringReader(inFile);
reader = XmlReader.Create(strReader, settings);

isValid = true;

while (reader.Read())
{
}

}

static void validationEventHandler(object sender,
ValidationEventArgs args)
{
isValid = false;
}
}

Thanks in advance for granting peace to my mind.

Jim

Jul 10 '07 #1
1 3575
Well I get what I deserve for blindly copying code.

The offending lines were:

settings.ValidationFlags &=
XmlSchemaValidationFlags.ProcessSchemaLocation;
settings.ValidationFlags &=
XmlSchemaValidationFlags.ProcessInlineSchema;
settings.ValidationFlags &=
XmlSchemaValidationFlags.ReportValidationWarnings;

The fix was to replace those lines with:

settings.ValidationFlags |=
XmlSchemaValidationFlags.ProcessSchemaLocation
|
XmlSchemaValidationFlags.ProcessInlineSchema
|
XmlSchemaValidationFlags.ReportValidationWarnings;

Anyone with experience with compound assignment operators want to
explain?

Jul 10 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Vik Rubenfeld | last post by:
I'm a newbie to Apache. This week I installed my first Apache 2.0 server, and it's working fine. I then installed PHP. When I ran the PHP test file ("test.php"), the actual text contents of the...
1
by: bronskimac | last post by:
I have a function to cope with " and ' in a form field. The quotes replace works fine but the apostrophe one does not. this is driving me nuts. function clean_text() frm_title =...
2
by: Gary | last post by:
I am trying to use the "System.Windows.Forms.SendKeys" class for triggering the Ctrl+P key. Syntax: System.Windows.Forms.SendKeys.Send("^(P)"); This is not working ..what could be the...
3
by: | last post by:
Hello, I am hoping someone else has thought about a date time calculation i need to perform. I would like to be able to calculate the number of "working minutes" between 2 dates, given my...
0
by: tom777 | last post by:
For some ASP.NET projects, after I have been working on them awhile the "Copy Project..." stops working when I try to copy the project to the web server, which is on another machine. The error...
0
by: Ron | last post by:
I've an aspx page with a custom (composite) server control and a TextBox, both with RequiredFieldValidators. I'd like the custom control to behave the same way the default TextBox does when one...
0
by: ken bus | last post by:
Validation control is bound to a listbox but the "*" is not showing during an error. The text property is set to "*" and the error message is being displayed in the Summary Control. All of the...
6
by: Gary | last post by:
Hi, I am trying to use the "System.Windows.Forms.SendKeys" class for triggering the Ctrl+P key. Syntax: System.Windows.Forms.SendKeys.Send("^(P)") This is not working ..what could be the...
10
by: morangolds | last post by:
Hi, I've been having a problem with C++ Windows Forms apps not "ending" when you close the form window. I've searched about this problem all over the place and most searches have lead me to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.