java - JAXB basics and parsing xml -


i have understood basics jaxb. tried 1 sample program , need help.

  1. i created sample jaxb project , tried parsing 1 xsd , xml file.. got error. later figured out need jdk targeted run-times jaxb uses files not in jre. can explain more please?

  2. then have parsed files.i haven't worked xml's before not sure syntax followed. think xml file should have mentioning xsd file. correct? parsed in 1 of classes got code generated:

    @xmlaccessortype(xmlaccesstype.field) @xmltype(name = "bookform", proporder = { "author", "title", "genre", "price", "pubdate", "review" })

shouldn't these have datatypes in front of them?

my sample xsd is:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/xmlschema"         targetnamespace="urn:books"         xmlns:bks="urn:books"> <xsd:element name="books" type="bks:booksform"/> <xsd:complextype name="booksform"> <xsd:sequence>   <xsd:element name="book"                type="bks:bookform"                minoccurs="0"                maxoccurs="unbounded"/>   </xsd:sequence> </xsd:complextype> <xsd:complextype name="bookform"> <xsd:sequence>   <xsd:element name="author"   type="xsd:string"/>   <xsd:element name="title"    type="xsd:string"/>   <xsd:element name="genre"    type="xsd:string"/>   <xsd:element name="price"    type="xsd:float" />   <xsd:element name="pub_date" type="xsd:date" />   <xsd:element name="review"   type="xsd:string"/> </xsd:sequence> <xsd:attribute name="id"   type="xsd:string"/> </xsd:complextype> 

my sample xml is:

<?xml version="1.0"?> <x:books xmlns:x="urn:books"> <book id="bk001">   <author>writer</author>   <title>the first book</title>   <genre>fiction</genre>   <price>44.95</price>   <pub_date>2000-10-01</pub_date>   <review>an amazing story of nothing.</review> </book></x:books> 

where can more info these annotations , how jaxb generates classes?


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -