当前位置: 首页>>代码示例>>C++>>正文


C++ xmlTextWriterEndDocument函数代码示例

本文整理汇总了C++中xmlTextWriterEndDocument函数的典型用法代码示例。如果您正苦于以下问题:C++ xmlTextWriterEndDocument函数的具体用法?C++ xmlTextWriterEndDocument怎么用?C++ xmlTextWriterEndDocument使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了xmlTextWriterEndDocument函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: endpointDescriptorWriter_writeDocument

celix_status_t endpointDescriptorWriter_writeDocument(endpoint_descriptor_writer_pt writer, array_list_pt endpoints, char **document) {
    celix_status_t status = CELIX_SUCCESS;
    int rc;

    rc = xmlTextWriterStartDocument(writer->writer, NULL, "UTF-8", NULL);
    if (rc < 0) {
        status = CELIX_BUNDLE_EXCEPTION;
    } else {
        rc = xmlTextWriterStartElementNS(writer->writer, NULL, ENDPOINT_DESCRIPTIONS, XMLNS);
        if (rc < 0) {
            status = CELIX_BUNDLE_EXCEPTION;
        } else {
            unsigned int i;
            for (i = 0; i < arrayList_size(endpoints); i++) {
                endpoint_description_pt endpoint = arrayList_get(endpoints, i);
                status = endpointDescriptorWriter_writeEndpoint(writer, endpoint);
            }
            if (status == CELIX_SUCCESS) {
                rc = xmlTextWriterEndElement(writer->writer);
                if (rc < 0) {
                    status = CELIX_BUNDLE_EXCEPTION;
                } else {
                    rc = xmlTextWriterEndDocument(writer->writer);
                    if (rc < 0) {
                        status = CELIX_BUNDLE_EXCEPTION;
                    } else {
                        *document = (char *) writer->buffer->content;
                    }
                }
            }
        }
    }

    return status;
}
开发者ID:apache,项目名称:celix,代码行数:35,代码来源:endpoint_descriptor_writer.c

示例2: xmlBufferCreate

char *generate_xml(NFE *nfe, EVP_PKEY *key, X509 *cert) {
	int rc;
	xmlTextWriterPtr writer;
	xmlDocPtr doc;
	xmlBufferPtr buf = xmlBufferCreate();

	writer = xmlNewTextWriterDoc(&doc, 0);
	if (writer == NULL)
		return NULL;
	xmlTextWriterStartDocument(writer, NULL, "UTF-8", NULL);
	rc = gen_inf_nfe(writer, nfe);
	if (rc < 0)
		return NULL;
	xmlTextWriterEndDocument(writer);
	char *URI = malloc(sizeof(char) * (strlen(nfe->idnfe->chave) +
		strlen(ID_PREFIX) + 2));
	strcpy(URI, "#");
	strcat(URI, ID_PREFIX);
	strcat(URI, nfe->idnfe->chave);
	rc = sign_xml(doc, key, cert, URI);
	if(rc)
		return NULL;
	xmlNodeDump(buf, NULL, xmlDocGetRootElement(doc), 0, 0);
	nfe->xml = strdup((char*)buf->content);
	return (char*)buf->content;
}
开发者ID:pablogallardo,项目名称:livrenfe,代码行数:26,代码来源:gen_xml.c

示例3: output

static void
output (char **roots)
{
  xmlOutputBufferPtr ob = xmlOutputBufferCreateFd (1, NULL);
  if (ob == NULL) {
    fprintf (stderr,
             _("%s: xmlOutputBufferCreateFd: failed to open stdout\n"),
             guestfs_int_program_name);
    exit (EXIT_FAILURE);
  }

  /* 'ob' is freed when 'xo' is freed.. */
  CLEANUP_XMLFREETEXTWRITER xmlTextWriterPtr xo = xmlNewTextWriter (ob);
  if (xo == NULL) {
    fprintf (stderr,
             _("%s: xmlNewTextWriter: failed to create libxml2 writer\n"),
             guestfs_int_program_name);
    exit (EXIT_FAILURE);
  }

  /* Pretty-print the output. */
  XMLERROR (-1, xmlTextWriterSetIndent (xo, 1));
  XMLERROR (-1, xmlTextWriterSetIndentString (xo, BAD_CAST "  "));

  XMLERROR (-1, xmlTextWriterStartDocument (xo, NULL, NULL, NULL));
  output_roots (xo, roots);
  XMLERROR (-1, xmlTextWriterEndDocument (xo));
}
开发者ID:myyyy,项目名称:libguestfs,代码行数:28,代码来源:inspector.c

示例4: xmlNewTextWriterDoc

