java - Is my XML output suppose to be like this? -
<?xml version="1.0" encoding="utf-8" standalone="yes"?> <staffs> <records xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:type="employee"> <id>1</id> <name>danial</name> <age>20</age> <tfn>1231231</tfn> <contact>12314123</contact> <jobtype>waiter</jobtype> <wage>12.0</wage> </records> <records xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:type="employee"> <id>2</id> <name>andrew</name> <age>21</age> <tfn>1231254</tfn> <contact>123677</contact> <jobtype>admin</jobtype> <wage>18.0</wage> </records> <records xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:type="employee"> <id>3</id> <name>jenny</name> <age>19</age> <tfn>1231432</tfn> <contact>1239873</contact> <jobtype>waitress</jobtype> <wage>15.0</wage> </records> <employees> <id>1</id> <name>danial</name> <age>20</age> <tfn>1231231</tfn> <contact>12314123</contact> <jobtype>waiter</jobtype> <wage>12.0</wage> </employees> <employees> <id>2</id> <name>andrew</name> <age>21</age> <tfn>1231254</tfn> <contact>123677</contact> <jobtype>admin</jobtype> <wage>18.0</wage> </employees> <employees> <id>3</id> <name>jenny</name> <age>19</age> <tfn>1231432</tfn> <contact>1239873</contact> <jobtype>waitress</jobtype> <wage>15.0</wage> </employees> </staffs>
anyways after using jaxb output above. normal?? why repeating inputs? records holds linkedlist , employees extends records
if there's away prevent keen hear
import javax.xml.bind.annotation.*; @xmlrootelement(name = "staffs") @xmlaccessortype(xmlaccesstype.field) public class employees extends records { @xmlelement(type = employee.class) public linkedlist<record> getemployees() { return super.getrecords(); } } //////////////////////employee class///////////////// import javax.xml.bind.annotation.*; @xmlrootelement(name = "staff") @xmlaccessortype(xmlaccesstype.field) public class employee extends record { }
the problem ist because have getters return same list:
- record.getrecords() and
- employee.getemployees().
see
public linkedlist<record> getemployees() { return super.getrecords(); }
that's why have 2 identical lists. need duplicate getter? if not, remove , output without duplicates.
Comments
Post a Comment