aspose file tools*
The moose likes XML and Related Technologies and the fly likes Validating String aginst schema directly Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply locked New topic
Author

Validating String aginst schema directly

James Peter
Ranch Hand

Joined: Sep 15, 2010
Posts: 115
Hi All,

Is there any way by which I can validate a string against xmlSchema in java?

eg. String is Audi

xmlSchema is
Siddhesh Deodhar
Ranch Hand

Joined: Mar 05, 2009
Posts: 117
There are two commonly used xml parsers in Java namely SAX and Dom.
Get more information on them by doing Google search and use the parser which meets your requirements.


Good, Better, Best, Don't take rest until, Good becomes Better, and Better becomes Best.
Sidd : (SCJP 6 [90%] )
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19697
    
  20

DocumentBuilderFactory and SAXParserFactory have one method you will be interested in: setSchema. You can create a Schema using SchemaFactory.

Moving to XML.


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: 18570
    
    8

You could wrap the string in some text which makes it into an XML document which you can then validate against the schema. But isn't this the same question as in your other post? I'm going to close this one as a duplicate.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Validating String aginst schema directly