private function listSets()
    {
        $listNode = $this->response->createElement('ListSets');

        // fetch the sets either by resumption token or without
        if (isset($this->params['resumptionToken'])) {
            $sets = $this->repository->listSetsByToken($this->params['resumptionToken']);
        } else {
            $sets = $this->repository->listSets();
            if (!count($sets->getItems())) {
                throw new NoSetHierarchyException("The repository does not support sets.");
            }
        }

        //create node for all sets
        foreach ($sets->getItems() as $set) {
            $setNode = $this->response->createElement('set');
            $setNode->appendChild($this->response->createElement('setSpec', $set->getSpec()));
            $setNode->appendChild($this->response->createElement('setName', $set->getName()));
            if ($set->getDescription()) {
                $setNode->appendChild($this->response->createElement('setDescription', $set->getDescription()));
            }
            $listNode->appendChild($setNode);
        }

        $this->addResumptionToken($sets, $listNode);

        return $listNode;
    }