try {
Element eltServices = new Element("services");
eltServices.setAttribute("package", "org.fao.geonet");
java.util.List<Service> serviceList = null;
ServiceRepository serviceRepo = context.getBean(ServiceRepository.class);
if (serviceIdentifierToLoad == -1) {
serviceList = serviceRepo.findAll();
} else {
serviceList = Collections.singletonList(serviceRepo.findOne(serviceIdentifierToLoad));
}
for (Service service : serviceList) {
if (service != null) {
Element srv = new Element("service");