xml - Java JaxB generation, How do I get a bigDecimal from my xsd? -
i have xsd annotation trying marshal java object. java end bigdecimal value. enter in xsd make this? using xjc ant task
<xjc schema="my.xsd" destdir="generated" header="false" extension="true" />
here relevant xsd -
<complextype name="size"> <attribute name="height" type="bigdecimal"></attribute> <!-- wrong--> </complextype>
i end generated class -
public class size { @xmlattribute(name = "height") protected bigdecimal height; }
a jaxb (jsr-222) implementation generate java.math.bigdecimal
decimal
type (see table 6-1 in jaxb 2.2 specification).
xml schema (schema.xsd)
<?xml version="1.0" encoding="utf-8"?> <schema xmlns="http://www.w3.org/2001/xmlschema" targetnamespace="http://www.example.org/schema" xmlns:tns="http://www.example.org/schema" elementformdefault="qualified"> <element name="foo"> <complextype> <sequence> <element name="bar" type="decimal"/> </sequence> </complextype> </element> </schema>
xjc call
xjc schema.xsd
java model (foo)
package org.example.schema; import java.math.bigdecimal; import javax.xml.bind.annotation.*; @xmlaccessortype(xmlaccesstype.field) @xmltype(name = "", proporder = {"bar"}) @xmlrootelement(name = "foo") public class foo { @xmlelement(required = true) protected bigdecimal bar; ... }
Comments
Post a Comment