File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
XML and Related Technologies
Validating String aginst schema directly
Joined: Sep 15, 2010
Dec 18, 2010 07:17:25
Is there any way by which I can validate a
against xmlSchema in
eg. String is Audi
<xs:element name="car"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="Audi"/> <xs:enumeration value="Golf"/> <xs:enumeration value="BMW"/> </xs:restriction> </xs:simpleType> </xs:element>
Joined: Mar 05, 2009
Dec 18, 2010 08:18:04
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%] )
Joined: Oct 27, 2005
Dec 19, 2010 03:18:36
have one method you will be interested in: setSchema. You can create a Schema using
Moving to XML.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions
How To Answer Questions
Joined: Oct 14, 2005
Dec 19, 2010 11:02:40
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:
subject: Validating String aginst schema directly
how to declare in schema that a tag should have value
XSD element validation
add constraints on two elements in schema - need help..
xsd: how to define an element of type integer which can validate even if it is empty
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015