- We can use DTD or XSD files for providing the information for about the xml tags that has to be used in our xml files.
- To read the information from an xml document, xml parsers like SAX(Simple API for XML parsing) and DOM(Document Object Model) can be used.
- SAX,DOM parsers are provided as part of JAXP(java API for xml processing).
- To read an XML document,we can use JAXP directly or we can use the solutions like XML Beans,JAXB.
- XML Beans,JAXB internally uses JAXP.
Schema compiler reads the information in XSD files and generates the classes and interfaces.
Steps to generate classes and interfaces from XSD using schema compiler.
- Download the current xml beans(xmlbeans-2.6.0.zip).
- Create a directory (E:\xml) and copy the downloaded ZIP file.
- Use cd command and move to the directory created in step 2.
- Extract the content of ZIP file using the command jar xf xmlbeans-2.6.0.zip
- A directory with the name xmlbeans-2.6.0 will be created and all the files related to xml beans will be copied.
- Create the classes,source directories under E:\xml>
- Run the following 2 commands.
- Copy the XSD file under E:\xml and run the following command.
E:\xml>scomp -d classes -src source customer.xsd