473,803 Members | 3,159 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ProcessSchemaLo cation 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
XmlReaderSettin gs->Schemas field at runtime does result in error being
thrown. As I read it, this step should not be neccessary as the
ProcessSchemaLo cation 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:

(
"<provenanc e xmlns=\"http://www.openarchive s.org/OAI/
2.0/provenance\"" + "\n" +
"\t" + "xmlns:xsi=\"ht tp://www.w3.org/2001/
XMLSchema-instance\"" + "\n" +
"\t" + "xsi:schemaLoca tion=\"http://
www.openarchive s.org/OAI/2.0/provenance" + "\n" +
"\t" + "http://www.openarchive s.org/OAI/2.0/
provenance.xsd\ ">" + "\n" +
"\t" + "<originDescrip tion harvestDate=
\"2002-02-02T14:10:02Z\" altered=\"true\ ">" + "\n" +
"\t" + "<baseURL>h ttp://the.oa.org</baseURL>" +
"\n" +
"\t" + "<identifier>oa i:r2.org:klik00 1</
identifier>" + "\n" +
"\t" + "<datestamp >I should fail</datestamp>" +
"\n" +
"\t" + "<metadataNames pace>http://
www.openarchive s.org/OAI/2.0/oai_dc/</metadataNamespa ce>" + "\n" +
"\t" + "\t" + "<originDescrip tion harvestDate=
\"2002-01-01T11:10:01Z\" altered=\"false \">" + "\n" +
"\t" + "\t" + "\t" + "<baseURL>h ttp://some.oa.org</
baseURL>" + "\n" +
"\t" + "\t" + "\t" +
"<identifier>oa i:r2.org:klik00 1</identifier>" + "\n" +
"\t" + "\t" + "\t" + "<datestamp>200 1-01-01</
datestamp>" + "\n" +
"\t" + "\t" + "\t" + "<metadataNames pace>http://
www.openarchive s.org/OAI/2.0/oai_dc/</metadataNamespa ce>" + "\n" +
"\t" + "\t" + "</originDescripti on>" + "\n" +
"\t" + "</originDescripti on>" + "\n" +
"\t" + "</provenance>");

Here is XML validation class:

public class XmlValidator
{

public static bool isValid;

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

settings.Valida tionType = ValidationType. Schema;
settings.Valida tionEventHandle r += new
ValidationEvent Handler(validat ionEventHandler );

settings.Valida tionFlags &=
XmlSchemaValida tionFlags.Proce ssSchemaLocatio n;
//settings.Valida tionFlags &=
XmlSchemaValida tionFlags.Proce ssInlineSchema;
settings.Valida tionFlags &=
XmlSchemaValida tionFlags.Repor tValidationWarn ings;

System.IO.Strin gReader strReader = new
System.IO.Strin gReader(inFile) ;
reader = XmlReader.Creat e(strReader, settings);

isValid = true;

while (reader.Read())
{
}

}

static void validationEvent Handler(object sender,
ValidationEvent Args args)
{
isValid = false;
}
}

Thanks in advance for granting peace to my mind.

Jim

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

The offending lines were:

settings.Valida tionFlags &=
XmlSchemaValida tionFlags.Proce ssSchemaLocatio n;
settings.Valida tionFlags &=
XmlSchemaValida tionFlags.Proce ssInlineSchema;
settings.Valida tionFlags &=
XmlSchemaValida tionFlags.Repor tValidationWarn ings;

The fix was to replace those lines with:

settings.Valida tionFlags |=
XmlSchemaValida tionFlags.Proce ssSchemaLocatio n
|
XmlSchemaValida tionFlags.Proce ssInlineSchema
|
XmlSchemaValida tionFlags.Repor tValidationWarn ings;

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
5502
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 file came up in the browser: ---------------- <?php phpinfo(); ?> ----------------
1
1672
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 = Replace(frm_title,"'","''") frm_title = Replace(frm_title,"""", """""") end function I know this topic keeps coming up, I have searched the vbscript newsgroups and can not see where I am going wrong.
2
6282
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 reason..? Situation: I have a menu in my form, which is given a short key "Ctrl+P", now when the
3
3123
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 working week definition. Lets say I have a working week definition of Monday through Friday, 9 am to 5 pm. Date1 = January 1st, 2005 at 8 am
0
1117
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 message is Documents in this folder are not available. The folder may have been moved or deleted, or network problems may be preventing a connection to the server I looked at Microsoft Knowledge Base Article 828897, and that did not seem to apply...
0
1465
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 clicks the submit button - a trip to the server is *not* made when using Internet Explorer. Validation works for the custom control, but only after a trip to the server. Does anyone know why this is the case and if there is a way to force...
0
972
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 other controls are working as expected just the listboxes are doing this. Is this a bug or undocumented behavior and how can it be fixed? Using .Net framework 1.1.
6
31122
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 reason..?
10
10055
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 believe that this has to do with unreleased form component events or event handlers. I'm comparatively new to .net and windows forms, in the sense that though I've been using them for over 2 years now, it's been rather sporadic. I work with...
0
9564
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10546
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10292
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10068
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9121
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5498
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5627
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4275
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2970
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.