bool
VLIDataset::Import(DataNode *node)
{
    this->Set(0, "", 0);

    if ((node != NULL) && (node->GetKey().find("dataset") != std::string::npos)) {
        if (node->GetNode("attributes") != NULL) this->nattr = node->GetNode("attributes")->AsInt();
        else return false;
        if (node->GetNode("format")  != NULL) this->format = std::string(node->GetNode("format")->AsString());
        if (node->GetNode("nitems")  != NULL) this->nitems = node->GetNode("nitems")->AsLong();

        this->attributes = new VLIAttribute[nattr];

        for (int i = 0; i < nattr; ++i) {
            char buf[15];
            sprintf(buf, "attribute %d", i);
            DataNode *aNode = node->GetNode(std::string(buf));
            aNode->SetKey("attribute");
            if (attributes[i].Import(aNode) != true) return false;
        }

        return true;
    }

    return false;
}
DataNode *
VLIDataset::Export(bool withAttributes)
{
    DataNode *node = new DataNode("dataset");
    node->AddNode(new DataNode("attributes", nattr));
    node->AddNode(new DataNode("format", std::string(format)));
    node->AddNode(new DataNode("nitems", nitems));

    if (withAttributes == true) {
        for (int i = 0; i < nattr; ++i) {
            char buf[15];
            sprintf(buf, "attribute %d", i);
            DataNode *aNode = this->attributes[i].Export();
            aNode->SetKey(std::string(buf));
            node->AddNode(aNode);
        }
    }

    return node;
}