• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

processing xml file in java

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic