Validate using one element of XSD in java
Is there any w开发者_如何学Pythonay to use an xsd file to validate input of a string?
I have found some examples of xsd being used to validate an xml file, but what I really want is to just use one element of the xsd to validate some user input.
Is there a simple way to do this or should I just treat the xsd file as an xml file, extract the element and compare it to the given string to see if it's valid?
Thanks
If I'm understanding your question correctly, you typically use jaxb along with an xsd(schema) to validate an xml file not the contents of a node in an xml file. You may be better off using xpath to parse the xml file and get the contents of the particular node and then do your comparison that way. Here is a link to one of the jaxb tutorials and a linkt to an XPATH tutorial.
精彩评论