Writing XML-File with Jpa

empalsili

New Member
Im using JAXB.marshal(list,file.xml) to write an XML file. It works perfectly and i can import the data into excel or access. but all columns are imported as string, although some are double or date. for the date field i used the @Temporal(javax.persistence.TemporalType.DATE) annotation. how can i save the datatyp in the xml file?or do i have to save it in a XML Schema? if so, can i auto-generate it with jpa?Edit: I managed to generate a xml and xsd file:XSD:\[code\]<?xml version="1.0" encoding="UTF-8" standalone="yes"?><xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:complexType name="eintragListe"><xs:sequence><xs:element name="Eintrag" type="eintrag" minOccurs="0" maxOccurs="unbounded"/></xs:sequence></xs:complexType><xs:complexType name="eintrag"> <xs:sequence> <xs:element name="art" type="xs:string" minOccurs="0"/> <xs:element name="betrag" type="xs:double"/> <xs:element name="datum" type="xs:dateTime" minOccurs="0"/> <xs:element name="id" type="xs:int"/> <xs:element name="pa" type="xs:int"/> <xs:element name="typ" type="xs:string" minOccurs="0"/> <xs:element name="verwendung" type="xs:string" minOccurs="0"/></xs:sequence> </xs:complexType></xs:schema>\[/code\]XML:\[code\] <?xml version="1.0" encoding="UTF-8"?><ns2:eintragListe xmlns:ns2="www"> <Eintrag> <art>Einmalig</art> <betrag>27.0</betrag> <datum>2012-06-01T00:00:00+02:00</datum> <id>601</id> <pa>-1</pa> <typ>Ausgabe</typ> <verwendung>Irgendswas</verwendung></Eintrag><Eintrag> <art>Einmalig</art> <betrag>17.0</betrag> <datum>2012-06-01T00:00:00+02:00</datum> <id>502</id> <pa>-1</pa> <typ>Ausgabe</typ> <verwendung>Irgendwasanderes</verwendung> </Eintrag></ns2:eintragListe>\[/code\]i now wanted to import these files into excel, but i always get an error, that the schema doesnt fit to the xml file. is there a solution? thanks four your help :)
 
Back
Top