Binding XML Schemas

JAXB를 사용한 기본적인 XML-to Java binding을 설명함

 

Simble Type Definitions

 Simple type으로 선언한 것을 사용하는 schema component는 전형적으로 Java property로 묶는다.

Schema component의 종류가 다르게 때문에, 여기에 따른 Java property attributes들은 아래와 같은 것을 포함한다.

  • Base type
  • Collection type, if any
  • Predicate

 

Default Data Type Binding

여기에서는 schema-to-Java, JAXBElement 그리고 Java-to-schema data type binding에 대해 설명한다.

 

Schema-to-Java

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:dataTime javax.xml.datatype.XMLGregorianCalendar
xsd:base64Binary byte[]
xsd:hexBinary byte[]
xsd:unsignedInt long
xsd:unsignedShort int
xsd:unsignedByte short
xsd:time javax.xml.datatype.XMLGregorialCalendar
xsd:date javax.xml.datatype.XMLGregorialCalendar
xsd:g javax.xml.datatype.XMLGregorialCalendar
xsd:anySimpleType java.lang.Object
xsd:anySimpleType java.lang.String
xsd:duration javax.xml.datatype.Duration
xsd:NOTATION javax.xml.namespace.QName


JAXBElement

JAXB Mapping of XML Data Types to Java Classes

Java Class XML Data Type
java.lang.String xs:string
java.math.BigInteger xs:integer
java.math.BigDecimal xs:decimal
java.util.Calendar xs:dataTime
java.util.Date xs:dataTime
javax.xml.namespace.QName xs:QName
java.net.URI xs:string
javax.xml.datatype.XMLGregorianCalendar xs:anySimpleType
javax.xml.datatype.Duration xs:duration
java.lang.Object xs:anyType
java.awt.Image xs:base64Binary
javax.activation.DataHandler xs:base64Binary
javax.xml.transform.Source xs:base64Binary
java.util.UUID xs:string

 

 

 

이 글은 스프링노트에서 작성되었습니다.

Buy me a coffeeBuy me a coffee

+ Recent posts