aspose file tools*
The moose likes XML and Related Technologies and the fly likes Reading xmlschema file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Reading xmlschema file" Watch "Reading xmlschema file" New topic
Author

Reading xmlschema file

James Peter
Ranch Hand

Joined: Sep 15, 2010
Posts: 115
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: 18987
    
    8

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: 115
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: 19784
    
  20

Moving to our XML forum.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reading xmlschema file