char *gen_export_nfe_xml(NFE *nfe){
	int rc, buffersize;
	xmlTextWriterPtr writer;
	xmlDocPtr doc;
	xmlChar *xmlbuf;

	writer = xmlNewTextWriterDoc(&doc, 0);
	if (writer == NULL)
		return NULL;
	xmlTextWriterStartDocument(writer, NULL, "UTF-8", NULL);
	rc = xmlTextWriterStartElement(writer, BAD_CAST "nfeProc");
	if (rc < 0)
		return NULL;
	rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "versao",
			BAD_CAST NFE_VERSAO);
	if (rc < 0)
		return NULL;
	rc = xmlTextWriterWriteRaw(writer, BAD_CAST nfe->xml);
	if (rc < 0)
		return NULL;
	rc = xmlTextWriterWriteRaw(writer, BAD_CAST nfe->protocolo->xml);
	if (rc < 0)
		return NULL;
	rc = xmlTextWriterEndElement(writer);
	if (rc < 0)
		return NULL;
	xmlTextWriterEndDocument(writer);
	xmlDocDumpMemory(doc, &xmlbuf, &buffersize);
	return (char*)xmlbuf;
}
开发者ID:pablogallardo,项目名称:livrenfe,代码行数:30,代码来源:gen_xml.c

示例5: qgs_write_mem

static int qgs_write_mem(xmlTextWriter *writer, qgs_t *qgs)
{
  if (qgs->n < 2)
    {
      btrace("not enough stops for a gradient (%zi)", qgs->n);
      return 1;
    }

  if (xmlTextWriterWriteDTD(writer, BAD_CAST "qgis_style", NULL, NULL, NULL) < 0)
    {
      btrace("error writing doctype");
      return 1;
    }

  if (qgs_write_qgis(writer, qgs) != 0)
    {
      btrace("failed to write qgis");
      return 1;
    }

  if (xmlTextWriterEndDocument(writer) < 0)
    {
      btrace("error from end document");
      return 1;
    }

  return 0;
}
开发者ID:collinanderson,项目名称:cptutils,代码行数:28,代码来源:qgswrite.c

示例6: xmlTextWriterEndDocument

bool c_XMLWriter::t_enddocument() {
  int ret = -1;
  if (m_ptr) {
    ret = xmlTextWriterEndDocument(m_ptr);
  }
  return ret != -1;
}
开发者ID:chethenry,项目名称:hiphop-php,代码行数:7,代码来源:ext_xmlwriter.cpp

示例7: xmlNewTextWriterFilename

void queryFavouriteFileProvider::SaveFavourites(queryFavouriteFolder *favourites)
{
	xmlTextWriterPtr writer;

	writer = xmlNewTextWriterFilename((const char *)settings->GetFavouritesFile().mb_str(wxConvUTF8), 0);
	if (!writer)
	{
		wxMessageBox(_("Failed to write to favourites file!"));
		return;
	}
	xmlTextWriterSetIndent(writer, 1);

	if ((xmlTextWriterStartDocument(writer, NULL, "UTF-8", NULL) < 0) ||
	        (xmlTextWriterStartElement(writer, XML_STR("favourites")) < 0))
	{
		wxMessageBox(_("Failed to write to favourites file!"));
		xmlFreeTextWriter(writer);
		return;
	}

	((queryFavouriteFolder *)favourites)->saveFolder(writer);

	if (xmlTextWriterEndDocument(writer) < 0)
	{
		wxMessageBox(_("Failed to write to favourites file!"));
	}

	xmlFreeTextWriter(writer);
}
开发者ID:GHnubsST,项目名称:pgadmin3,代码行数:29,代码来源:favourites.cpp

示例8: xmlTextWriterEndDocument

AEResult AEXMLWriter::FinalizeXML()
{
	if (!m_IsReady)
	{
		return AEResult::NotReady;
	}

	AEResult ret = AEResult::Ok;

	int rsc = xmlTextWriterEndDocument(m_XMLWriter);
	if (rsc < 0)
	{
		AETODO("Better return code");
		return AEResult::Fail;
	}

	if (m_InMemory)
	{
		std::ofstream xmlFile(m_Filename);
		if (xmlFile.is_open())
		{
			xmlFile << (const char *)m_XMLBuffer->content;
			xmlFile.close();
		}
		else
		{
			ret = AEResult::OpenFileFail;
		}
	}

	CleanUp();

	return ret;
}
开发者ID:dtbinh,项目名称:Arenal-Engine,代码行数:34,代码来源:AEXMLWriter.cpp

示例9: xmlBufferCreate

