Вы находитесь на странице: 1из 3


JAXB allows Java developers to access and process XML data without having to know XML or XML processing. For example, there's no need to create or use a SAX parser or write callback methods. It makes use of a given schema of an XML document and automatically generates the required Java classes, corresponding to that schema. (DeveloperIQ is now providing a detailed workshop on DTD, a form of Schema). Modern trend focuses on XML representation of Data, for ease of exchange in webservice and otherwise. If we have an xml representation of a database, we can use JAXB to create a tree of Java objects and work with them in Java idiom. This is known as

Validation is an important part of any XML document. Unlike HTML, XML tags are user-defined. This is what gives XML its power and utility. But, at the same time, to make it really useful, each such XML document should have a 'schema'.... Something like Data Definition in SQL. It should be carefully noted that 'schema' is a general term. In the earlier days of XML, the only schema that was known and used was DTD (Document-type-definition). Even today, DTD is said to be the most prevalent 'schema' in use and best known, among developers. However, DTD was found to have a number of limitations. Microsoft is credited with the proposal for an alternative to DTD in the very early days of XML.It was known as 'XML Schema. The proposal was submitted to the W3C (World-wide Web Consortium), which is the standards body for XML, HTML and related topics and was later adopted by W3C with some modifications. 'XML-Schema' is considered to be better than DTD, for a number of reasons. First, unlike a DTD, an XML-Schema is itself an XML document. Secondly, it has provision for greater variety of data-types than are available in DTD.It supports Name-space. JAXB Mapping of XML Schema Built-in Data Types XML Schema Type Java Data Type xsd:string java.lang.String xsd:integer java.math.BigInteger

xsd:int int xsd.long long xsd:short short xsd:decimal java.math.BigDecimal xsd:float float xsd:double double xsd:boolean boolean xsd:byte byte xsd:QName javax.xml.namespace.QName xsd:dateTime java.util.Calendar xsd:base64Binary byte[] xsd:hexBinary

byte[] xsd:unsignedInt long xsd:unsignedShort int xsd:unsignedByte short xsd:time java.util.Calendar xsd:date java.util.Calendar xsd:anySimpleType java.lang.String
public static HiringScenario getScenario() throws FileNotFoundException { try{ JAXBContext context = JAXBContext.newInstance("com.savvion.tools.simulation.ui.eclipse.report s.excel.jaxbgenerated") ; Unmarshaller unmarshaller = context.createUnmarshaller(); hiringScenario = (HiringScenario)unmarshaller.unmarshal(new FileInputStream("HiringScenario.ssf")); } catch(JAXBException je) { je.getMessage(); } return hiringScenario; }

public static void main(String[] args) throws Exception { getScenario(); }