| Author |
Reading xmlschema file
|
James Peter
Ranch Hand
Joined: Sep 15, 2010
Posts: 114
|
|
Hi All,
My requirement is like this.
1. I need to validate user inputs in a web application. For example user name field.
2. I get user name field restrictions from a xml schema by calling a webservice on the fly.
3. I need to read the schema and validate user input as per the restrictions in xmlschema.
What will be the best approach? I have a plan to accomplish this task. But would like to take experts advice.
Rgds
Peter
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16483
|
|
|
So, you have an XML document and you want to validate it against a schema? Well, if you follow the link XmlFaq you'll see that this is one of the many FAQ's we encounter in our XML forum. Follow the appropriate link from that page.
|
 |
James Peter
Ranch Hand
Joined: Sep 15, 2010
Posts: 114
|
|
Hi,
I want to validate user inputs as per the restrictions in the schema.
My plan is :
1. Call the webservice and get the schema (not going to store this schema physically. it will be in memory)
2. Read xmlschema using jdom and store element restrictions in javabeans.
3. Create Patterns and Matchers as per the restrictions for a particular element.
4. Validate user inputs in webpage using this Matchers.
Rgds
Peter
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
Moving to our XML forum.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16483
|
|
Sorry, I would say that's a bad plan. Don't attempt to replicate the workings of schema validation on your own, especially when you're a beginner. Just use the standard process for validating a document against a schema.
Actually, reading your post carefully it sort of looks like you don't actually have an XML document to validate. If that's the case then why are you using an XML schema, whose whole purpose is to validate an XML document? If you just have a collection of rules which your field inputs have to follow, then I would recommend using one of the validators you get from one of the standard open-source frameworks. Don't drag in a complex beast like XML schema where it doesn't belong.
|
 |
 |
|
|
subject: Reading xmlschema file
|
|
|