wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes What tools should I start looking at? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "What tools should I start looking at?" Watch "What tools should I start looking at?" New topic
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
    
    5
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
    
    5
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What tools should I start looking at?
 
Similar Threads
Struts 1.1 Validator Vs Business Rules Validation
Upload multiple xml files
To study XML and Java
How to start and stop websphere instance from command prompt
NX: Graphical server mode UrlyBird