Win a copy of Design for the Mind this week in the Design forum!
    Bookmark Topic Watch Topic
  • New Topic

Validating String aginst schema directly

 
James Peter
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 118
  • Mark post as helpful
  • send pies
  • Report post to moderator
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.
 
Rob Spoor
Sheriff
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Report post to moderator
DocumentBuilderFactory and SAXParserFactory have one method you will be interested in: setSchema. You can create a Schema using SchemaFactory.

Moving to XML.
 
Paul Clapham
Sheriff
Pie
Posts: 20955
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
    Bookmark Topic Watch Topic
  • New Topic