473,473 Members | 1,918 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Custom error code when XSD validation fails?

Hi,

Is there any way to tell an XSD Schema that you want custom error
codes for particular validation failures in an XML document?

To show what I mean, here's an example:

XSD excerpt:

<xs:element name = "EmployeeID">
<xs:simpleType>
<xs:restriction base = "xs:string" >
<xs:length value = "3"/>
<xs:pattern value = "[0-9]{3}"/>
</xs:restriction>
</xs:simpleType>
</xs:element>

XML excerpt:

<EmployeeID>1234</EmployeeID>

When the XML fails to validate against its XSD element, I want, say,
error code 1000 to be returned from the validator for further parsing
in my C# code - can this be done easily?

(I'm thinking along the lines of having an element like
<xs:customErrorCode = 1000along side each restriction.)

Any help very much appreciated

Artie
Jun 27 '08 #1
1 3117
Artie wrote:
When the XML fails to validate against its XSD element, I want, say,
error code 1000 to be returned from the validator for further parsing
in my C# code - can this be done easily?

(I'm thinking along the lines of having an element like
<xs:customErrorCode = 1000along side each restriction.)

Any help very much appreciated
There is no such element as xs:customErrorCode but the schema language
allows for custom attributes in a different namespace than the schema
namespace (http://www.w3.org/2001/XMLSchema). And there are annotations
allowed (http://www.w3.org/TR/xmlschema-1/#cAnnotations) so that a
schema can have additional information, both for human readers and for
automated processing. The schema object model (SOM) in the .NET
framework allows you to access the attributes
(http://msdn2.microsoft.com/en-us/lib...ttributes.aspx)
and the annotations
(http://msdn2.microsoft.com/en-us/lib...nnotation.aspx)

So you can put such information into your schema(s) and then extract
them when processing the schema.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jun 27 '08 #2

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

Similar topics

2
by: Pham Nguyen | last post by:
Has anyone seen an example of a textbox server control that has built-in client-side validation? I'd like to build a server control that extends the System.Web.UI.WebControls.TextBox class to allow...
8
by: pmud | last post by:
Hi, I am using a compare validator in asp.net application(c# code). This Custom validator is used for comparing a value enterd by the user against the primary key in the SQL database. IF the...
5
by: | last post by:
Hi all, Has anyone been able to write some custom javascript on the onclick event of submit button to do certain things like disable submit button, only submit form once etc. This was a breeze...
3
by: matko | last post by:
This is a long one, so I'll summarize: 1. What are your opinions on raising an exception within the constructor of a (custom) exception? 2. How do -you- validate arguments in your own...
8
by: Radu | last post by:
Hi. I have an ASP control on my page: <asp:Calendar ID="calStart" ................ Etc </asp:Calendar> and I have a Custom Validator defined as <asp:CustomValidator
1
by: Artie | last post by:
Hi, Is there any way to tell an XSD Schema that you want custom error codes for particular validation failures in an XML document? To show what I mean, here's an example: XSD excerpt ...
0
by: Artie | last post by:
On Apr 21, 11:48 am, Martin Honnen <mahotr...@yahoo.dewrote: Thanks for your reply Martin. I was hoping for something generic rather than validator-specific, but I'll try in a Microsoft group...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
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
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,...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.