std::string XMLSchema::xml() const
{
    xmlBuffer *b = xmlBufferCreate();
    xmlTextWriterPtr w = xmlNewTextWriterMemory(b, 0);

    xmlTextWriterSetIndent(w, 1);
    xmlTextWriterStartDocument(w, NULL, "utf-8", NULL);
    xmlTextWriterStartElementNS(w, (const xmlChar*)"pc",
        (const xmlChar*)"PointCloudSchema", NULL);
    xmlTextWriterWriteAttributeNS(w, (const xmlChar*) "xmlns",
        (const xmlChar*)"pc", NULL,
        (const xmlChar*)"http://pointcloud.org/schemas/PC/");
    xmlTextWriterWriteAttributeNS(w, (const xmlChar*)"xmlns",
        (const xmlChar*)"xsi", NULL,
        (const xmlChar*)"http://www.w3.org/2001/XMLSchema-instance");

    writeXml(w);

    xmlTextWriterEndElement(w);
    xmlTextWriterEndDocument(w);

    std::string output((const char *)b->content, b->use);
    xmlFreeTextWriter(w);
    xmlBufferFree(b);

    return output;
}
开发者ID:mloskot,项目名称:PDAL,代码行数:27,代码来源:XMLSchema.cpp

示例10: xmlNewTextWriterFilename

void queryMacroFileProvider::SaveMacros(queryMacroList *macros)
{
	xmlTextWriterPtr writer;

	writer = xmlNewTextWriterFilename((const char *)settings->GetMacrosFile().mb_str(wxConvUTF8), 0);
	if (!writer)
	{
		wxMessageBox(_("Failed to open macros file!"));
		return;
	}
	xmlTextWriterSetIndent(writer, 1);

	if ((xmlTextWriterStartDocument(writer, NULL, "UTF-8", NULL) < 0) ||
	        (xmlTextWriterStartElement(writer, XML_STR("macros")) < 0))
	{
		wxMessageBox(_("Failed to write to macros file!"));
		xmlFreeTextWriter(writer);
		return;
	}

	((queryMacroList *)macros)->saveList(writer);

	if (xmlTextWriterEndDocument(writer) < -1)
	{
		wxMessageBox(_("Failed to write to macros file!"));
	}

	xmlFreeTextWriter(writer);
}
开发者ID:KrisShannon,项目名称:pgadmin3,代码行数:29,代码来源:macros.cpp

示例11: fileinfo_get

char* fileinfo_get(char* path) {
    FILE* file;
    xmlBufferPtr buf;
    xmlTextWriterPtr writer;
    char* ret;
    int wordCount;

    file  = fopen(path, "r");
    wordCount = countWords(file);
    fclose(file);

    buf = xmlBufferCreate();
    writer = xmlNewTextWriterMemory(buf, 0);

    xmlTextWriterStartDocument(writer, NULL, XML_E, NULL);


    xmlTextWriterStartElement(writer, BAD_CAST "fileInfo");
    xmlTextWriterWriteFormatElement(writer, BAD_CAST "wordCount", "%d", wordCount);
    xmlTextWriterEndElement(writer);

    xmlTextWriterEndDocument(writer);

    ret = malloc(buf->size);
    strcpy(ret,(char*)buf->content);
    xmlBufferFree(buf);

    return ret;
}
开发者ID:antonmazun,项目名称:gogog,代码行数:29,代码来源:fileInfo.c

示例12: write_volumeindex

int write_volumeindex(opendcp_t *opendcp) {
    xmlIndentTreeOutput = 1;
    xmlDocPtr        doc;
    xmlTextWriterPtr xml;
    int              rc;

    dcp_log(LOG_INFO,"Writing VOLINDEX file %.256s",opendcp->volindex.filename);

    /* create XML document */
    xml = xmlNewTextWriterDoc(&doc,0);

    /* volumeindex XML Start */
    rc = xmlTextWriterStartDocument(xml, NULL, XML_ENCODING, NULL);
    if (rc < 0) {
        dcp_log(LOG_ERROR,"xmlTextWriterStartDocument failed");
        return DCP_FATAL;
    }

    xmlTextWriterStartElement(xml, BAD_CAST "VolumeIndex");
    xmlTextWriterWriteAttribute(xml, BAD_CAST "xmlns", BAD_CAST NS_AM[opendcp->ns]);
    xmlTextWriterWriteFormatElement(xml, BAD_CAST "Index","%d",1);
    xmlTextWriterEndElement(xml); 

    rc = xmlTextWriterEndDocument(xml);
    if (rc < 0) {
        dcp_log(LOG_ERROR,"xmlTextWriterEndDocument failed %s",opendcp->volindex.filename);
        return DCP_FATAL;
    }

    xmlFreeTextWriter(xml);
    xmlSaveFormatFile(opendcp->volindex.filename, doc, 1);
    xmlFreeDoc(doc);

    return DCP_SUCCESS;
}
开发者ID:eugen-kugler,项目名称:OpenDCP,代码行数:35,代码来源:opendcp_xml.c

