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

XML validation of single value without entire XML document

Hi all,

Does anyone know if it is possible, and if so how, to perform validation of
a simple non XML string against certain XSD restrictions, without having the
entire XML document to validate against the schema.
To elaborate -
- Within XSD certain restrictions are defined for a particular
element/attribute, such as datatype, minlength, maxlength, valid enumeration
values etc.
Is it at all possible to validate a simple string value against these
restrictions defined within the schema.
I.e. I do not have the entire XML document that matches the schema. I do not
even have any XML at all - I simply have a string value which represents one
of the elements' values in the schema. I would like to utilise the power of
XSD to validate the value, rather than writing my own code to check the
datatype, length, allowed values etc.

Any suggestions appreciated!

Thanks,

Bardo
Nov 29 '06 #1
2 2035
Bardo wrote:
Does anyone know if it is possible, and if so how, to perform validation of
a simple non XML string against certain XSD restrictions, without having the
entire XML document to validate against the schema.
To elaborate -
- Within XSD certain restrictions are defined for a particular
element/attribute, such as datatype, minlength, maxlength, valid enumeration
values etc.
Is it at all possible to validate a simple string value against these
restrictions defined within the schema.
I.e. I do not have the entire XML document that matches the schema. I do not
even have any XML at all - I simply have a string value which represents one
of the elements' values in the schema. I would like to utilise the power of
XSD to validate the value, rather than writing my own code to check the
datatype, length, allowed values etc.
With .NET 2.0 and later the XmlDocument has a method called Validate
where you can pass in a single node to be validated. So you will at
least to create e.g. an element node and pass that to the validate method.

Then, also in .NET 2.0 and later, there is the XmlSchemaValidator class
that has method likes ValidateAttribute, ValidateElement, ValidateText
that allows you to validate certain components.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Nov 29 '06 #2
Thanks Martin, the XmlSchemaValidator looks like what I'm after!

"Martin Honnen" <ma*******@yahoo.dewrote in message
news:u%***************@TK2MSFTNGP02.phx.gbl...
Bardo wrote:
>Does anyone know if it is possible, and if so how, to perform validation
of
a simple non XML string against certain XSD restrictions, without having
the
entire XML document to validate against the schema.
To elaborate -
- Within XSD certain restrictions are defined for a particular
element/attribute, such as datatype, minlength, maxlength, valid
enumeration
values etc.
Is it at all possible to validate a simple string value against these
restrictions defined within the schema.
I.e. I do not have the entire XML document that matches the schema. I do
not
even have any XML at all - I simply have a string value which represents
one
of the elements' values in the schema. I would like to utilise the power
of
XSD to validate the value, rather than writing my own code to check the
datatype, length, allowed values etc.

With .NET 2.0 and later the XmlDocument has a method called Validate where
you can pass in a single node to be validated. So you will at least to
create e.g. an element node and pass that to the validate method.

Then, also in .NET 2.0 and later, there is the XmlSchemaValidator class
that has method likes ValidateAttribute, ValidateElement, ValidateText
that allows you to validate certain components.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

Nov 30 '06 #3

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

Similar topics

4
by: Mike | last post by:
Related to another topic I just posted, I wanted to discuss ways to optimize the validation of very large (>100MB) XML documents. First, I have no idea if something like this already exists; it...
7
by: Mike | last post by:
I've been trying for the past week to put a simple code together. I have done a LOT of searching, found scripts showing the functions I would like to use, however when I mix them it all goes wrong,...
2
by: Axel Foley | last post by:
Hi Folks, i'm newbie at JS; but "learning by tweaking" is my middle name! Trying to set up a link partnership application on a client's site; got this script at "The Javascript Source", but it...
10
by: dries | last post by:
A friend of mine has a problem with his credit card validation routine and it is probably a simple thing to solve but I cannot find it. It has to do with the expiry dates. What happens is that as...
6
by: MickG | last post by:
Hi, I am trying to validate these values, this seems to work fine for the phone number and name but I am trying to get the program to fail to submit and set the focus on the date when 2006 is...
41
by: Gérard Talbot | last post by:
Cross-posted to: comp.infosystems.www.authoring.html and alt.html Followup-to: comp.infosystems.www.authoring.html 1- One day, I stumbled across a website that offers to validate webpages. What...
12
by: Dabbler | last post by:
I need to insure that at least one of three phone number fields has a value (requiredfield) but I'm not sure of a way to implement this without server side logic. Is there a way to use the...
0
by: micksey | last post by:
i have a form linked with access database. code goes like this: <%while not serv.eof %> <tr valign="top"> <td height="30"> <%=serv.fields("serialno") %> </td> <td> <input name="txtSCorCO"...
15
by: MKO | last post by:
Hi guys I'm having a little trouble with form validation, I can get the entire form to validate without problems (i.e. when all fields set to required & valid data is entered) but can't get it 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: 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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...
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
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,...

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.