| Author |
What tools should I start looking at?
|
Tony Brown
Greenhorn
Joined: Jan 02, 2004
Posts: 6
|
|
Hi all, I'm starting a project where I have to create a Java application that outputs XML data. I want to have a check button where the user can check the validity of their input against an existing XML Schema. So if they forget to put a value into a mandatory field, the application will tell them what's missing and won't let them output the data into XML until it is valid. Also, I want them to be able to load an XML file into the application so that the fields are filled automatically if the file is valid. Can someone tell me which APIs I need and where I should start looking/reading? Thanks, Tony Brown
|
 |
Lasse Koskela
author
Sheriff
Joined: Jan 23, 2002
Posts: 11962
|
|
|
You should do a search on this forum for "schema validation" or something similar. You'll find that it is rather simple to validate a document against a given XML schema. However, I am unable to advice you regarding your "fill in the blanks" requirement (the only way I can think of is to write a lot of code to check for fields one at a time, manually)...
|
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
|
 |
steve souza
Ranch Hand
Joined: Jun 26, 2002
Posts: 852
|
|
For generating XML from databases check out the OpenSource FormattedDataSet API (http://www.fdsapi.com). It can also be used to collect Form data and put it into XML format. Sample code to do this follows:
|
http://www.jamonapi.com/ - a fast, free open source performance tuning api.
JavaRanch Performance FAQ
|
 |
steve souza
Ranch Hand
Joined: Jun 26, 2002
Posts: 852
|
|
see the following link for a demo app of converting HTML form request parameters to XML. http://ssouza.kgbinternet.com/fdsapi/basicdemo.jsp
|
 |
Tony Brown
Greenhorn
Joined: Jan 02, 2004
Posts: 6
|
|
Everything I'm seeing seems to show validation by command line against an existing xml file. I would like to validate dynamically against xml data in memory (such as in a DOM tree) before I write it out to a file. Is this possible?
|
 |
Lasse Koskela
author
Sheriff
Joined: Jan 23, 2002
Posts: 11962
|
|
There's always a couple of alternative parsing methods -- if the example uses a File or a FileInputStream to create a Source, you can most certainly construct the Source from in-memory data structures. Browse the java.io.* javadocs. There's an example of schema validation using Xerces in our JavaRanch Wiki. If you happen to use a recent enough version of JAXP, you can rely on its implementation-agnostic schema validation features. See here and here for details.
|
 |
 |
|
|
subject: What tools should I start looking at?
|
|
|