aspose file tools*
The moose likes XML and Related Technologies and the fly likes processing xml file in java 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 "processing xml file in java" Watch "processing xml file in java" New topic
Author

processing xml file in java

ved gunjan
Ranch Hand

Joined: May 17, 2003
Posts: 86
Hi! All
I have to process/handle a xml file in my java application.so for this i'm using JAXB API.This is what i have understood uptill now regarding JAXB. JAXB producing the Java files from the XML schema and then unmarshalling xml data into java object.In the unmarshalling process you begin with a valid XML file and convert it to Java objects that are instances of the classes that were created by the JAXB schema compiler.so on the whole You will perform two basic activities when working with a data binding solution. You will compile the schema into Java source files that contain interfaces and classes. You will then use these generated classes along with the APIs provided for handling generated files.
Java files are then created by giving the following command

java -jar [JAXB_LIB]\ abc.xsd .Suppose it generates the corrosponding java files in the folder structure
c:\MyPackage\*.java

Now to unmarshal XML content into a content tree of data objects, you first create a JAXBContext instance for handling schema-derived classes, then create an Unmarshaller instance, and then finally unmarshal the XML content. For example, if the generated classes are in a package named MyPackage and the XML content is in a file named abc.xml:

JAXBContext jc = JAXBContext.newInstance( "MyPackage" );
Unmarshaller u = jc.createUnmarshaller();
PurchaseOrder po =
(PurchaseOrder)u.unmarshal( new FileInputStream( "abc.xml" ) );

Now i want to know whether i have to invoke the command
java -jar [JAXB_LIB]\abc.xsd
dynamically using the java.lang.Runtime execute(String command)
to get the generated java classes in some folder,as we work on the generated java classes to unmarshal it.

Any help will be greatly appreciated.
Many Regards
Ved Gunjan.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: processing xml file in java