Results 1 to 2 of 2
Thread: Data Validation help
- 01-28-2012, 04:06 PM #1
Member
- Join Date
- Jan 2012
- Posts
- 2
- Rep Power
- 0
Data Validation help
Hello everyone,
Can anyone please suggest me with some examples of how to validate data on the server side. I tried out the Javascript and looked at some regex methods. The regex methods actually use methods from the class Pattern. I cannot find examples that use the Validator class. I was told to read the Javadocs but I am not able to understand how those methods work.
So I would appreciate if anyone could provide me with links to examples for validation at the server site.
- 01-28-2012, 04:25 PM #2
Re: Data Validation help
Javascript would be something you'd use on the client side.
The Validator class is for validating XML against a Schema. Here's an excerpt from a program I'm working on right now. In this snippet, doc is a Document that was passed into the method. XMLInput is the name of the class in which this code appears.
Java Code:StreamSource source = new StreamSource(XMLInput.class.getResourceAsStream("/schema/Input.xsd")); SchemaFactory sf = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema"); Schema schema = sf.newSchema(source); Validator validator = schema.newValidator(); // make it throw exceptions for all errors validator.setErrorHandler(new ErrorHandler() { @Override public void error(SAXParseException e) throws SAXException { throw e; } @Override public void fatalError(SAXParseException e) throws SAXException { throw e; } @Override public void warning(SAXParseException e) throws SAXException { throw e; } }); validator.validate(new DOMSource(doc));
Last edited by kjkrum; 01-28-2012 at 04:30 PM.
Get in the habit of using standard Java naming conventions!
Similar Threads
-
data type validation
By cagipple in forum New To JavaReplies: 2Last Post: 12-14-2011, 07:57 AM -
XML Validation
By sehudson in forum XMLReplies: 5Last Post: 03-21-2011, 12:38 PM -
Tokenizer with data validation for missing text
By dug in forum New To JavaReplies: 4Last Post: 01-29-2011, 11:18 PM -
Connection to SQL Server and Data Validation
By hisouka in forum JDBCReplies: 0Last Post: 09-01-2008, 11:57 AM
Bookmarks