public class EmployeeXmlDS extends DataSource {

    private static EmployeeXmlDS instance = null;

    public static EmployeeXmlDS getInstance() {
        if (instance == null) {
            instance = new EmployeeXmlDS("employeesDS");
        }
        return instance;
    }

    public EmployeeXmlDS(String id) {

        setID(id);
        setTitleField("Name");
        setRecordXPath("/List/employee");
        DataSourceTextField nameField = new DataSourceTextField("Name", "Name", 128);

        DataSourceIntegerField nodeIdField = new DataSourceIntegerField("NodeId", "Node ID");
        nodeIdField.setPrimaryKey(true);
        nodeIdField.setRequired(true);

        DataSourceIntegerField reportsToField = new DataSourceIntegerField("ReportsTo", "Manager");
        reportsToField.setRequired(true);
        reportsToField.setForeignKey(id + ".NodeId");
        reportsToField.setRootValue("1");

        DataSourceBooleanField isFolderField = new DataSourceBooleanField("isFolder");

        setFields(nameField, nodeIdField, reportsToField, isFolderField);

        setDataURL("employee.data.xml");
        setClientOnly(true);
    }
}