Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reading xmlschema file

 
James Peter
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21298
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20605
60
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to our XML forum.
 
Paul Clapham
Sheriff
Posts: 21298
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic