<?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="Employee"> <xs:complexType> <xs:sequence> <xs:element name="id" type="xs:int"/> <xs:element name="name" type="xs:string"/> <xs:element name="salary" type="xs:double" minOccurs="0"/> <xs:element name="department" type="xs:string"/> </xs:sequence> <xs:attribute name="active" type="xs:boolean"/> </xs:complexType> </xs:element> </xs:schema>
@XmlElement(required = true) protected String department;
@XmlElement(required = false) protected Double salary; convert xsd to java pojo online
Run xjc locally or via build tool to keep code generation in your pipeline and avoid uploading sensitive schemas.
package com.example.model; import javax.xml.bind.annotation.*; ?xml version="1.0" encoding="UTF-8"?>
@XmlElement(required = true) protected int id;
@XmlAttribute(name = "active") protected Boolean active; xs:element name="id" type="xs:int"/>
@XmlElement(required = true) protected String name;