473,395 Members | 1,464 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,395 software developers and data experts.

How do I enforce a xsd?

Hi!

My users shall be able to upload xml documents to my web server.
I will check the validity of the documents with my xsd schema.
The document will contain something like:

<project>
<project-item />
</project>

1- How do they specify in the xml document that they are using my schema
with no namespace prefix?
2- When checking the validity, how do I make sure that they have specified
my schema in their document?
3- If they haven't specified my schema in their xml, how do I tell the
XmlReader that my schema shall be used on the namespace with no prefix?

thanks,
mortb
Jan 30 '07 #1
1 1758
mortb wrote:
My users shall be able to upload xml documents to my web server.
I will check the validity of the documents with my xsd schema.
The document will contain something like:

<project>
<project-item />
</project>

1- How do they specify in the xml document that they are using my schema
with no namespace prefix?
2- When checking the validity, how do I make sure that they have specified
my schema in their document?
3- If they haven't specified my schema in their xml, how do I tell the
XmlReader that my schema shall be used on the namespace with no prefix?
With .NET 2.0 to do validation you use e.g.
XmlReaderSettings readerSettings = new XmlReaderSettings();
readerSettings.ValidationType = ValidationType.Schema;
readerSettings.Schemas.Add(null, "schema.xsd");
readerSettings.ValidationEventHandler += new
ValidationEventHandler(YourHandler);

using (XmlReader xmlReader = XmlReader.Create(@"file.xml",
readerSettings)
{
// now pull in node and check events in your
// ValidationEventHandler
while (xmlReader.Read()) {}
}

If you want the reader to use the
schemaLocation/noNamespaceSchemaLocation attribute(s) then you do not
need to add the schema yourself, rather you need to set a validation
flag to use schema location attributes.

If you want to first check whether the document refers to your schema
then you might want to start reading it and look at validation warnings
whether a schema has been found.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jan 30 '07 #2

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

Similar topics

6
by: aa | last post by:
Is it possible to enforce changed in php.ini without re-booting (w2k)?
0
by: Dave | last post by:
Hi, I just want to share what I have found today. In the online article "Enforce Constness With C#" by Bill Wagner for "Visual Studio Magazine", he explaines how to make a little workaround to...
1
by: Bryan Harrington | last post by:
Hello all, I have a requirement to enforce strong passwords from a customer, and I can only assume they won't be the last to ask for it. Does anyone have any pointers for handling complex...
7
by: gino | last post by:
Dear all, My monitor was set to 1600x1200 so the fonts in IE is too small for me even when I set the "View->Text Size->Largest"... I don't have previlage to change the monitor resolution... ...
0
by: Sreepathi Rao | last post by:
I created a typedDataset from the XML designer, and set relation to the tables. When I enforce the relation to teh dataset it is not enforcing the same. Can anyone tell me what is wrong with the...
9
by: obhayes | last post by:
Hi, I have two tables Table A and B, below with some dummy data... Table A (contains specific unique settings that can be requested) Id, SettingName 1, weight 2, length Table B (contains...
2
by: noone | last post by:
A typical inventory management system would have people linked to items that link to other items. However in what I'm trying to do, PCs are one of the inventory items. One PC can be linked to...
1
by: shumaker | last post by:
....please. I've found other posts that explain the Cascade options, but the Enforce relationships option still is foggy to me. As to "enforcing relationship for ... UPDATEs"(with cascade NOT...
23
by: Ken Turkowski | last post by:
The construct (void*)(((long)ptr + 3) & ~3) worked well until now to enforce alignment of the pointer to long boundaries. However, now VC++ warns about it, undoubtedly to help things work on 64...
14
by: Sacha Schär | last post by:
Hi there, i have a sequence like the following: const char *a = "foo"; char b; for ( i = 1; i < strlen(a); i++) { b = a;
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.