示例13: tDebug

bool TasksetWriter::write(const std::string& filename, vector<Task*>& taskset) const {
    xmlDocPtr doc;
    tDebug() << "Writing Taskset to XML file: " << filename;

    xmlTextWriterPtr writer;
    writer = xmlNewTextWriterDoc(&doc, 0);
    xmlTextWriterSetIndent(writer, 1);
    if (xmlTextWriterSetIndentString(writer, (const xmlChar*) "  ") != 0) {
        tError() << "Fehler beim Setzen des Einrueckens!";
    }

    xmlTextWriterStartDocument(writer, NULL, "UTF-8", NULL);

    xmlTextWriterWriteComment(writer, (xmlChar*) "Hier kommen die Tasks");

    xmlTextWriterStartElement(writer, (xmlChar*) "taskset");
    xmlTextWriterWriteAttributeNS(writer, (xmlChar*) "xsi", (xmlChar*) "schemaLocation", (xmlChar*) "http://www.w3.org/2001/XMLSchema-instance", (xmlChar*) "http://www.tmsxmlns.com taskset.xsd");
    xmlTextWriterWriteAttribute(writer, (xmlChar*) "xmlns", (xmlChar*) "http://www.tmsxmlns.com");

    xmlTextWriterWriteRaw(writer, (xmlChar*) "\n");

    for (size_t i = 0; i < taskset.size(); i++) {
        xmlTextWriterWriteRaw(writer, (xmlChar*) "\n");
        //taskset[i]->write(writer);
        taskset[i]->writeToXML(writer);
        xmlTextWriterWriteRaw(writer, (xmlChar*) "\n");
    }

    xmlTextWriterEndElement(writer); // close TaskSet

    xmlTextWriterEndDocument(writer);
    xmlFreeTextWriter(writer);
    xmlSaveFile(filename.c_str(), doc);

    xmlNodePtr cur = xmlDocGetRootElement(doc);
    if (cur == NULL) {
        tError() << "Empty document.";
        xmlFreeDoc(doc);
        return false;
    }
    if (xmlStrcmp(cur->name, (const xmlChar *) "taskset")) {
        tError() << "Document of the wrong type, root node != taskset";
        xmlFreeDoc(doc);
        return false;
    }

    if (isValid(doc) > 0) {
        tDebug() << "Written document is valid";

    } else {
        tError() << "Written document is invalid";
        xmlFreeDoc(doc);
        return false;
    }

    xmlFreeDoc(doc);

    return true;

}
开发者ID:702nADOS-archive,项目名称:tms-sim-modified,代码行数:60,代码来源:tasksetwriter.cpp

示例14: cpe_lang_model_export_xml

/* Private exporting functions cpe_*<structure>*_export( xmlTextWriterPtr )
 * More info in representive header file.
 * returns the type of <structure>
 */
void cpe_lang_model_export_xml(const struct cpe_lang_model *spec, const char *file)
{

	__attribute__nonnull__(spec);
	__attribute__nonnull__(file);

	// TODO: ad macro to check return value from xmlTextWriter* functions
	xmlTextWriterPtr writer;

	writer = xmlNewTextWriterFilename(file, 0);
	if (writer == NULL) {
		oscap_setxmlerr(xmlGetLastError());
		return;
	}
	// Set properties of writer TODO: make public function to edit this ??
	xmlTextWriterSetIndent(writer, 1);
	xmlTextWriterSetIndentString(writer, BAD_CAST "    ");

	xmlTextWriterStartDocument(writer, NULL, "UTF-8", NULL);

	cpe_lang_export(spec, writer);
	xmlTextWriterEndDocument(writer);
	xmlFreeTextWriter(writer);
	if (xmlGetLastError() != NULL)
		oscap_setxmlerr(xmlGetLastError());
}
开发者ID:GautamSatish,项目名称:openscap,代码行数:30,代码来源:cpelang_priv.c

示例15: assert

bool XMLInOut::SaveScript(const char* filename)
{
	int rc;
	ofstream out;
	// First check to see that we can open the filename before saving/killing the document.

	assert(filename);
	out.open(filename);

	if (out.fail())
		return false;

	rc = xmlTextWriterEndDocument(writer);
    if (rc < 0) {
        printf("testXmlwriterMemory: Error at xmlTextWriterEndDocument\n");
        return false;
    }

    // Now print it or write it...
    cout << "XML Command being saved:" << endl
    		<< "'" << (const char *) buf->content << "'" << endl;

	out << buf->content;
	out.close();

    // Reset back to zero. New document.
    SetupDoc();
    return true;
}
开发者ID:bobwolff68,项目名称:neuron,代码行数:29,代码来源:xmlinout.cpp


注:本文中的xmlTextWriterEndDocument函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。