15841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard 21d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/* 31d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlwriter.c: XML text writer implementation 41d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 51d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * For license and disclaimer see the license and disclaimer of 61d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * libxml2. 71d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 81d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * alfred@mickautsch.de 91d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 101d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 11b23de5ad89fbcd0a0a6dcab2053cb8e25fc7aa0fIgor Zlatkovic#define IN_LIBXML 12c1099be5eb3e78ae6cef1b2c39b21e7b36a59035William M. Brack#include "libxml.h" 131d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard#include <string.h> 141d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 151d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard#include <libxml/xmlmemory.h> 161d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard#include <libxml/parser.h> 175841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard#include <libxml/uri.h> 185841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard#include <libxml/HTMLtree.h> 191d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 201d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard#ifdef LIBXML_WRITER_ENABLED 211d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 221d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard#include <libxml/xmlwriter.h> 231d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 24dbf5411b21cbf5f0f72283a3ff4d4df38afa9990Daniel Veillard#include "buf.h" 25dbf5411b21cbf5f0f72283a3ff4d4df38afa9990Daniel Veillard#include "enc.h" 26dbf5411b21cbf5f0f72283a3ff4d4df38afa9990Daniel Veillard#include "save.h" 27dbf5411b21cbf5f0f72283a3ff4d4df38afa9990Daniel Veillard 281d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard#define B64LINELEN 72 291d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard#define B64CRLF "\r\n" 301d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 311d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/* 32f4caa5e698007f195d1c99b0ef1e06add0c852f4William M. Brack * The following VA_COPY was coded following an example in 33f4caa5e698007f195d1c99b0ef1e06add0c852f4William M. Brack * the Samba project. It may not be sufficient for some 340f7a26d8442b87fb7d576e759c9148e8feff9e20Patrick Monnerat * esoteric implementations of va_list but (hopefully) will 350f7a26d8442b87fb7d576e759c9148e8feff9e20Patrick Monnerat * be sufficient for libxml2. 36f4caa5e698007f195d1c99b0ef1e06add0c852f4William M. Brack */ 37f4caa5e698007f195d1c99b0ef1e06add0c852f4William M. Brack#ifndef VA_COPY 38f4caa5e698007f195d1c99b0ef1e06add0c852f4William M. Brack #ifdef HAVE_VA_COPY 39f4caa5e698007f195d1c99b0ef1e06add0c852f4William M. Brack #define VA_COPY(dest, src) va_copy(dest, src) 40f4caa5e698007f195d1c99b0ef1e06add0c852f4William M. Brack #else 41f4caa5e698007f195d1c99b0ef1e06add0c852f4William M. Brack #ifdef HAVE___VA_COPY 42f4caa5e698007f195d1c99b0ef1e06add0c852f4William M. Brack #define VA_COPY(dest,src) __va_copy(dest, src) 43f4caa5e698007f195d1c99b0ef1e06add0c852f4William M. Brack #else 440f7a26d8442b87fb7d576e759c9148e8feff9e20Patrick Monnerat #ifndef VA_LIST_IS_ARRAY 450f7a26d8442b87fb7d576e759c9148e8feff9e20Patrick Monnerat #define VA_COPY(dest,src) (dest) = (src) 460f7a26d8442b87fb7d576e759c9148e8feff9e20Patrick Monnerat #else 470f7a26d8442b87fb7d576e759c9148e8feff9e20Patrick Monnerat #include <string.h> 480f7a26d8442b87fb7d576e759c9148e8feff9e20Patrick Monnerat #define VA_COPY(dest,src) memcpy((char *)(dest),(char *)(src),sizeof(va_list)) 490f7a26d8442b87fb7d576e759c9148e8feff9e20Patrick Monnerat #endif 50f4caa5e698007f195d1c99b0ef1e06add0c852f4William M. Brack #endif 51f4caa5e698007f195d1c99b0ef1e06add0c852f4William M. Brack #endif 52f4caa5e698007f195d1c99b0ef1e06add0c852f4William M. Brack#endif 53f4caa5e698007f195d1c99b0ef1e06add0c852f4William M. Brack 54f4caa5e698007f195d1c99b0ef1e06add0c852f4William M. Brack/* 551d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Types are kept private 561d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 571d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardtypedef enum { 581d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard XML_TEXTWRITER_NONE = 0, 591d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard XML_TEXTWRITER_NAME, 601d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard XML_TEXTWRITER_ATTRIBUTE, 611d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard XML_TEXTWRITER_TEXT, 621d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard XML_TEXTWRITER_PI, 631d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard XML_TEXTWRITER_PI_TEXT, 641d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard XML_TEXTWRITER_CDATA, 651d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard XML_TEXTWRITER_DTD, 661d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard XML_TEXTWRITER_DTD_TEXT, 671d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard XML_TEXTWRITER_DTD_ELEM, 68500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard XML_TEXTWRITER_DTD_ELEM_TEXT, 691d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard XML_TEXTWRITER_DTD_ATTL, 70500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard XML_TEXTWRITER_DTD_ATTL_TEXT, 71500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard XML_TEXTWRITER_DTD_ENTY, /* entity */ 72500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard XML_TEXTWRITER_DTD_ENTY_TEXT, 73500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard XML_TEXTWRITER_DTD_PENT, /* parameter entity */ 7487640d5f14e7ce8b9844b886c765af0c56de5ca5William M. Brack XML_TEXTWRITER_COMMENT 751d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} xmlTextWriterState; 761d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 771d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardtypedef struct _xmlTextWriterStackEntry xmlTextWriterStackEntry; 781d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 791d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardstruct _xmlTextWriterStackEntry { 801d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlChar *name; 811d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlTextWriterState state; 821d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard}; 831d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 841d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardtypedef struct _xmlTextWriterNsStackEntry xmlTextWriterNsStackEntry; 851d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardstruct _xmlTextWriterNsStackEntry { 861d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlChar *prefix; 871d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlChar *uri; 881d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlLinkPtr elem; 891d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard}; 901d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 911d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardstruct _xmlTextWriter { 92ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard xmlOutputBufferPtr out; /* output buffer */ 93ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard xmlListPtr nodes; /* element name stack */ 94ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard xmlListPtr nsstack; /* name spaces stack */ 951d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int level; 96ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard int indent; /* enable indent */ 97ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard int doindent; /* internal indent flag */ 98ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard xmlChar *ichar; /* indent character */ 99ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard char qchar; /* character used for quoting attribute values */ 10020c5e7878d462bfd93aa4eede7f1f5faabd377feDaniel Veillard xmlParserCtxtPtr ctxt; 101a521d287516f2dc93a8fe540c5883ffc39cb5024Daniel Veillard int no_doc_free; 1029db68f0c14cb0509cd262749aa6ea2d15fbd6207Rob Richards xmlDocPtr doc; 1031d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard}; 1041d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 1051d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardstatic void xmlFreeTextWriterStackEntry(xmlLinkPtr lk); 1061d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardstatic int xmlCmpTextWriterStackEntry(const void *data0, 1071d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const void *data1); 108b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richardsstatic int xmlTextWriterOutputNSDecl(xmlTextWriterPtr writer); 1091d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardstatic void xmlFreeTextWriterNsStackEntry(xmlLinkPtr lk); 1101d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardstatic int xmlCmpTextWriterNsStackEntry(const void *data0, 1111d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const void *data1); 1125841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillardstatic int xmlTextWriterWriteDocCallback(void *context, 1135841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard const xmlChar * str, int len); 1145841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillardstatic int xmlTextWriterCloseDocCallback(void *context); 1155841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard 1164472c3a5a5b516aaf59b89be602fbce52756c3e9David Kilzerstatic xmlChar *xmlTextWriterVSprintf(const char *format, va_list argptr) LIBXML_ATTR_FORMAT(1,0); 1171d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardstatic int xmlOutputBufferWriteBase64(xmlOutputBufferPtr out, int len, 1181d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const unsigned char *data); 1195841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillardstatic void xmlTextWriterStartDocumentCallback(void *ctx); 120ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillardstatic int xmlTextWriterWriteIndent(xmlTextWriterPtr writer); 121500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillardstatic int 122500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard xmlTextWriterHandleStateDependencies(xmlTextWriterPtr writer, 123500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard xmlTextWriterStackEntry * p); 1241d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 1251d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 126dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard * xmlWriterErrMsg: 127dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard * @ctxt: a writer context 128dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard * @error: the error number 129dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard * @msg: the error message 130dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard * 131dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard * Handle a writer error 132dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard */ 133dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillardstatic void 134dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel VeillardxmlWriterErrMsg(xmlTextWriterPtr ctxt, xmlParserErrors error, 135dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard const char *msg) 136dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard{ 137dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard if (ctxt != NULL) { 138dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard __xmlRaiseError(NULL, NULL, NULL, ctxt->ctxt, 139dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard NULL, XML_FROM_WRITER, error, XML_ERR_FATAL, 140bccae2d21038967f5d83109f27b925bcd4795602Daniel Veillard NULL, 0, NULL, NULL, NULL, 0, 0, "%s", msg); 141dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard } else { 142dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_WRITER, error, 143bccae2d21038967f5d83109f27b925bcd4795602Daniel Veillard XML_ERR_FATAL, NULL, 0, NULL, NULL, NULL, 0, 0, "%s", msg); 144dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard } 145dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard} 146dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard 147dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard/** 148dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard * xmlWriterErrMsgInt: 149dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard * @ctxt: a writer context 150dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard * @error: the error number 151dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard * @msg: the error message 152dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard * @val: an int 153dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard * 154dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard * Handle a writer error 155dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard */ 1564472c3a5a5b516aaf59b89be602fbce52756c3e9David Kilzerstatic void LIBXML_ATTR_FORMAT(3,0) 157dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel VeillardxmlWriterErrMsgInt(xmlTextWriterPtr ctxt, xmlParserErrors error, 158dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard const char *msg, int val) 159dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard{ 160dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard if (ctxt != NULL) { 161dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard __xmlRaiseError(NULL, NULL, NULL, ctxt->ctxt, 162dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard NULL, XML_FROM_WRITER, error, XML_ERR_FATAL, 163dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard NULL, 0, NULL, NULL, NULL, val, 0, msg, val); 164dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard } else { 165dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_WRITER, error, 166dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard XML_ERR_FATAL, NULL, 0, NULL, NULL, NULL, val, 0, msg, val); 167dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard } 168dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard} 169dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard 170dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard/** 1711d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlNewTextWriter: 1721d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @out: an xmlOutputBufferPtr 1731d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 1741d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Create a new xmlNewTextWriter structure using an xmlOutputBufferPtr 175d5cc0f7f5185532120f6b8351e12ed7e81d4a28cDaniel Veillard * NOTE: the @out parameter will be deallocated when the writer is closed 176d5cc0f7f5185532120f6b8351e12ed7e81d4a28cDaniel Veillard * (if the call succeed.) 1771d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 1781d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the new xmlTextWriterPtr or NULL in case of error 1791d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 1801d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterPtr 1811d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlNewTextWriter(xmlOutputBufferPtr out) 1821d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 1831d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlTextWriterPtr ret; 1841d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 1851d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard ret = (xmlTextWriterPtr) xmlMalloc(sizeof(xmlTextWriter)); 1861d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (ret == NULL) { 187dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY, 1881d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard "xmlNewTextWriter : out of memory!\n"); 1891d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return NULL; 1901d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 1911d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard memset(ret, 0, (size_t) sizeof(xmlTextWriter)); 1921d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 1931d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard ret->nodes = xmlListCreate((xmlListDeallocator) 1941d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlFreeTextWriterStackEntry, 1951d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard (xmlListDataCompare) 1961d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlCmpTextWriterStackEntry); 1971d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (ret->nodes == NULL) { 198dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY, 1991d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard "xmlNewTextWriter : out of memory!\n"); 2001d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlFree(ret); 2011d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return NULL; 2021d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 2031d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 2041d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard ret->nsstack = xmlListCreate((xmlListDeallocator) 2051d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlFreeTextWriterNsStackEntry, 2061d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard (xmlListDataCompare) 2071d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlCmpTextWriterNsStackEntry); 2081d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (ret->nsstack == NULL) { 209dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY, 2101d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard "xmlNewTextWriter : out of memory!\n"); 211500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard xmlListDelete(ret->nodes); 2121d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlFree(ret); 2131d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return NULL; 2141d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 2151d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 2161d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard ret->out = out; 217ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard ret->ichar = xmlStrdup(BAD_CAST " "); 2181d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard ret->qchar = '"'; 2191d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 220500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (!ret->ichar) { 221500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard xmlListDelete(ret->nodes); 222500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard xmlListDelete(ret->nsstack); 223500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard xmlFree(ret); 224dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY, 225500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard "xmlNewTextWriter : out of memory!\n"); 226ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard return NULL; 227500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 2289db68f0c14cb0509cd262749aa6ea2d15fbd6207Rob Richards 2299db68f0c14cb0509cd262749aa6ea2d15fbd6207Rob Richards ret->doc = xmlNewDoc(NULL); 2309db68f0c14cb0509cd262749aa6ea2d15fbd6207Rob Richards 231a521d287516f2dc93a8fe540c5883ffc39cb5024Daniel Veillard ret->no_doc_free = 0; 232ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard 2331d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return ret; 2341d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 2351d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 2361d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 2371d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlNewTextWriterFilename: 2381d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @uri: the URI of the resource for the output 2391d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @compression: compress the output? 2401d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 2411d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Create a new xmlNewTextWriter structure with @uri as output 2421d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 2431d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the new xmlTextWriterPtr or NULL in case of error 2441d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 2451d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterPtr 2461d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlNewTextWriterFilename(const char *uri, int compression) 2471d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 2481d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlTextWriterPtr ret; 2491d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlOutputBufferPtr out; 2501d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 2511d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard out = xmlOutputBufferCreateFilename(uri, NULL, compression); 2521d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (out == NULL) { 253798743a4983d3a2c94d6af1608bce9696aa181e7Rob Richards xmlWriterErrMsg(NULL, XML_IO_EIO, 254798743a4983d3a2c94d6af1608bce9696aa181e7Rob Richards "xmlNewTextWriterFilename : cannot open uri\n"); 2551d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return NULL; 2561d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 2571d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 2581d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard ret = xmlNewTextWriter(out); 2591d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (ret == NULL) { 260dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY, 2611d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard "xmlNewTextWriterFilename : out of memory!\n"); 2621d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlOutputBufferClose(out); 2631d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return NULL; 2641d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 2651d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 2662cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard ret->indent = 0; 2672cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard ret->doindent = 0; 2681d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return ret; 2691d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 2701d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 2711d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 2721d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlNewTextWriterMemory: 2731d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @buf: xmlBufferPtr 2741d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @compression: compress the output? 2751d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 2761d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Create a new xmlNewTextWriter structure with @buf as output 2771d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * TODO: handle compression 2781d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 2791d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the new xmlTextWriterPtr or NULL in case of error 2801d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 2811d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterPtr 2821d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlNewTextWriterMemory(xmlBufferPtr buf, int compression ATTRIBUTE_UNUSED) 2831d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 2841d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlTextWriterPtr ret; 2851d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlOutputBufferPtr out; 2861d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 2871d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/*::todo handle compression */ 288a44f234d3a0c94879136c5fa4b24f386148716adRob Richards out = xmlOutputBufferCreateBuffer(buf, NULL); 289a44f234d3a0c94879136c5fa4b24f386148716adRob Richards 2901d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (out == NULL) { 291dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY, 2921d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard "xmlNewTextWriterMemory : out of memory!\n"); 2931d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return NULL; 2941d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 2951d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 2961d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard ret = xmlNewTextWriter(out); 2971d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (ret == NULL) { 298dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY, 2991d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard "xmlNewTextWriterMemory : out of memory!\n"); 3001d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlOutputBufferClose(out); 3011d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return NULL; 3021d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 3031d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 3041d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return ret; 3051d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 3061d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 3071d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 3085841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * xmlNewTextWriterPushParser: 3095841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @ctxt: xmlParserCtxtPtr to hold the new XML document tree 3105841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @compression: compress the output? 3115841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 3125841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Create a new xmlNewTextWriter structure with @ctxt as output 313d5cc0f7f5185532120f6b8351e12ed7e81d4a28cDaniel Veillard * NOTE: the @ctxt context will be freed with the resulting writer 314d5cc0f7f5185532120f6b8351e12ed7e81d4a28cDaniel Veillard * (if the call succeeds). 3155841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * TODO: handle compression 3165841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 3175841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Returns the new xmlTextWriterPtr or NULL in case of error 3185841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard */ 3195841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel VeillardxmlTextWriterPtr 3201d913863130a17a638db69c2c50f89e5b0d4aae4Daniel VeillardxmlNewTextWriterPushParser(xmlParserCtxtPtr ctxt, 3211d913863130a17a638db69c2c50f89e5b0d4aae4Daniel Veillard int compression ATTRIBUTE_UNUSED) 3225841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard{ 3235841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard xmlTextWriterPtr ret; 3245841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard xmlOutputBufferPtr out; 3255841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard 326500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (ctxt == NULL) { 327dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(NULL, XML_ERR_INTERNAL_ERROR, 328500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard "xmlNewTextWriterPushParser : invalid context!\n"); 329500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return NULL; 330500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 331500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 3325841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard out = xmlOutputBufferCreateIO((xmlOutputWriteCallback) 3335841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard xmlTextWriterWriteDocCallback, 3345841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard (xmlOutputCloseCallback) 3355841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard xmlTextWriterCloseDocCallback, 3365841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard (void *) ctxt, NULL); 3375841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard if (out == NULL) { 338dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(NULL, XML_ERR_INTERNAL_ERROR, 3395841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard "xmlNewTextWriterPushParser : error at xmlOutputBufferCreateIO!\n"); 3405841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard return NULL; 3415841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard } 3425841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard 3435841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard ret = xmlNewTextWriter(out); 3445841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard if (ret == NULL) { 345dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(NULL, XML_ERR_INTERNAL_ERROR, 3465841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard "xmlNewTextWriterPushParser : error at xmlNewTextWriter!\n"); 3475841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard xmlOutputBufferClose(out); 3485841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard return NULL; 3495841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard } 3505841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard 35120c5e7878d462bfd93aa4eede7f1f5faabd377feDaniel Veillard ret->ctxt = ctxt; 35220c5e7878d462bfd93aa4eede7f1f5faabd377feDaniel Veillard 3535841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard return ret; 3545841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard} 3555841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard 3565841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard/** 3575841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * xmlNewTextWriterDoc: 3585841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @doc: address of a xmlDocPtr to hold the new XML document tree 3595841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @compression: compress the output? 3605841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 3615841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Create a new xmlNewTextWriter structure with @*doc as output 3625841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 3635841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Returns the new xmlTextWriterPtr or NULL in case of error 3645841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard */ 3655841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel VeillardxmlTextWriterPtr 3665841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel VeillardxmlNewTextWriterDoc(xmlDocPtr * doc, int compression) 3675841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard{ 3685841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard xmlTextWriterPtr ret; 3695841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard xmlSAXHandler saxHandler; 3705841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard xmlParserCtxtPtr ctxt; 3715841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard 3725841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard memset(&saxHandler, '\0', sizeof(saxHandler)); 3735841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard xmlSAX2InitDefaultSAXHandler(&saxHandler, 1); 3745841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard saxHandler.startDocument = xmlTextWriterStartDocumentCallback; 3755841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard saxHandler.startElement = xmlSAX2StartElement; 3765841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard saxHandler.endElement = xmlSAX2EndElement; 3775841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard 3785841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard ctxt = xmlCreatePushParserCtxt(&saxHandler, NULL, NULL, 0, NULL); 3795841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard if (ctxt == NULL) { 380dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(NULL, XML_ERR_INTERNAL_ERROR, 381eb0a0b2e31b6de7df2b7c354a914708c033f6f8fDaniel Veillard "xmlNewTextWriterDoc : error at xmlCreatePushParserCtxt!\n"); 3825841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard return NULL; 3835841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard } 38403a53c34db279cbe4a305d58969beb1f26ff3d19Daniel Veillard /* 38503a53c34db279cbe4a305d58969beb1f26ff3d19Daniel Veillard * For some reason this seems to completely break if node names 38603a53c34db279cbe4a305d58969beb1f26ff3d19Daniel Veillard * are interned. 38703a53c34db279cbe4a305d58969beb1f26ff3d19Daniel Veillard */ 38803a53c34db279cbe4a305d58969beb1f26ff3d19Daniel Veillard ctxt->dictNames = 0; 3895841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard 3901d913863130a17a638db69c2c50f89e5b0d4aae4Daniel Veillard ctxt->myDoc = xmlNewDoc(BAD_CAST XML_DEFAULT_VERSION); 3915841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard if (ctxt->myDoc == NULL) { 3925841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard xmlFreeParserCtxt(ctxt); 393dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(NULL, XML_ERR_INTERNAL_ERROR, 3945841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard "xmlNewTextWriterDoc : error at xmlNewDoc!\n"); 3955841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard return NULL; 3965841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard } 3975841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard 3985841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard ret = xmlNewTextWriterPushParser(ctxt, compression); 3995841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard if (ret == NULL) { 400eb0a0b2e31b6de7df2b7c354a914708c033f6f8fDaniel Veillard xmlFreeDoc(ctxt->myDoc); 401eb0a0b2e31b6de7df2b7c354a914708c033f6f8fDaniel Veillard xmlFreeParserCtxt(ctxt); 402dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(NULL, XML_ERR_INTERNAL_ERROR, 403eb0a0b2e31b6de7df2b7c354a914708c033f6f8fDaniel Veillard "xmlNewTextWriterDoc : error at xmlNewTextWriterPushParser!\n"); 4045841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard return NULL; 4055841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard } 4065841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard 407500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard xmlSetDocCompressMode(ctxt->myDoc, compression); 408500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 409a521d287516f2dc93a8fe540c5883ffc39cb5024Daniel Veillard if (doc != NULL) { 410500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard *doc = ctxt->myDoc; 411a521d287516f2dc93a8fe540c5883ffc39cb5024Daniel Veillard ret->no_doc_free = 1; 412a521d287516f2dc93a8fe540c5883ffc39cb5024Daniel Veillard } 4135841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard 4145841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard return ret; 4155841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard} 4165841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard 4175841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard/** 4185841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * xmlNewTextWriterTree: 4195841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @doc: xmlDocPtr 4205841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @node: xmlNodePtr or NULL for doc->children 4215841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @compression: compress the output? 4225841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 4235841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Create a new xmlNewTextWriter structure with @doc as output 4245841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * starting at @node 4255841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 4265841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Returns the new xmlTextWriterPtr or NULL in case of error 4275841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard */ 4285841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel VeillardxmlTextWriterPtr 4295841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel VeillardxmlNewTextWriterTree(xmlDocPtr doc, xmlNodePtr node, int compression) 4305841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard{ 4315841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard xmlTextWriterPtr ret; 4325841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard xmlSAXHandler saxHandler; 4335841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard xmlParserCtxtPtr ctxt; 4345841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard 4355841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard if (doc == NULL) { 436dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(NULL, XML_ERR_INTERNAL_ERROR, 437500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard "xmlNewTextWriterTree : invalid document tree!\n"); 4385841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard return NULL; 4395841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard } 4405841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard 4415841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard memset(&saxHandler, '\0', sizeof(saxHandler)); 4425841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard xmlSAX2InitDefaultSAXHandler(&saxHandler, 1); 4435841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard saxHandler.startDocument = xmlTextWriterStartDocumentCallback; 4445841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard saxHandler.startElement = xmlSAX2StartElement; 4455841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard saxHandler.endElement = xmlSAX2EndElement; 4465841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard 4475841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard ctxt = xmlCreatePushParserCtxt(&saxHandler, NULL, NULL, 0, NULL); 4485841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard if (ctxt == NULL) { 449dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(NULL, XML_ERR_INTERNAL_ERROR, 4505841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard "xmlNewTextWriterDoc : error at xmlCreatePushParserCtxt!\n"); 4515841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard return NULL; 4525841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard } 45303a53c34db279cbe4a305d58969beb1f26ff3d19Daniel Veillard /* 45403a53c34db279cbe4a305d58969beb1f26ff3d19Daniel Veillard * For some reason this seems to completely break if node names 45503a53c34db279cbe4a305d58969beb1f26ff3d19Daniel Veillard * are interned. 45603a53c34db279cbe4a305d58969beb1f26ff3d19Daniel Veillard */ 45703a53c34db279cbe4a305d58969beb1f26ff3d19Daniel Veillard ctxt->dictNames = 0; 4585841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard 4595841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard ret = xmlNewTextWriterPushParser(ctxt, compression); 4605841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard if (ret == NULL) { 461500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard xmlFreeParserCtxt(ctxt); 462dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(NULL, XML_ERR_INTERNAL_ERROR, 4635841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard "xmlNewTextWriterDoc : error at xmlNewTextWriterPushParser!\n"); 4645841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard return NULL; 4655841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard } 4665841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard 467500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard ctxt->myDoc = doc; 468500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard ctxt->node = node; 469a521d287516f2dc93a8fe540c5883ffc39cb5024Daniel Veillard ret->no_doc_free = 1; 470500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 4715841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard xmlSetDocCompressMode(doc, compression); 4725841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard 4735841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard return ret; 4745841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard} 4755841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard 4765841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard/** 4771d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlFreeTextWriter: 4781d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 4791d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 4801d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Deallocate all the resources associated to the writer 4811d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 4821d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardvoid 4831d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlFreeTextWriter(xmlTextWriterPtr writer) 4841d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 4851d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (writer == NULL) 4861d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return; 4871d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 4881d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (writer->out != NULL) 4891d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlOutputBufferClose(writer->out); 4901d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 4911d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (writer->nodes != NULL) 4921d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlListDelete(writer->nodes); 4931d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 4941d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (writer->nsstack != NULL) 4951d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlListDelete(writer->nsstack); 4961d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 497a521d287516f2dc93a8fe540c5883ffc39cb5024Daniel Veillard if (writer->ctxt != NULL) { 498a521d287516f2dc93a8fe540c5883ffc39cb5024Daniel Veillard if ((writer->ctxt->myDoc != NULL) && (writer->no_doc_free == 0)) { 499a521d287516f2dc93a8fe540c5883ffc39cb5024Daniel Veillard xmlFreeDoc(writer->ctxt->myDoc); 500a521d287516f2dc93a8fe540c5883ffc39cb5024Daniel Veillard writer->ctxt->myDoc = NULL; 501a521d287516f2dc93a8fe540c5883ffc39cb5024Daniel Veillard } 50220c5e7878d462bfd93aa4eede7f1f5faabd377feDaniel Veillard xmlFreeParserCtxt(writer->ctxt); 503a521d287516f2dc93a8fe540c5883ffc39cb5024Daniel Veillard } 50420c5e7878d462bfd93aa4eede7f1f5faabd377feDaniel Veillard 5059db68f0c14cb0509cd262749aa6ea2d15fbd6207Rob Richards if (writer->doc != NULL) 5069db68f0c14cb0509cd262749aa6ea2d15fbd6207Rob Richards xmlFreeDoc(writer->doc); 5079db68f0c14cb0509cd262749aa6ea2d15fbd6207Rob Richards 5084773df2a58be83e1b9b1b55840371acf37386820Daniel Veillard if (writer->ichar != NULL) 5094773df2a58be83e1b9b1b55840371acf37386820Daniel Veillard xmlFree(writer->ichar); 5101d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlFree(writer); 5111d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 5121d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 5131d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 5141d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterStartDocument: 5151d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 5161d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @version: the xml version ("1.0") or NULL for default ("1.0") 5171d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @encoding: the encoding or NULL for default 5181d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @standalone: "yes" or "no" or NULL for default 5191d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 5201d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Start a new xml document 5211d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 5221d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 5231d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 5241d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 5251d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterStartDocument(xmlTextWriterPtr writer, const char *version, 5261d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const char *encoding, const char *standalone) 5271d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 5281d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int count; 5291d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int sum; 5301d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlLinkPtr lk; 5311d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlCharEncodingHandlerPtr encoder; 5321d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 533500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if ((writer == NULL) || (writer->out == NULL)) { 534dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, 535500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard "xmlTextWriterStartDocument : invalid writer!\n"); 5361d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 537500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 5381d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 5391d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard lk = xmlListFront(writer->nodes); 5401d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if ((lk != NULL) && (xmlLinkGetData(lk) != NULL)) { 541dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, 542500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard "xmlTextWriterStartDocument : not allowed in this context!\n"); 5431d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 5441d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 5451d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 5461d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard encoder = NULL; 5471d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (encoding != NULL) { 5481d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard encoder = xmlFindCharEncodingHandler(encoding); 5491d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (encoder == NULL) { 550dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, 5511d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard "xmlTextWriterStartDocument : out of memory!\n"); 5521d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 5531d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 5541d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 5551d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 5561d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard writer->out->encoder = encoder; 5571d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (encoder != NULL) { 558caa1951d59833b4516c008829f9e5ce96fd37b03Daniel Veillard if (writer->out->conv == NULL) { 559dbf5411b21cbf5f0f72283a3ff4d4df38afa9990Daniel Veillard writer->out->conv = xmlBufCreateSize(4000); 560caa1951d59833b4516c008829f9e5ce96fd37b03Daniel Veillard } 561dbf5411b21cbf5f0f72283a3ff4d4df38afa9990Daniel Veillard xmlCharEncOutput(writer->out, 1); 5629db68f0c14cb0509cd262749aa6ea2d15fbd6207Rob Richards if ((writer->doc != NULL) && (writer->doc->encoding == NULL)) 5639db68f0c14cb0509cd262749aa6ea2d15fbd6207Rob Richards writer->doc->encoding = xmlStrdup((xmlChar *)writer->out->encoder->name); 5641d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } else 5651d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard writer->out->conv = NULL; 5661d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 5671d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum = 0; 5681d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, "<?xml version="); 5691d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 5701d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 5711d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 5721d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); 5731d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 5741d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 5751d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 5761d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (version != 0) 5771d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, version); 5781d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard else 5791d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, "1.0"); 5801d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 5811d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 5821d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 5831d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); 5841d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 5851d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 5861d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 5871d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (writer->out->encoder != 0) { 5881d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, " encoding="); 5891d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 5901d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 5911d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 5921d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); 5931d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 5941d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 5951d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 5961d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = 5971d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlOutputBufferWriteString(writer->out, 5981d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard writer->out->encoder->name); 5991d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 6001d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 6011d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 6021d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); 6031d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 6041d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 6051d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 6061d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 6071d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 6081d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (standalone != 0) { 6091d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, " standalone="); 6101d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 6111d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 6121d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 6131d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); 6141d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 6151d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 6161d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 6171d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, standalone); 6181d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 6191d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 6201d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 6211d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); 6221d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 6231d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 6241d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 6251d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 6261d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 6271d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, "?>\n"); 6281d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 6291d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 6301d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 6311d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 6321d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return sum; 6331d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 6341d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 6351d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 6361d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterEndDocument: 6371d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 6381d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 6393ff24115d2d95342ae1adc387560907d63f99ec7Daniel Veillard * End an xml document. All open elements are closed, and 6403ff24115d2d95342ae1adc387560907d63f99ec7Daniel Veillard * the content is flushed to the output. 6411d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 6423ff24115d2d95342ae1adc387560907d63f99ec7Daniel Veillard * Returns the bytes written or -1 in case of error 6431d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 6441d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 6451d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterEndDocument(xmlTextWriterPtr writer) 6461d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 6471d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int count; 6481d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int sum; 6491d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlLinkPtr lk; 6501d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlTextWriterStackEntry *p; 6511d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 652500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (writer == NULL) { 653dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, 654500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard "xmlTextWriterEndDocument : invalid writer!\n"); 6551d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 656500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 6571d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 6581d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum = 0; 6591d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard while ((lk = xmlListFront(writer->nodes)) != NULL) { 6601d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); 6611d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (p == 0) 6621d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard break; 6631d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard switch (p->state) { 6641d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard case XML_TEXTWRITER_NAME: 6651d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard case XML_TEXTWRITER_ATTRIBUTE: 6661d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard case XML_TEXTWRITER_TEXT: 6671d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlTextWriterEndElement(writer); 6681d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 6691d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 6701d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 6711d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard break; 6721d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard case XML_TEXTWRITER_PI: 6731d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard case XML_TEXTWRITER_PI_TEXT: 6741d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlTextWriterEndPI(writer); 6751d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 6761d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 6771d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 6781d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard break; 6791d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard case XML_TEXTWRITER_CDATA: 6801d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlTextWriterEndCDATA(writer); 6811d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 6821d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 6831d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 6841d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard break; 6851d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard case XML_TEXTWRITER_DTD: 686500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD_TEXT: 687500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD_ELEM: 688500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD_ELEM_TEXT: 689500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD_ATTL: 690500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD_ATTL_TEXT: 691500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD_ENTY: 692500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD_ENTY_TEXT: 693500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD_PENT: 6941d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlTextWriterEndDTD(writer); 6951d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 6961d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 6971d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 6981d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard break; 699ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard case XML_TEXTWRITER_COMMENT: 700ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard count = xmlTextWriterEndComment(writer); 701ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard if (count < 0) 702ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard return -1; 703ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard sum += count; 704ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard break; 7051d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard default: 706ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard break; 7071d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 7081d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 7091d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 7102cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard if (!writer->indent) { 711ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard count = xmlOutputBufferWriteString(writer->out, "\n"); 712ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard if (count < 0) 713ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard return -1; 714ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard sum += count; 715ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard } 7163ff24115d2d95342ae1adc387560907d63f99ec7Daniel Veillard 7173ff24115d2d95342ae1adc387560907d63f99ec7Daniel Veillard sum += xmlTextWriterFlush(writer); 7183ff24115d2d95342ae1adc387560907d63f99ec7Daniel Veillard 719ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard return sum; 720ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard} 721ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard 722ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard/** 723ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard * xmlTextWriterStartComment: 724ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard * @writer: the xmlTextWriterPtr 725ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard * 726ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard * Start an xml comment. 727ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard * 728ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 729ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard */ 730ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillardint 731ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel VeillardxmlTextWriterStartComment(xmlTextWriterPtr writer) 732ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard{ 733ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard int count; 734ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard int sum; 735ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard xmlLinkPtr lk; 736ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard xmlTextWriterStackEntry *p; 737ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard 738500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (writer == NULL) { 739dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, 740500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard "xmlTextWriterStartComment : invalid writer!\n"); 741ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard return -1; 742500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 743ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard 744ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard sum = 0; 745ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard lk = xmlListFront(writer->nodes); 746ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard if (lk != 0) { 747ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); 748ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard if (p != 0) { 749ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard switch (p->state) { 750ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard case XML_TEXTWRITER_TEXT: 751ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard case XML_TEXTWRITER_NONE: 752ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard break; 753ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard case XML_TEXTWRITER_NAME: 754b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards /* Output namespace declarations */ 755b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards count = xmlTextWriterOutputNSDecl(writer); 756b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards if (count < 0) 757b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards return -1; 758b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards sum += count; 759ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard count = xmlOutputBufferWriteString(writer->out, ">"); 760ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard if (count < 0) 761ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard return -1; 762ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard sum += count; 763500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (writer->indent) { 764500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = 765500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard xmlOutputBufferWriteString(writer->out, "\n"); 766500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (count < 0) 767500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 768500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum += count; 769500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 770ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard p->state = XML_TEXTWRITER_TEXT; 771ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard break; 772ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard default: 773ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard return -1; 774ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard } 775ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard } 776ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard } 777ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard 778ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard p = (xmlTextWriterStackEntry *) 779ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard xmlMalloc(sizeof(xmlTextWriterStackEntry)); 780ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard if (p == 0) { 781dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, 782ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard "xmlTextWriterStartElement : out of memory!\n"); 783ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard return -1; 784ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard } 785ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard 78675e389d4e0ccd998d288387051e66a8f0b2af1b0Daniel Veillard p->name = NULL; 787ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard p->state = XML_TEXTWRITER_COMMENT; 788ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard 789ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard xmlListPushFront(writer->nodes, p); 790ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard 791ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard if (writer->indent) { 792ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard count = xmlTextWriterWriteIndent(writer); 793ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard if (count < 0) 794ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard return -1; 795ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard sum += count; 796ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard } 797ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard 798ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard count = xmlOutputBufferWriteString(writer->out, "<!--"); 799ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard if (count < 0) 8005841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard return -1; 8015841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard sum += count; 802ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard 803ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard return sum; 804ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard} 805ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard 806ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard/** 807ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard * xmlTextWriterEndComment: 808ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard * @writer: the xmlTextWriterPtr 809ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard * 810ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard * End the current xml coment. 811ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard * 812ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 813ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard */ 814ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillardint 815ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel VeillardxmlTextWriterEndComment(xmlTextWriterPtr writer) 816ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard{ 817ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard int count; 818ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard int sum; 819ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard xmlLinkPtr lk; 820ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard xmlTextWriterStackEntry *p; 821ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard 822500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (writer == NULL) { 823dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, 824500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard "xmlTextWriterEndComment : invalid writer!\n"); 825ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard return -1; 826500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 827ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard 828ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard lk = xmlListFront(writer->nodes); 829500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (lk == 0) { 830dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, 831500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard "xmlTextWriterEndComment : not allowed in this context!\n"); 832ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard return -1; 833500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 834ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard 835ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); 836ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard if (p == 0) 837ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard return -1; 838ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard 839ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard sum = 0; 840ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard switch (p->state) { 841ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard case XML_TEXTWRITER_COMMENT: 842ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard count = xmlOutputBufferWriteString(writer->out, "-->"); 843ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard if (count < 0) 844ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard return -1; 845ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard sum += count; 846ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard break; 847ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard default: 848ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard return -1; 849ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard } 850ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard 851ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard if (writer->indent) { 852ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard count = xmlOutputBufferWriteString(writer->out, "\n"); 853ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard if (count < 0) 854ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard return -1; 855ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard sum += count; 8562cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard } 857ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard 858ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard xmlListPopFront(writer->nodes); 8591d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return sum; 8601d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 8611d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 8621d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 8631d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterWriteFormatComment: 8641d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 8651d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @format: format string (see printf) 8661d913863130a17a638db69c2c50f89e5b0d4aae4Daniel Veillard * @...: extra parameters for the format 8671d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 8681d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Write an xml comment. 8691d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 8701d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 8711d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 872ffa3c74933baa45bef5e0d7f15473c38a4c3f9e8Daniel Veillardint XMLCDECL 8731d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteFormatComment(xmlTextWriterPtr writer, 8741d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const char *format, ...) 8751d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 8761d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int rc; 8771d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_list ap; 8781d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 8791d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_start(ap, format); 8801d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 8811d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard rc = xmlTextWriterWriteVFormatComment(writer, format, ap); 8821d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 8831d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_end(ap); 8841d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return rc; 8851d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 8861d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 8871d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 8881d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterWriteVFormatComment: 8891d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 8901d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @format: format string (see printf) 8911d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @argptr: pointer to the first member of the variable argument list. 8921d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 8931d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Write an xml comment. 8941d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 8951d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 8961d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 8971d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 8981d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteVFormatComment(xmlTextWriterPtr writer, 8991d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const char *format, va_list argptr) 9001d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 9011d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int rc; 9021d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlChar *buf; 9031d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 904500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (writer == NULL) { 905dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, 906500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard "xmlTextWriterWriteVFormatComment : invalid writer!\n"); 9071d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 908500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 9091d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 9101d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard buf = xmlTextWriterVSprintf(format, argptr); 911cb0ae19174e7b26f9dbc1633e8aca3280db45a32Daniel Veillard if (buf == NULL) 912cb0ae19174e7b26f9dbc1633e8aca3280db45a32Daniel Veillard return -1; 9131d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 9141d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard rc = xmlTextWriterWriteComment(writer, buf); 9151d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 9161d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlFree(buf); 9171d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return rc; 9181d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 9191d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 9201d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 9211d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterWriteComment: 9221d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 9231d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @content: comment string 9241d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 9251d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Write an xml comment. 9261d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 9271d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 9281d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 9291d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 9301d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteComment(xmlTextWriterPtr writer, const xmlChar * content) 9311d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 9321d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int count; 9331d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int sum; 9341d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 9351d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum = 0; 936ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard count = xmlTextWriterStartComment(writer); 9371d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 9381d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 9391d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 940ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard count = xmlTextWriterWriteString(writer, content); 9411d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 9421d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 9431d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 944ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard count = xmlTextWriterEndComment(writer); 9451d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 9461d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 9471d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 9481d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 9491d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return sum; 9501d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 9511d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 9521d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 9531d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterStartElement: 9541d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 9551d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @name: element name 9561d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 9571d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Start an xml element. 9581d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 9591d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 9601d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 9611d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 9621d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterStartElement(xmlTextWriterPtr writer, const xmlChar * name) 9631d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 9641d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int count; 9651d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int sum; 9661d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlLinkPtr lk; 9671d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlTextWriterStackEntry *p; 9681d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 9691d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if ((writer == NULL) || (name == NULL) || (*name == '\0')) 9701d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 9711d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 9721d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum = 0; 9731d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard lk = xmlListFront(writer->nodes); 9741d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (lk != 0) { 9751d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); 9761d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (p != 0) { 9771d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard switch (p->state) { 9781d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard case XML_TEXTWRITER_PI: 9791d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard case XML_TEXTWRITER_PI_TEXT: 9801d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 9811d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard case XML_TEXTWRITER_NONE: 9821d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard break; 983614fdc13b7d073b6732fff5bb2baf16ef2ade18dDaniel Veillard case XML_TEXTWRITER_ATTRIBUTE: 984614fdc13b7d073b6732fff5bb2baf16ef2ade18dDaniel Veillard count = xmlTextWriterEndAttribute(writer); 985614fdc13b7d073b6732fff5bb2baf16ef2ade18dDaniel Veillard if (count < 0) 986614fdc13b7d073b6732fff5bb2baf16ef2ade18dDaniel Veillard return -1; 987614fdc13b7d073b6732fff5bb2baf16ef2ade18dDaniel Veillard sum += count; 988614fdc13b7d073b6732fff5bb2baf16ef2ade18dDaniel Veillard /* fallthrough */ 9891d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard case XML_TEXTWRITER_NAME: 990b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards /* Output namespace declarations */ 991b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards count = xmlTextWriterOutputNSDecl(writer); 992b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards if (count < 0) 993b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards return -1; 994b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards sum += count; 9951d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, ">"); 9961d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 9971d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 9981d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 999ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard if (writer->indent) 1000ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard count = 1001ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard xmlOutputBufferWriteString(writer->out, "\n"); 10021d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p->state = XML_TEXTWRITER_TEXT; 10031d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard break; 1004ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard default: 1005ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard break; 10061d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 10071d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 10081d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 10091d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 10101d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p = (xmlTextWriterStackEntry *) 10111d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlMalloc(sizeof(xmlTextWriterStackEntry)); 10121d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (p == 0) { 1013dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, 10141d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard "xmlTextWriterStartElement : out of memory!\n"); 10151d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 10161d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 10171d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 10181d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p->name = xmlStrdup(name); 10191d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (p->name == 0) { 1020dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, 10211d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard "xmlTextWriterStartElement : out of memory!\n"); 10221d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlFree(p); 10231d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 10241d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 10251d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p->state = XML_TEXTWRITER_NAME; 10261d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 10271d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlListPushFront(writer->nodes, p); 10281d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 1029ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard if (writer->indent) { 1030ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard count = xmlTextWriterWriteIndent(writer); 1031ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard sum += count; 10322cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard } 10332cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard 10341d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, "<"); 10351d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 10361d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 10371d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 10385841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard count = 10395841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard xmlOutputBufferWriteString(writer->out, (const char *) p->name); 10401d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 10411d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 10421d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 10431d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 10441d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return sum; 10451d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 10461d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 10471d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 10481d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterStartElementNS: 10491d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 10501d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @prefix: namespace prefix or NULL 10511d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @name: element local name 10521d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @namespaceURI: namespace URI or NULL 10531d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 10541d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Start an xml element with namespace support. 10551d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 10561d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 10571d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 10581d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 10591d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterStartElementNS(xmlTextWriterPtr writer, 10601d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * prefix, const xmlChar * name, 10611d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * namespaceURI) 10621d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 10631d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int count; 10641d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int sum; 10651d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlChar *buf; 10661d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 10671d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if ((writer == NULL) || (name == NULL) || (*name == '\0')) 10681d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 10691d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 107075e389d4e0ccd998d288387051e66a8f0b2af1b0Daniel Veillard buf = NULL; 10711d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (prefix != 0) { 10721d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard buf = xmlStrdup(prefix); 10731d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard buf = xmlStrcat(buf, BAD_CAST ":"); 10741d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 10751d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard buf = xmlStrcat(buf, name); 10761d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 10771d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum = 0; 10781d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlTextWriterStartElement(writer, buf); 10791d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlFree(buf); 10801d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 10811d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 10821d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 10831d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 10841d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (namespaceURI != 0) { 1085f8e3db0445a1bc8cfe3f77326b07ec161482caa2Daniel Veillard xmlTextWriterNsStackEntry *p = (xmlTextWriterNsStackEntry *) 1086b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards xmlMalloc(sizeof(xmlTextWriterNsStackEntry)); 1087b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards if (p == 0) { 1088f8e3db0445a1bc8cfe3f77326b07ec161482caa2Daniel Veillard xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, 1089b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards "xmlTextWriterStartElementNS : out of memory!\n"); 1090b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards return -1; 1091b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards } 1092b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards 10931d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard buf = xmlStrdup(BAD_CAST "xmlns"); 10941d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (prefix != 0) { 10951d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard buf = xmlStrcat(buf, BAD_CAST ":"); 10961d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard buf = xmlStrcat(buf, prefix); 10971d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 10981d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 1099b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards p->prefix = buf; 1100b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards p->uri = xmlStrdup(namespaceURI); 1101b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards if (p->uri == 0) { 1102b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, 1103b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards "xmlTextWriterStartElementNS : out of memory!\n"); 1104b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards xmlFree(p); 11051d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 1106b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards } 1107b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards p->elem = xmlListFront(writer->nodes); 1108b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards 1109b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards xmlListPushFront(writer->nsstack, p); 11101d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 11111d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 11121d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return sum; 11131d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 11141d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 11151d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 11161d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterEndElement: 11171d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 11181d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 11191d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * End the current xml element. 11201d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 11211d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 11221d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 11231d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 11241d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterEndElement(xmlTextWriterPtr writer) 11251d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 11261d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int count; 11271d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int sum; 11281d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlLinkPtr lk; 11291d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlTextWriterStackEntry *p; 11301d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 11311d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (writer == NULL) 11321d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 11331d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 11341d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard lk = xmlListFront(writer->nodes); 1135b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards if (lk == 0) { 1136b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards xmlListDelete(writer->nsstack); 1137b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards writer->nsstack = NULL; 11381d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 1139b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards } 11401d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 11411d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); 1142b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards if (p == 0) { 1143b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards xmlListDelete(writer->nsstack); 1144b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards writer->nsstack = NULL; 11451d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 1146b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards } 11471d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 11481d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum = 0; 11491d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard switch (p->state) { 11501d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard case XML_TEXTWRITER_ATTRIBUTE: 11511d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlTextWriterEndAttribute(writer); 1152b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards if (count < 0) { 1153b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards xmlListDelete(writer->nsstack); 1154b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards writer->nsstack = NULL; 11551d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 1156b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards } 11571d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 11581d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard /* fallthrough */ 11591d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard case XML_TEXTWRITER_NAME: 1160b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards /* Output namespace declarations */ 1161b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards count = xmlTextWriterOutputNSDecl(writer); 1162b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards if (count < 0) 1163b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards return -1; 1164b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards sum += count; 1165b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards 1166ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard if (writer->indent) /* next element needs indent */ 1167ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard writer->doindent = 1; 11681d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, "/>"); 11691d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 11701d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 11711d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 11721d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard break; 11731d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard case XML_TEXTWRITER_TEXT: 1174ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard if ((writer->indent) && (writer->doindent)) { 1175ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard count = xmlTextWriterWriteIndent(writer); 1176ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard sum += count; 1177ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard writer->doindent = 1; 1178ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard } else 1179ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard writer->doindent = 1; 11801d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, "</"); 11811d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 11821d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 11831d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 11841d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, 1185ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard (const char *) p->name); 11861d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 11871d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 11881d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 11891d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, ">"); 11901d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 11911d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 11921d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 11931d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard break; 11941d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard default: 11951d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 11961d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 11971d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 11982cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard if (writer->indent) { 1199ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard count = xmlOutputBufferWriteString(writer->out, "\n"); 1200ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard sum += count; 12012cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard } 12022cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard 12031d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlListPopFront(writer->nodes); 12041d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return sum; 12051d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 12061d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 12071d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 12081d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterFullEndElement: 12091d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 12101d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 12111d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * End the current xml element. Writes an end tag even if the element is empty 12121d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 12131d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 12141d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 12151d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 12161d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterFullEndElement(xmlTextWriterPtr writer) 12171d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 12181d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int count; 12191d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int sum; 12201d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlLinkPtr lk; 12211d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlTextWriterStackEntry *p; 12221d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 12231d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (writer == NULL) 12241d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 12251d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 12261d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard lk = xmlListFront(writer->nodes); 12271d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (lk == 0) 12281d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 12291d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 12301d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); 12311d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (p == 0) 12321d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 12331d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 12341d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum = 0; 12351d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard switch (p->state) { 12361d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard case XML_TEXTWRITER_ATTRIBUTE: 12371d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlTextWriterEndAttribute(writer); 12381d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 12391d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 12401d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 12411d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard /* fallthrough */ 12421d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard case XML_TEXTWRITER_NAME: 1243b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards /* Output namespace declarations */ 1244b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards count = xmlTextWriterOutputNSDecl(writer); 1245b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards if (count < 0) 1246b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards return -1; 1247b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards sum += count; 1248b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards 12491d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, ">"); 12501d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 12511d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 12521d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 12535a7d8bdf712ed1d0c429e292808c2b35d628acfaRob Richards if (writer->indent) 12545a7d8bdf712ed1d0c429e292808c2b35d628acfaRob Richards writer->doindent = 0; 12551d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard /* fallthrough */ 12561d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard case XML_TEXTWRITER_TEXT: 12575a7d8bdf712ed1d0c429e292808c2b35d628acfaRob Richards if ((writer->indent) && (writer->doindent)) { 12585a7d8bdf712ed1d0c429e292808c2b35d628acfaRob Richards count = xmlTextWriterWriteIndent(writer); 12595a7d8bdf712ed1d0c429e292808c2b35d628acfaRob Richards sum += count; 12605a7d8bdf712ed1d0c429e292808c2b35d628acfaRob Richards writer->doindent = 1; 12615a7d8bdf712ed1d0c429e292808c2b35d628acfaRob Richards } else 12625a7d8bdf712ed1d0c429e292808c2b35d628acfaRob Richards writer->doindent = 1; 12631d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, "</"); 12641d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 12651d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 12661d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 12671d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, 1268ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard (const char *) p->name); 12691d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 12701d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 12711d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 12721d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, ">"); 12731d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 12741d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 12751d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 12761d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard break; 12771d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard default: 12781d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 12791d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 12801d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 12817e26fb4b109b50ecf6752fe3d6f74d349432fac7Daniel Veillard if (writer->indent) { 12827e26fb4b109b50ecf6752fe3d6f74d349432fac7Daniel Veillard count = xmlOutputBufferWriteString(writer->out, "\n"); 12837e26fb4b109b50ecf6752fe3d6f74d349432fac7Daniel Veillard sum += count; 12847e26fb4b109b50ecf6752fe3d6f74d349432fac7Daniel Veillard } 12857e26fb4b109b50ecf6752fe3d6f74d349432fac7Daniel Veillard 12861d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlListPopFront(writer->nodes); 12871d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return sum; 12881d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 12891d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 12901d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 12911d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterWriteFormatRaw: 12921d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 12931d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @format: format string (see printf) 12941d913863130a17a638db69c2c50f89e5b0d4aae4Daniel Veillard * @...: extra parameters for the format 12951d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 12961d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Write a formatted raw xml text. 12971d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 12981d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 12991d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 1300ffa3c74933baa45bef5e0d7f15473c38a4c3f9e8Daniel Veillardint XMLCDECL 13011d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteFormatRaw(xmlTextWriterPtr writer, const char *format, 13021d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard ...) 13031d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 13041d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int rc; 13051d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_list ap; 13061d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 13071d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_start(ap, format); 13081d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 13091d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard rc = xmlTextWriterWriteVFormatRaw(writer, format, ap); 13101d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 13111d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_end(ap); 13121d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return rc; 13131d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 13141d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 13151d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 13161d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterWriteVFormatRaw: 13171d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 13181d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @format: format string (see printf) 13191d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @argptr: pointer to the first member of the variable argument list. 13201d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 13211d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Write a formatted raw xml text. 13221d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 13231d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 13241d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 13251d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 13261d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteVFormatRaw(xmlTextWriterPtr writer, const char *format, 13271d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_list argptr) 13281d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 13291d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int rc; 13301d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlChar *buf; 13311d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 13321d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (writer == NULL) 13331d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 13341d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 13351d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard buf = xmlTextWriterVSprintf(format, argptr); 1336cb0ae19174e7b26f9dbc1633e8aca3280db45a32Daniel Veillard if (buf == NULL) 1337cb0ae19174e7b26f9dbc1633e8aca3280db45a32Daniel Veillard return -1; 13381d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 13391d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard rc = xmlTextWriterWriteRaw(writer, buf); 13401d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 13411d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlFree(buf); 13421d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return rc; 13431d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 13441d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 13451d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 13461e90661bb817402f85103c3b9d3ce6ebab570f38Daniel Veillard * xmlTextWriterWriteRawLen: 13471d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 13481d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @content: text string 13491d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @len: length of the text string 13501d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 13511d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Write an xml text. 13521d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * TODO: what about entities and special chars?? 13531d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 13541d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 13551d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 13561d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 13571d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteRawLen(xmlTextWriterPtr writer, const xmlChar * content, 13581d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int len) 13591d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 13601d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int count; 13611d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int sum; 13621d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlLinkPtr lk; 13631d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlTextWriterStackEntry *p; 13641d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 1365500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (writer == NULL) { 1366dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, 1367500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard "xmlTextWriterWriteRawLen : invalid writer!\n"); 13681d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 1369500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 13701d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 1371e43cc574e49cd8173e157d8c31973f709a4cb7ecDaniel Veillard if ((content == NULL) || (len < 0)) { 1372dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, 1373500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard "xmlTextWriterWriteRawLen : invalid content!\n"); 1374500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 1375500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 13761d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 13771d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum = 0; 1378500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard lk = xmlListFront(writer->nodes); 1379500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (lk != 0) { 1380500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); 1381500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlTextWriterHandleStateDependencies(writer, p); 1382500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (count < 0) 13831d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 1384500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum += count; 13851d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 13861d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 1387500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (writer->indent) 1388500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard writer->doindent = 0; 1389500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 1390500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (content != NULL) { 1391500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = 1392500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard xmlOutputBufferWrite(writer->out, len, (const char *) content); 1393500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (count < 0) 1394500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 1395500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum += count; 1396500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 13971d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 13981d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return sum; 13991d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 14001d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 14011d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 14021d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterWriteRaw: 14031d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 14041d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @content: text string 14051d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 14061d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Write a raw xml text. 14071d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 14081d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 14091d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 14101d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 14111d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteRaw(xmlTextWriterPtr writer, const xmlChar * content) 14121d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 14131d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return xmlTextWriterWriteRawLen(writer, content, xmlStrlen(content)); 14141d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 14151d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 14161d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 14171d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterWriteFormatString: 14181d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 14191d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @format: format string (see printf) 14201d913863130a17a638db69c2c50f89e5b0d4aae4Daniel Veillard * @...: extra parameters for the format 14211d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 14221d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Write a formatted xml text. 14231d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 14241d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 14251d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 1426ffa3c74933baa45bef5e0d7f15473c38a4c3f9e8Daniel Veillardint XMLCDECL 14271d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteFormatString(xmlTextWriterPtr writer, const char *format, 14281d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard ...) 14291d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 14301d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int rc; 14311d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_list ap; 14321d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 1433e43cc574e49cd8173e157d8c31973f709a4cb7ecDaniel Veillard if ((writer == NULL) || (format == NULL)) 1434e43cc574e49cd8173e157d8c31973f709a4cb7ecDaniel Veillard return -1; 1435e43cc574e49cd8173e157d8c31973f709a4cb7ecDaniel Veillard 14361d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_start(ap, format); 14371d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 14381d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard rc = xmlTextWriterWriteVFormatString(writer, format, ap); 14391d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 14401d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_end(ap); 14411d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return rc; 14421d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 14431d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 14441d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 14451d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterWriteVFormatString: 14461d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 14471d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @format: format string (see printf) 14481d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @argptr: pointer to the first member of the variable argument list. 14491d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 14501d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Write a formatted xml text. 14511d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 14521d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 14531d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 14541d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 14551d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteVFormatString(xmlTextWriterPtr writer, 14561d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const char *format, va_list argptr) 14571d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 14581d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int rc; 14591d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlChar *buf; 14601d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 1461e43cc574e49cd8173e157d8c31973f709a4cb7ecDaniel Veillard if ((writer == NULL) || (format == NULL)) 14621d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 14631d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 14641d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard buf = xmlTextWriterVSprintf(format, argptr); 1465cb0ae19174e7b26f9dbc1633e8aca3280db45a32Daniel Veillard if (buf == NULL) 1466cb0ae19174e7b26f9dbc1633e8aca3280db45a32Daniel Veillard return -1; 14671d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 14681d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard rc = xmlTextWriterWriteString(writer, buf); 14691d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 14701d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlFree(buf); 14711d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return rc; 14721d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 14731d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 14741d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 14751d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterWriteString: 14761d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 14771d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @content: text string 14781d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 14791d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Write an xml text. 14801d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 14811d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 14821d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 14831d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 14841d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteString(xmlTextWriterPtr writer, const xmlChar * content) 14851d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 1486500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard int count; 14871d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int sum; 14881d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlLinkPtr lk; 14891d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlTextWriterStackEntry *p; 1490500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard xmlChar *buf; 14911d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 1492e43cc574e49cd8173e157d8c31973f709a4cb7ecDaniel Veillard if ((writer == NULL) || (content == NULL)) 14931d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 14941d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 14951d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum = 0; 1496500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard buf = (xmlChar *) content; 1497500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard lk = xmlListFront(writer->nodes); 1498500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (lk != 0) { 1499500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); 1500500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (p != 0) { 1501500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard switch (p->state) { 1502500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_NAME: 1503500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_TEXT: 150462040be3602d66ce983dcb22017af4ccc5d8276dDaniel Veillard#if 0 150562040be3602d66ce983dcb22017af4ccc5d8276dDaniel Veillard buf = NULL; 150662040be3602d66ce983dcb22017af4ccc5d8276dDaniel Veillard xmlOutputBufferWriteEscape(writer->out, content, NULL); 150762040be3602d66ce983dcb22017af4ccc5d8276dDaniel Veillard#endif 1508500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard buf = xmlEncodeSpecialChars(NULL, content); 1509500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard break; 1510500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_ATTRIBUTE: 1511500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard buf = NULL; 1512dbf5411b21cbf5f0f72283a3ff4d4df38afa9990Daniel Veillard xmlBufAttrSerializeTxtContent(writer->out->buffer, 1513dbf5411b21cbf5f0f72283a3ff4d4df38afa9990Daniel Veillard writer->doc, NULL, content); 1514500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard break; 151587640d5f14e7ce8b9844b886c765af0c56de5ca5William M. Brack default: 151687640d5f14e7ce8b9844b886c765af0c56de5ca5William M. Brack break; 1517500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 1518500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 15191d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 15201d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 1521500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (buf != NULL) { 1522500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlTextWriterWriteRaw(writer, buf); 1523751c9ec657e784bd941802d722632f19f17f17aeDaniel Veillard 1524500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (buf != content) /* buf was allocated by us, so free it */ 1525500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard xmlFree(buf); 1526eb0a0b2e31b6de7df2b7c354a914708c033f6f8fDaniel Veillard 1527eb0a0b2e31b6de7df2b7c354a914708c033f6f8fDaniel Veillard if (count < 0) 1528eb0a0b2e31b6de7df2b7c354a914708c033f6f8fDaniel Veillard return -1; 1529eb0a0b2e31b6de7df2b7c354a914708c033f6f8fDaniel Veillard sum += count; 1530a9c612c3ee115278fb8dc0cac1b2f2e362f0c052William M. Brack } 15311d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 15321d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return sum; 15331d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 15341d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 15351d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 15361d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlOutputBufferWriteBase64: 15371d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @out: the xmlOutputBufferPtr 15381d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @data: binary data 15391d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @len: the number of bytes to encode 15401d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 15411d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Write base64 encoded data to an xmlOutputBuffer. 15421d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Adapted from John Walker's base64.c (http://www.fourmilab.ch/). 15431d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 15441d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 15451d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 15461d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardstatic int 15471d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlOutputBufferWriteBase64(xmlOutputBufferPtr out, int len, 15481d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const unsigned char *data) 15491d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 15501d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard static unsigned char dtable[64] = 155147a318840053e03e60acb437f41e63366f44852cWilliam M. Brack {'A','B','C','D','E','F','G','H','I','J','K','L','M', 155247a318840053e03e60acb437f41e63366f44852cWilliam M. Brack 'N','O','P','Q','R','S','T','U','V','W','X','Y','Z', 155347a318840053e03e60acb437f41e63366f44852cWilliam M. Brack 'a','b','c','d','e','f','g','h','i','j','k','l','m', 155447a318840053e03e60acb437f41e63366f44852cWilliam M. Brack 'n','o','p','q','r','s','t','u','v','w','x','y','z', 155547a318840053e03e60acb437f41e63366f44852cWilliam M. Brack '0','1','2','3','4','5','6','7','8','9','+','/'}; 155647a318840053e03e60acb437f41e63366f44852cWilliam M. Brack 15571d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int i; 15581d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int linelen; 15591d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int count; 15601d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int sum; 15611d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 1562e43cc574e49cd8173e157d8c31973f709a4cb7ecDaniel Veillard if ((out == NULL) || (len < 0) || (data == NULL)) 1563e43cc574e49cd8173e157d8c31973f709a4cb7ecDaniel Veillard return(-1); 1564e43cc574e49cd8173e157d8c31973f709a4cb7ecDaniel Veillard 15651d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard linelen = 0; 15661d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum = 0; 15671d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 15681d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard i = 0; 15691d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard while (1) { 15701d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard unsigned char igroup[3]; 15711d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard unsigned char ogroup[4]; 15721d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int c; 15731d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int n; 15741d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 15751d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard igroup[0] = igroup[1] = igroup[2] = 0; 15761d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard for (n = 0; n < 3 && i < len; n++, i++) { 15771d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard c = data[i]; 15781d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard igroup[n] = (unsigned char) c; 15791d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 15801d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 15811d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (n > 0) { 15821d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard ogroup[0] = dtable[igroup[0] >> 2]; 15831d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard ogroup[1] = dtable[((igroup[0] & 3) << 4) | (igroup[1] >> 4)]; 15841d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard ogroup[2] = 15851d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard dtable[((igroup[1] & 0xF) << 2) | (igroup[2] >> 6)]; 15861d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard ogroup[3] = dtable[igroup[2] & 0x3F]; 15871d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 15881d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (n < 3) { 15891d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard ogroup[3] = '='; 15901d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (n < 2) { 15911d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard ogroup[2] = '='; 15921d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 15931d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 15941d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 15951d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (linelen >= B64LINELEN) { 15961d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWrite(out, 2, B64CRLF); 15971d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count == -1) 15981d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 15991d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 16001d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard linelen = 0; 16011d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 16021d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWrite(out, 4, (const char *) ogroup); 16031d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count == -1) 16041d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 16051d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 16061d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 16071d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard linelen += 4; 16081d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 1609929714b707a2d793cd78b033bfacb56fbaea3e36Daniel Veillard 1610929714b707a2d793cd78b033bfacb56fbaea3e36Daniel Veillard if (i >= len) 1611929714b707a2d793cd78b033bfacb56fbaea3e36Daniel Veillard break; 16121d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 16131d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 16141d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return sum; 16151d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 16161d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 16171d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 16181d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterWriteBase64: 16191d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 16201d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @data: binary data 16211d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @start: the position within the data of the first byte to encode 16221d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @len: the number of bytes to encode 16231d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 16241d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Write an base64 encoded xml text. 16251d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 16261d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 16271d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 16281d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 1629ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel VeillardxmlTextWriterWriteBase64(xmlTextWriterPtr writer, const char *data, 16301d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int start, int len) 16311d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 16321d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int count; 16331d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int sum; 16341d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlLinkPtr lk; 16351d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlTextWriterStackEntry *p; 16361d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 1637e43cc574e49cd8173e157d8c31973f709a4cb7ecDaniel Veillard if ((writer == NULL) || (data == NULL) || (start < 0) || (len < 0)) 16381d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 16391d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 16401d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum = 0; 1641500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard lk = xmlListFront(writer->nodes); 1642500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (lk != 0) { 1643500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); 1644500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (p != 0) { 1645500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlTextWriterHandleStateDependencies(writer, p); 16461d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 16471d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 16481d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 1649500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 16501d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 16511d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 1652ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard if (writer->indent) 1653ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard writer->doindent = 0; 1654ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard 16551d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = 16561d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlOutputBufferWriteBase64(writer->out, len, 16571d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard (unsigned char *) data + start); 16581d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 16591d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 16601d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 16611d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 16621d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return sum; 16631d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 16641d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 16651d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 16661d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlOutputBufferWriteBinHex: 16671d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @out: the xmlOutputBufferPtr 16681d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @data: binary data 16691d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @len: the number of bytes to encode 16701d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 16711d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Write hqx encoded data to an xmlOutputBuffer. 16721d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * ::todo 16731d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 1674f8e3db0445a1bc8cfe3f77326b07ec161482caa2Daniel Veillard * Returns the bytes written (may be 0 because of buffering) 167547a318840053e03e60acb437f41e63366f44852cWilliam M. Brack * or -1 in case of error 16761d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 16771d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardstatic int 1678ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel VeillardxmlOutputBufferWriteBinHex(xmlOutputBufferPtr out, 1679ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard int len, const unsigned char *data) 16801d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 1681ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard int count; 1682ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard int sum; 1683f8e3db0445a1bc8cfe3f77326b07ec161482caa2Daniel Veillard static char hex[16] = 1684f8e3db0445a1bc8cfe3f77326b07ec161482caa2Daniel Veillard {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; 1685ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard int i; 1686ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard 1687e43cc574e49cd8173e157d8c31973f709a4cb7ecDaniel Veillard if ((out == NULL) || (data == NULL) || (len < 0)) { 1688ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard return -1; 1689ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard } 1690ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard 1691ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard sum = 0; 1692ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard for (i = 0; i < len; i++) { 1693ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard count = 1694ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard xmlOutputBufferWrite(out, 1, 1695ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard (const char *) &hex[data[i] >> 4]); 1696ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard if (count == -1) 1697ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard return -1; 1698ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard sum += count; 1699ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard count = 1700ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard xmlOutputBufferWrite(out, 1, 1701ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard (const char *) &hex[data[i] & 0xF]); 1702ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard if (count == -1) 1703ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard return -1; 1704ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard sum += count; 1705ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard } 1706ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard 1707ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard return sum; 17081d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 17091d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 17101d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 17111d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterWriteBinHex: 17121d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 17131d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @data: binary data 17141d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @start: the position within the data of the first byte to encode 17151d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @len: the number of bytes to encode 17161d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 17171d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Write a BinHex encoded xml text. 17181d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 17191d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 17201d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 17211d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 1722ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel VeillardxmlTextWriterWriteBinHex(xmlTextWriterPtr writer, const char *data, 17231d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int start, int len) 17241d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 17251d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int count; 17261d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int sum; 17271d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlLinkPtr lk; 17281d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlTextWriterStackEntry *p; 17291d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 1730e43cc574e49cd8173e157d8c31973f709a4cb7ecDaniel Veillard if ((writer == NULL) || (data == NULL) || (start < 0) || (len < 0)) 17311d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 17321d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 17331d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum = 0; 1734500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard lk = xmlListFront(writer->nodes); 1735500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (lk != 0) { 1736500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); 1737500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (p != 0) { 1738500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlTextWriterHandleStateDependencies(writer, p); 17391d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 17401d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 17411d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 1742500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 17431d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 17441d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 1745ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard if (writer->indent) 1746ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard writer->doindent = 0; 1747ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard 17481d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = 17491d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlOutputBufferWriteBinHex(writer->out, len, 17501d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard (unsigned char *) data + start); 17511d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 17521d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 17531d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 17541d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 17551d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return sum; 17561d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 17571d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 17581d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 17591d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterStartAttribute: 17601d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 17611d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @name: element name 17621d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 17631d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Start an xml attribute. 17641d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 17651d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 17661d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 17671d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 17681d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterStartAttribute(xmlTextWriterPtr writer, const xmlChar * name) 17691d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 17701d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int count; 17711d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int sum; 17721d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlLinkPtr lk; 17731d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlTextWriterStackEntry *p; 17741d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 17751d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if ((writer == NULL) || (name == NULL) || (*name == '\0')) 17761d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 17771d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 17781d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum = 0; 17791d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard lk = xmlListFront(writer->nodes); 17801d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (lk == 0) 17811d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 17821d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 17831d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); 17841d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (p == 0) 17851d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 17861d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 17871d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard switch (p->state) { 17881d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard case XML_TEXTWRITER_ATTRIBUTE: 17891d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlTextWriterEndAttribute(writer); 17901d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 17911d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 17921d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 17931d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard /* fallthrough */ 17941d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard case XML_TEXTWRITER_NAME: 17951d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, " "); 17961d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 17971d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 17981d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 17995841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard count = 18005841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard xmlOutputBufferWriteString(writer->out, 18015841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard (const char *) name); 18021d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 18031d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 18041d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 18051d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, "="); 18061d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 18071d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 18081d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 18091d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); 18101d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 18111d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 18121d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 18131d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p->state = XML_TEXTWRITER_ATTRIBUTE; 18141d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard break; 18151d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard default: 18161d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 18171d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 18181d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 18191d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return sum; 18201d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 18211d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 18221d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 18231d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterStartAttributeNS: 18241d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 18251d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @prefix: namespace prefix or NULL 18261d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @name: element local name 18271d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @namespaceURI: namespace URI or NULL 18281d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 18291d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Start an xml attribute with namespace support. 18301d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 18311d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 18321d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 18331d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 18341d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterStartAttributeNS(xmlTextWriterPtr writer, 18351d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * prefix, const xmlChar * name, 18361d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * namespaceURI) 18371d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 18381d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int count; 18391d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int sum; 18401d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlChar *buf; 18411d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlTextWriterNsStackEntry *p; 18421d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 18431d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if ((writer == NULL) || (name == NULL) || (*name == '\0')) 18441d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 18451d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 1846b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards /* Handle namespace first in case of error */ 1847b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards if (namespaceURI != 0) { 1848b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards xmlTextWriterNsStackEntry nsentry, *curns; 1849b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards 1850b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards buf = xmlStrdup(BAD_CAST "xmlns"); 1851b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards if (prefix != 0) { 1852b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards buf = xmlStrcat(buf, BAD_CAST ":"); 1853b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards buf = xmlStrcat(buf, prefix); 1854b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards } 1855b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards 1856b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards nsentry.prefix = buf; 1857b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards nsentry.uri = (xmlChar *)namespaceURI; 1858b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards nsentry.elem = xmlListFront(writer->nodes); 1859b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards 1860f8e3db0445a1bc8cfe3f77326b07ec161482caa2Daniel Veillard curns = (xmlTextWriterNsStackEntry *)xmlListSearch(writer->nsstack, 1861b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards (void *)&nsentry); 1862b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards if ((curns != NULL)) { 1863b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards xmlFree(buf); 1864b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards if (xmlStrcmp(curns->uri, namespaceURI) == 0) { 1865b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards /* Namespace already defined on element skip */ 1866b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards buf = NULL; 1867b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards } else { 1868b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards /* Prefix mismatch so error out */ 1869b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards return -1; 1870b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards } 1871b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards } 1872b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards 1873b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards /* Do not add namespace decl to list - it is already there */ 1874b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards if (buf != NULL) { 1875b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards p = (xmlTextWriterNsStackEntry *) 1876b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards xmlMalloc(sizeof(xmlTextWriterNsStackEntry)); 1877b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards if (p == 0) { 1878b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, 1879b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards "xmlTextWriterStartAttributeNS : out of memory!\n"); 1880b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards return -1; 1881b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards } 1882b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards 1883b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards p->prefix = buf; 1884b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards p->uri = xmlStrdup(namespaceURI); 1885b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards if (p->uri == 0) { 1886b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, 1887b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards "xmlTextWriterStartAttributeNS : out of memory!\n"); 1888b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards xmlFree(p); 1889b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards return -1; 1890b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards } 1891b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards p->elem = xmlListFront(writer->nodes); 1892b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards 1893b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards xmlListPushFront(writer->nsstack, p); 1894b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards } 1895b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards } 1896b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards 189775e389d4e0ccd998d288387051e66a8f0b2af1b0Daniel Veillard buf = NULL; 18981d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (prefix != 0) { 18991d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard buf = xmlStrdup(prefix); 19001d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard buf = xmlStrcat(buf, BAD_CAST ":"); 19011d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 19021d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard buf = xmlStrcat(buf, name); 19031d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 19041d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum = 0; 19051d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlTextWriterStartAttribute(writer, buf); 19061d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlFree(buf); 19071d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 19081d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 19091d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 19101d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 19111d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return sum; 19121d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 19131d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 19141d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 19151d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterEndAttribute: 19161d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 19171d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 19181d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * End the current xml element. 19191d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 19201d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 19211d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 19221d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 19231d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterEndAttribute(xmlTextWriterPtr writer) 19241d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 19251d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int count; 19261d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int sum; 19271d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlLinkPtr lk; 19281d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlTextWriterStackEntry *p; 19291d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 19301d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (writer == NULL) 19311d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 19321d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 19331d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard lk = xmlListFront(writer->nodes); 19341d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (lk == 0) { 19351d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 19361d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 19371d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 19381d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); 19391d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (p == 0) { 19401d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 19411d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 19421d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 19431d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum = 0; 19441d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard switch (p->state) { 19451d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard case XML_TEXTWRITER_ATTRIBUTE: 19461d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p->state = XML_TEXTWRITER_NAME; 19471d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 19481d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); 19491d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) { 19501d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 19511d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 19521d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 19531d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard break; 19541d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard default: 19551d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 19561d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 19571d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 19581d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return sum; 19591d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 19601d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 19611d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 19621d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterWriteFormatAttribute: 19631d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 19641d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @name: attribute name 19651d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @format: format string (see printf) 19661d913863130a17a638db69c2c50f89e5b0d4aae4Daniel Veillard * @...: extra parameters for the format 19671d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 19681d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Write a formatted xml attribute. 19691d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 19701d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 19711d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 1972ffa3c74933baa45bef5e0d7f15473c38a4c3f9e8Daniel Veillardint XMLCDECL 19731d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteFormatAttribute(xmlTextWriterPtr writer, 19741d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * name, const char *format, 19751d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard ...) 19761d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 19771d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int rc; 19781d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_list ap; 19791d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 19801d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_start(ap, format); 19811d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 19821d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard rc = xmlTextWriterWriteVFormatAttribute(writer, name, format, ap); 19831d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 19841d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_end(ap); 19851d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return rc; 19861d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 19871d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 19881d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 19891d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterWriteVFormatAttribute: 19901d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 19911d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @name: attribute name 19921d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @format: format string (see printf) 19931d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @argptr: pointer to the first member of the variable argument list. 19941d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 19951d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Write a formatted xml attribute. 19961d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 19971d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 19981d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 19991d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 20001d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteVFormatAttribute(xmlTextWriterPtr writer, 20011d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * name, 20021d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const char *format, va_list argptr) 20031d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 20041d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int rc; 20051d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlChar *buf; 20061d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 20071d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (writer == NULL) 20081d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 20091d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 20101d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard buf = xmlTextWriterVSprintf(format, argptr); 2011cb0ae19174e7b26f9dbc1633e8aca3280db45a32Daniel Veillard if (buf == NULL) 2012cb0ae19174e7b26f9dbc1633e8aca3280db45a32Daniel Veillard return -1; 20131d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 20141d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard rc = xmlTextWriterWriteAttribute(writer, name, buf); 20151d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 20161d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlFree(buf); 20171d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return rc; 20181d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 20191d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 20201d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 20211d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterWriteAttribute: 20221d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 20231d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @name: attribute name 20241d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @content: attribute content 20251d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 20261d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Write an xml attribute. 20271d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 20281d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 20291d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 20301d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 20311d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteAttribute(xmlTextWriterPtr writer, const xmlChar * name, 20321d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * content) 20331d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 20341d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int count; 20351d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int sum; 20361d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 20371d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum = 0; 20381d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlTextWriterStartAttribute(writer, name); 20391d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 20401d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 20411d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 20421d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlTextWriterWriteString(writer, content); 20431d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 20441d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 20451d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 20461d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlTextWriterEndAttribute(writer); 20471d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 20481d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 20491d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 20501d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 20511d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return sum; 20521d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 20531d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 20541d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 20551d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterWriteFormatAttributeNS: 20561d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 20571d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @prefix: namespace prefix 20581d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @name: attribute local name 20591d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @namespaceURI: namespace URI 20601d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @format: format string (see printf) 20611d913863130a17a638db69c2c50f89e5b0d4aae4Daniel Veillard * @...: extra parameters for the format 20621d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 20631d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Write a formatted xml attribute.with namespace support 20641d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 20651d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 20661d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 2067ffa3c74933baa45bef5e0d7f15473c38a4c3f9e8Daniel Veillardint XMLCDECL 20681d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteFormatAttributeNS(xmlTextWriterPtr writer, 20691d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * prefix, 20701d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * name, 20711d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * namespaceURI, 20721d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const char *format, ...) 20731d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 20741d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int rc; 20751d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_list ap; 20761d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 20771d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_start(ap, format); 20781d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 20791d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard rc = xmlTextWriterWriteVFormatAttributeNS(writer, prefix, name, 20801d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard namespaceURI, format, ap); 20811d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 20821d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_end(ap); 20831d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return rc; 20841d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 20851d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 20861d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 20871d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterWriteVFormatAttributeNS: 20881d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 20891d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @prefix: namespace prefix 20901d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @name: attribute local name 20911d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @namespaceURI: namespace URI 20921d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @format: format string (see printf) 20931d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @argptr: pointer to the first member of the variable argument list. 20941d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 20951d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Write a formatted xml attribute.with namespace support 20961d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 20971d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 20981d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 20991d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 21001d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteVFormatAttributeNS(xmlTextWriterPtr writer, 21011d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * prefix, 21021d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * name, 21031d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * namespaceURI, 21041d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const char *format, va_list argptr) 21051d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 21061d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int rc; 21071d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlChar *buf; 21081d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 21091d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (writer == NULL) 21101d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 21111d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 21121d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard buf = xmlTextWriterVSprintf(format, argptr); 2113cb0ae19174e7b26f9dbc1633e8aca3280db45a32Daniel Veillard if (buf == NULL) 2114cb0ae19174e7b26f9dbc1633e8aca3280db45a32Daniel Veillard return -1; 21151d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 21161d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard rc = xmlTextWriterWriteAttributeNS(writer, prefix, name, namespaceURI, 21171d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard buf); 21181d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 21191d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlFree(buf); 21201d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return rc; 21211d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 21221d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 21231d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 21241d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterWriteAttributeNS: 21251d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 21261d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @prefix: namespace prefix 21271d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @name: attribute local name 21281d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @namespaceURI: namespace URI 21291d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @content: attribute content 21301d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 21311d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Write an xml attribute. 21321d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 21331d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 21341d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 21351d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 21361d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteAttributeNS(xmlTextWriterPtr writer, 21371d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * prefix, const xmlChar * name, 21381d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * namespaceURI, 21391d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * content) 21401d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 21411d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int count; 21421d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int sum; 21431d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 21441d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if ((writer == NULL) || (name == NULL) || (*name == '\0')) 21451d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 21461d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 21471d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum = 0; 2148b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards count = xmlTextWriterStartAttributeNS(writer, prefix, name, namespaceURI); 2149b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards if (count < 0) 2150b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards return -1; 2151b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards sum += count; 2152b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards count = xmlTextWriterWriteString(writer, content); 2153b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards if (count < 0) 2154b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards return -1; 2155b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards sum += count; 2156b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards count = xmlTextWriterEndAttribute(writer); 21571d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 21581d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 21591d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 21601d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 21611d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return sum; 21621d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 21631d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 21641d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 21651d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterWriteFormatElement: 21661d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 21671d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @name: element name 21681d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @format: format string (see printf) 21691d913863130a17a638db69c2c50f89e5b0d4aae4Daniel Veillard * @...: extra parameters for the format 21701d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 21711d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Write a formatted xml element. 21721d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 21731d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 21741d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 2175ffa3c74933baa45bef5e0d7f15473c38a4c3f9e8Daniel Veillardint XMLCDECL 21761d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteFormatElement(xmlTextWriterPtr writer, 21771d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * name, const char *format, 21781d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard ...) 21791d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 21801d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int rc; 21811d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_list ap; 21821d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 21831d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_start(ap, format); 21841d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 21851d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard rc = xmlTextWriterWriteVFormatElement(writer, name, format, ap); 21861d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 21871d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_end(ap); 21881d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return rc; 21891d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 21901d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 21911d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 21921d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterWriteVFormatElement: 21931d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 21941d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @name: element name 21951d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @format: format string (see printf) 21961d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @argptr: pointer to the first member of the variable argument list. 21971d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 21981d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Write a formatted xml element. 21991d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 22001d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 22011d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 22021d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 22031d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteVFormatElement(xmlTextWriterPtr writer, 22041d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * name, const char *format, 22051d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_list argptr) 22061d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 22071d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int rc; 22081d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlChar *buf; 22091d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 22101d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (writer == NULL) 22111d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 22121d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 22131d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard buf = xmlTextWriterVSprintf(format, argptr); 2214cb0ae19174e7b26f9dbc1633e8aca3280db45a32Daniel Veillard if (buf == NULL) 2215cb0ae19174e7b26f9dbc1633e8aca3280db45a32Daniel Veillard return -1; 22161d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 22171d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard rc = xmlTextWriterWriteElement(writer, name, buf); 22181d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 22191d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlFree(buf); 22201d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return rc; 22211d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 22221d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 22231d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 22241d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterWriteElement: 22251d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 22261d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @name: element name 22271d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @content: element content 22281d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 22291d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Write an xml element. 22301d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 22311d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 22321d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 22331d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 22341d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteElement(xmlTextWriterPtr writer, const xmlChar * name, 22351d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * content) 22361d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 22371d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int count; 22381d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int sum; 22391d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 22401d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum = 0; 22411d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlTextWriterStartElement(writer, name); 22421d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count == -1) 22431d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 22441d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 2245c9ecf45d1bf4ed9bdfed7f9733687a4df1daf897Daniel Veillard if (content != NULL) { 2246c9ecf45d1bf4ed9bdfed7f9733687a4df1daf897Daniel Veillard count = xmlTextWriterWriteString(writer, content); 2247c9ecf45d1bf4ed9bdfed7f9733687a4df1daf897Daniel Veillard if (count == -1) 2248c9ecf45d1bf4ed9bdfed7f9733687a4df1daf897Daniel Veillard return -1; 2249c9ecf45d1bf4ed9bdfed7f9733687a4df1daf897Daniel Veillard sum += count; 2250c9ecf45d1bf4ed9bdfed7f9733687a4df1daf897Daniel Veillard } 22511d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlTextWriterEndElement(writer); 22521d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count == -1) 22531d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 22541d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 22551d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 22561d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return sum; 22571d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 22581d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 22591d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 22601d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterWriteFormatElementNS: 22611d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 22621d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @prefix: namespace prefix 22631d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @name: element local name 22641d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @namespaceURI: namespace URI 22651d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @format: format string (see printf) 22661d913863130a17a638db69c2c50f89e5b0d4aae4Daniel Veillard * @...: extra parameters for the format 22671d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 22681d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Write a formatted xml element with namespace support. 22691d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 22701d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 22711d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 2272ffa3c74933baa45bef5e0d7f15473c38a4c3f9e8Daniel Veillardint XMLCDECL 22731d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteFormatElementNS(xmlTextWriterPtr writer, 22741d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * prefix, 22751d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * name, 22761d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * namespaceURI, 22771d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const char *format, ...) 22781d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 22791d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int rc; 22801d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_list ap; 22811d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 22821d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_start(ap, format); 22831d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 22841d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard rc = xmlTextWriterWriteVFormatElementNS(writer, prefix, name, 22851d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard namespaceURI, format, ap); 22861d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 22871d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_end(ap); 22881d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return rc; 22891d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 22901d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 22911d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 22921d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterWriteVFormatElementNS: 22931d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 22941d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @prefix: namespace prefix 22951d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @name: element local name 22961d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @namespaceURI: namespace URI 22971d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @format: format string (see printf) 22981d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @argptr: pointer to the first member of the variable argument list. 22991d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 23001d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Write a formatted xml element with namespace support. 23011d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 23021d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 23031d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 23041d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 23051d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteVFormatElementNS(xmlTextWriterPtr writer, 23061d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * prefix, 23071d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * name, 23081d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * namespaceURI, 23091d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const char *format, va_list argptr) 23101d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 23111d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int rc; 23121d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlChar *buf; 23131d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 23141d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (writer == NULL) 23151d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 23161d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 23171d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard buf = xmlTextWriterVSprintf(format, argptr); 2318cb0ae19174e7b26f9dbc1633e8aca3280db45a32Daniel Veillard if (buf == NULL) 2319cb0ae19174e7b26f9dbc1633e8aca3280db45a32Daniel Veillard return -1; 23201d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 23211d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard rc = xmlTextWriterWriteElementNS(writer, prefix, name, namespaceURI, 23221d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard buf); 23231d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 23241d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlFree(buf); 23251d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return rc; 23261d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 23271d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 23281d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 23291d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterWriteElementNS: 23301d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 23311d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @prefix: namespace prefix 23321d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @name: element local name 23331d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @namespaceURI: namespace URI 23341d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @content: element content 23351d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 23361d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Write an xml element with namespace support. 23371d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 23381d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 23391d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 23401d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 23411d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteElementNS(xmlTextWriterPtr writer, 23421d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * prefix, const xmlChar * name, 23431d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * namespaceURI, 23441d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * content) 23451d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 23461d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int count; 23471d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int sum; 23481d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 23491d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if ((writer == NULL) || (name == NULL) || (*name == '\0')) 23501d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 23511d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 23521d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum = 0; 23531d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = 23541d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlTextWriterStartElementNS(writer, prefix, name, namespaceURI); 23551d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 23561d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 23571d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 23581d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlTextWriterWriteString(writer, content); 23591d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count == -1) 23601d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 23611d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 23621d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlTextWriterEndElement(writer); 23631d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count == -1) 23641d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 23651d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 23661d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 23671d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return sum; 23681d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 23691d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 23701d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 23711d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterStartPI: 23721d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 23731d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @target: PI target 23741d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 23751d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Start an xml PI. 23761d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 23771d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 23781d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 23791d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 23801d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterStartPI(xmlTextWriterPtr writer, const xmlChar * target) 23811d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 23821d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int count; 23831d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int sum; 23841d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlLinkPtr lk; 23851d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlTextWriterStackEntry *p; 23861d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 23871d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if ((writer == NULL) || (target == NULL) || (*target == '\0')) 23881d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 23891d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 23901d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (xmlStrcasecmp(target, (const xmlChar *) "xml") == 0) { 2391dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, 23921d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard "xmlTextWriterStartPI : target name [Xx][Mm][Ll] is reserved for xml standardization!\n"); 23931d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 23941d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 23951d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 23961d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum = 0; 23971d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard lk = xmlListFront(writer->nodes); 23981d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (lk != 0) { 23991d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); 24001d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (p != 0) { 24011d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard switch (p->state) { 24021d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard case XML_TEXTWRITER_ATTRIBUTE: 24031d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlTextWriterEndAttribute(writer); 24041d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 24051d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 24061d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 24071d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard /* fallthrough */ 24081d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard case XML_TEXTWRITER_NAME: 2409b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards /* Output namespace declarations */ 2410b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards count = xmlTextWriterOutputNSDecl(writer); 2411b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards if (count < 0) 2412b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards return -1; 2413b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards sum += count; 24141d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, ">"); 24151d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 24161d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 24171d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 24181d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p->state = XML_TEXTWRITER_TEXT; 24191d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard break; 2420ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard case XML_TEXTWRITER_NONE: 2421ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard case XML_TEXTWRITER_TEXT: 2422ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard case XML_TEXTWRITER_DTD: 2423ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard break; 24241d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard case XML_TEXTWRITER_PI: 24251d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard case XML_TEXTWRITER_PI_TEXT: 2426dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, 24271d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard "xmlTextWriterStartPI : nested PI!\n"); 24281d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 24291d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard default: 24301d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 24311d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 24321d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 24331d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 24341d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 24351d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p = (xmlTextWriterStackEntry *) 24361d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlMalloc(sizeof(xmlTextWriterStackEntry)); 24371d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (p == 0) { 2438dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, 24391d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard "xmlTextWriterStartPI : out of memory!\n"); 24401d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 24411d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 24421d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 24431d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p->name = xmlStrdup(target); 24441d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (p->name == 0) { 2445dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, 24461d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard "xmlTextWriterStartPI : out of memory!\n"); 24471d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlFree(p); 24481d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 24491d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 24501d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p->state = XML_TEXTWRITER_PI; 24511d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 24521d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlListPushFront(writer->nodes, p); 24531d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 24541d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, "<?"); 24551d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 24561d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 24571d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 24585841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard count = 24595841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard xmlOutputBufferWriteString(writer->out, (const char *) p->name); 24601d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 24611d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 24621d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 24631d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 24641d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return sum; 24651d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 24661d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 24671d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 24681d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterEndPI: 24691d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 24701d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 24711d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * End the current xml PI. 24721d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 24731d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 24741d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 24751d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 24761d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterEndPI(xmlTextWriterPtr writer) 24771d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 24781d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int count; 24791d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int sum; 24801d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlLinkPtr lk; 24811d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlTextWriterStackEntry *p; 24821d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 24831d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (writer == NULL) 24841d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 24851d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 24861d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard lk = xmlListFront(writer->nodes); 24871d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (lk == 0) 24881d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return 0; 24891d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 24901d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); 24911d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (p == 0) 24921d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return 0; 24931d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 24941d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum = 0; 24951d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard switch (p->state) { 24961d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard case XML_TEXTWRITER_PI: 24971d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard case XML_TEXTWRITER_PI_TEXT: 24981d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, "?>"); 24991d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 25001d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 25011d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 25021d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard break; 25031d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard default: 25041d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 25051d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 25061d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 250702c1f23297ad794a9c83e408e477167b32b71e30Daniel Veillard if (writer->indent) { 250802c1f23297ad794a9c83e408e477167b32b71e30Daniel Veillard count = xmlOutputBufferWriteString(writer->out, "\n"); 2509f8e3db0445a1bc8cfe3f77326b07ec161482caa2Daniel Veillard if (count < 0) 2510f8e3db0445a1bc8cfe3f77326b07ec161482caa2Daniel Veillard return -1; 251102c1f23297ad794a9c83e408e477167b32b71e30Daniel Veillard sum += count; 251202c1f23297ad794a9c83e408e477167b32b71e30Daniel Veillard } 251302c1f23297ad794a9c83e408e477167b32b71e30Daniel Veillard 25141d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlListPopFront(writer->nodes); 25151d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return sum; 25161d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 25171d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 25181d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 25191d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterWriteFormatPI: 25201d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 25211d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @target: PI target 25221d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @format: format string (see printf) 25231d913863130a17a638db69c2c50f89e5b0d4aae4Daniel Veillard * @...: extra parameters for the format 25241d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 25251d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Write a formatted PI. 25261d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 25271d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 25281d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 2529ffa3c74933baa45bef5e0d7f15473c38a4c3f9e8Daniel Veillardint XMLCDECL 25301d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteFormatPI(xmlTextWriterPtr writer, const xmlChar * target, 25311d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const char *format, ...) 25321d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 25331d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int rc; 25341d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_list ap; 25351d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 25361d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_start(ap, format); 25371d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 25381d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard rc = xmlTextWriterWriteVFormatPI(writer, target, format, ap); 25391d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 25401d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_end(ap); 25411d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return rc; 25421d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 25431d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 25441d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 25451d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterWriteVFormatPI: 25461d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 25471d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @target: PI target 25481d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @format: format string (see printf) 25495841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @argptr: pointer to the first member of the variable argument list. 25501d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 25511d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Write a formatted xml PI. 25521d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 25531d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 25541d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 25551d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 25561d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteVFormatPI(xmlTextWriterPtr writer, 25571d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * target, const char *format, 25581d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_list argptr) 25591d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 25601d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int rc; 25611d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlChar *buf; 25621d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 25631d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (writer == NULL) 25641d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 25651d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 25661d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard buf = xmlTextWriterVSprintf(format, argptr); 2567cb0ae19174e7b26f9dbc1633e8aca3280db45a32Daniel Veillard if (buf == NULL) 2568cb0ae19174e7b26f9dbc1633e8aca3280db45a32Daniel Veillard return -1; 25691d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 25701d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard rc = xmlTextWriterWritePI(writer, target, buf); 25711d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 25721d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlFree(buf); 25731d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return rc; 25741d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 25751d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 25761d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 25771d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterWritePI: 25781d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 25791d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @target: PI target 25801d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @content: PI content 25811d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 25821d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Write an xml PI. 25831d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 25841d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 25851d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 25861d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 25871d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWritePI(xmlTextWriterPtr writer, const xmlChar * target, 25881d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * content) 25891d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 25901d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int count; 25911d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int sum; 25921d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 25931d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum = 0; 25941d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlTextWriterStartPI(writer, target); 25951d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count == -1) 25961d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 25971d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 25981d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (content != 0) { 25991d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlTextWriterWriteString(writer, content); 26001d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count == -1) 26011d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 26021d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 26031d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 26041d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlTextWriterEndPI(writer); 26051d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count == -1) 26061d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 26071d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 26081d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 26091d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return sum; 26101d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 26111d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 26121d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 26131d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterStartCDATA: 26141d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 26151d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 26161d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Start an xml CDATA section. 26171d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 26181d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 26191d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 26201d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 26211d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterStartCDATA(xmlTextWriterPtr writer) 26221d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 26231d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int count; 26241d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int sum; 26251d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlLinkPtr lk; 26261d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlTextWriterStackEntry *p; 26271d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 26281d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (writer == NULL) 26291d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 26301d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 26311d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum = 0; 26321d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard lk = xmlListFront(writer->nodes); 26331d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (lk != 0) { 26341d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); 26351d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (p != 0) { 26361d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard switch (p->state) { 26371d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard case XML_TEXTWRITER_NONE: 2638ccc476f177312548342c0a8cc921445024ebc7d2Daniel Veillard case XML_TEXTWRITER_TEXT: 26391d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard case XML_TEXTWRITER_PI: 26401d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard case XML_TEXTWRITER_PI_TEXT: 26411d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard break; 26421d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard case XML_TEXTWRITER_ATTRIBUTE: 26431d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlTextWriterEndAttribute(writer); 26441d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 26451d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 26461d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 26471d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard /* fallthrough */ 26481d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard case XML_TEXTWRITER_NAME: 2649b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards /* Output namespace declarations */ 2650b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards count = xmlTextWriterOutputNSDecl(writer); 2651b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards if (count < 0) 2652b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards return -1; 2653b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards sum += count; 26541d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, ">"); 26551d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 26561d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 26571d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 26581d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p->state = XML_TEXTWRITER_TEXT; 26591d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard break; 26601d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard case XML_TEXTWRITER_CDATA: 2661dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, 26621d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard "xmlTextWriterStartCDATA : CDATA not allowed in this context!\n"); 26631d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 26641d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard default: 26651d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 26661d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 26671d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 26681d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 26691d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 26701d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p = (xmlTextWriterStackEntry *) 26711d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlMalloc(sizeof(xmlTextWriterStackEntry)); 26721d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (p == 0) { 2673dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, 26741d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard "xmlTextWriterStartCDATA : out of memory!\n"); 26751d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 26761d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 26771d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 267875e389d4e0ccd998d288387051e66a8f0b2af1b0Daniel Veillard p->name = NULL; 26791d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p->state = XML_TEXTWRITER_CDATA; 26801d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 26811d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlListPushFront(writer->nodes, p); 26821d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 26831d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, "<![CDATA["); 26841d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 26851d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 26861d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 26871d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 26881d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return sum; 26891d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 26901d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 26911d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 26921d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterEndCDATA: 26931d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 26941d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 26951d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * End an xml CDATA section. 26961d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 26971d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 26981d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 26991d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 27001d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterEndCDATA(xmlTextWriterPtr writer) 27011d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 27021d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int count; 27031d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int sum; 27041d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlLinkPtr lk; 27051d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlTextWriterStackEntry *p; 27061d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 27071d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (writer == NULL) 27081d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 27091d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 27101d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard lk = xmlListFront(writer->nodes); 27111d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (lk == 0) 27121d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 27131d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 27141d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); 27151d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (p == 0) 27161d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 27171d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 27181d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum = 0; 27191d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard switch (p->state) { 27201d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard case XML_TEXTWRITER_CDATA: 27211d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, "]]>"); 27221d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 27231d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 27241d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 27251d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard break; 27261d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard default: 27271d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 27281d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 27291d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 27301d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlListPopFront(writer->nodes); 27311d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return sum; 27321d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 27331d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 27341d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 27351d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterWriteFormatCDATA: 27361d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 27371d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @format: format string (see printf) 27381d913863130a17a638db69c2c50f89e5b0d4aae4Daniel Veillard * @...: extra parameters for the format 27391d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 27401d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Write a formatted xml CDATA. 27411d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 27421d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 27431d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 2744ffa3c74933baa45bef5e0d7f15473c38a4c3f9e8Daniel Veillardint XMLCDECL 27451d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteFormatCDATA(xmlTextWriterPtr writer, const char *format, 27461d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard ...) 27471d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 27481d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int rc; 27491d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_list ap; 27501d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 27511d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_start(ap, format); 27521d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 27531d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard rc = xmlTextWriterWriteVFormatCDATA(writer, format, ap); 27541d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 27551d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_end(ap); 27561d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return rc; 27571d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 27581d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 27591d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 27601d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterWriteVFormatCDATA: 27611d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 27621d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @format: format string (see printf) 27635841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @argptr: pointer to the first member of the variable argument list. 27641d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 27651d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Write a formatted xml CDATA. 27661d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 27671d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 27681d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 27691d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 27701d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteVFormatCDATA(xmlTextWriterPtr writer, const char *format, 27711d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_list argptr) 27721d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 27731d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int rc; 27741d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlChar *buf; 27751d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 27761d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (writer == NULL) 27771d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 27781d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 27791d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard buf = xmlTextWriterVSprintf(format, argptr); 2780cb0ae19174e7b26f9dbc1633e8aca3280db45a32Daniel Veillard if (buf == NULL) 2781cb0ae19174e7b26f9dbc1633e8aca3280db45a32Daniel Veillard return -1; 27821d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 27831d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard rc = xmlTextWriterWriteCDATA(writer, buf); 27841d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 27851d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlFree(buf); 27861d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return rc; 27871d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 27881d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 27891d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 27901d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterWriteCDATA: 27911d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 27921d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @content: CDATA content 27931d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 27941d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Write an xml CDATA. 27951d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 27961d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 27971d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 27981d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 27991d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteCDATA(xmlTextWriterPtr writer, const xmlChar * content) 28001d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 28011d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int count; 28021d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int sum; 28031d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 28041d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum = 0; 28051d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlTextWriterStartCDATA(writer); 28061d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count == -1) 28071d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 28081d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 28091d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (content != 0) { 28101d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlTextWriterWriteString(writer, content); 28111d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count == -1) 28121d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 28131d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 28141d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 28151d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlTextWriterEndCDATA(writer); 28161d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count == -1) 28171d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 28181d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 28191d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 28201d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return sum; 28211d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 28221d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 28231d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 28241d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterStartDTD: 28251d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 28261d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @name: the name of the DTD 28271d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @pubid: the public identifier, which is an alternative to the system identifier 28281d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @sysid: the system identifier, which is the URI of the DTD 28291d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 28301d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Start an xml DTD. 28311d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 28321d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 28331d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 28341d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 28351d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterStartDTD(xmlTextWriterPtr writer, 28361d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * name, 28371d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * pubid, const xmlChar * sysid) 28381d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 28391d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int count; 28401d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int sum; 28411d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlLinkPtr lk; 28421d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlTextWriterStackEntry *p; 28431d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 28441d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (writer == NULL || name == NULL || *name == '\0') 28451d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 28461d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 28471d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum = 0; 28481d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard lk = xmlListFront(writer->nodes); 2849ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard if ((lk != NULL) && (xmlLinkGetData(lk) != NULL)) { 2850dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, 28511d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard "xmlTextWriterStartDTD : DTD allowed only in prolog!\n"); 28521d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 28531d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 28541d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 28551d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p = (xmlTextWriterStackEntry *) 28561d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlMalloc(sizeof(xmlTextWriterStackEntry)); 28571d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (p == 0) { 2858dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, 28591d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard "xmlTextWriterStartDTD : out of memory!\n"); 28601d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 28611d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 28621d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 28631d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p->name = xmlStrdup(name); 28641d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (p->name == 0) { 2865dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, 28661d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard "xmlTextWriterStartDTD : out of memory!\n"); 28671d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlFree(p); 28681d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 28691d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 28701d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p->state = XML_TEXTWRITER_DTD; 28711d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 28721d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlListPushFront(writer->nodes, p); 28731d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 28741d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, "<!DOCTYPE "); 28751d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 28761d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 28771d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 28781d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, (const char *) name); 28791d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 28801d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 28811d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 28821d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 28831d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (pubid != 0) { 28841d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (sysid == 0) { 2885dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, 28861d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard "xmlTextWriterStartDTD : system identifier needed!\n"); 28871d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 28881d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 28891d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 2890500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (writer->indent) 2891500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlOutputBufferWrite(writer->out, 1, "\n"); 2892500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard else 2893500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlOutputBufferWrite(writer->out, 1, " "); 2894500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (count < 0) 2895500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 2896500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum += count; 2897500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 2898500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlOutputBufferWriteString(writer->out, "PUBLIC "); 2899500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (count < 0) 2900500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 2901500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum += count; 2902500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 2903500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); 29041d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 29051d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 29061d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 29071d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 29085841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard count = 29095841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard xmlOutputBufferWriteString(writer->out, (const char *) pubid); 29101d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 29111d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 29121d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 29131d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 2914500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); 29151d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 29161d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 29171d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 29181d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 29191d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 29201d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (sysid != 0) { 29211d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (pubid == 0) { 2922500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (writer->indent) 2923500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlOutputBufferWrite(writer->out, 1, "\n"); 2924500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard else 2925500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlOutputBufferWrite(writer->out, 1, " "); 2926500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (count < 0) 2927500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 2928500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum += count; 2929500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlOutputBufferWriteString(writer->out, "SYSTEM "); 2930500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (count < 0) 2931500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 2932500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum += count; 2933ffe47feb2725849a6eb47299af87548fa0f52d4fRob Richards } else { 2934ffe47feb2725849a6eb47299af87548fa0f52d4fRob Richards if (writer->indent) 2935500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlOutputBufferWriteString(writer->out, "\n "); 2936ffe47feb2725849a6eb47299af87548fa0f52d4fRob Richards else 2937ffe47feb2725849a6eb47299af87548fa0f52d4fRob Richards count = xmlOutputBufferWrite(writer->out, 1, " "); 29381d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 29391d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 29401d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 29411d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 29421d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 2943500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); 29441d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 29451d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 29461d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 29471d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 29485841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard count = 29495841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard xmlOutputBufferWriteString(writer->out, (const char *) sysid); 29501d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 29511d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 29521d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 29531d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 2954500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); 29551d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 29561d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 29571d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 29581d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 29591d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 29601d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return sum; 29611d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 29621d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 29631d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 29641d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterEndDTD: 29651d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 29661d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 29671d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * End an xml DTD. 29681d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 29691d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 29701d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 29711d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 29721d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterEndDTD(xmlTextWriterPtr writer) 29731d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 2974500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard int loop; 29751d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int count; 29761d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int sum; 29771d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlLinkPtr lk; 29781d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlTextWriterStackEntry *p; 29791d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 29801d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (writer == NULL) 29811d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 29821d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 29831d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum = 0; 2984500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard loop = 1; 2985500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard while (loop) { 2986500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard lk = xmlListFront(writer->nodes); 2987500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (lk == NULL) 2988500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard break; 2989500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); 2990500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (p == 0) 2991500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard break; 2992500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard switch (p->state) { 2993500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD_TEXT: 2994500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlOutputBufferWriteString(writer->out, "]"); 2995500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (count < 0) 2996500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 2997500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum += count; 2998500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard /* fallthrough */ 2999500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD: 3000500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlOutputBufferWriteString(writer->out, ">"); 30011d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 3002500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (writer->indent) { 3003500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (count < 0) 3004500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 3005500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum += count; 3006500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlOutputBufferWriteString(writer->out, "\n"); 3007500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 30081d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 3009500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard xmlListPopFront(writer->nodes); 3010500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard break; 3011500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD_ELEM: 3012500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD_ELEM_TEXT: 3013500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlTextWriterEndDTDElement(writer); 3014500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard break; 3015500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD_ATTL: 3016500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD_ATTL_TEXT: 3017500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlTextWriterEndDTDAttlist(writer); 3018500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard break; 3019500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD_ENTY: 3020500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD_PENT: 3021500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD_ENTY_TEXT: 3022500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlTextWriterEndDTDEntity(writer); 3023500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard break; 3024500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_COMMENT: 3025500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlTextWriterEndComment(writer); 3026500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard break; 3027500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard default: 3028500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard loop = 0; 3029500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard continue; 3030500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 3031500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 3032500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (count < 0) 30331d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 3034500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum += count; 30351d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 30361d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 30371d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return sum; 30381d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 30391d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 30401d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 30411d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterWriteFormatDTD: 30421d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 30431d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @name: the name of the DTD 30441d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @pubid: the public identifier, which is an alternative to the system identifier 30451d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @sysid: the system identifier, which is the URI of the DTD 30461d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @format: format string (see printf) 30471d913863130a17a638db69c2c50f89e5b0d4aae4Daniel Veillard * @...: extra parameters for the format 30481d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 30491d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Write a DTD with a formatted markup declarations part. 30501d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 30511d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 30521d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 3053ffa3c74933baa45bef5e0d7f15473c38a4c3f9e8Daniel Veillardint XMLCDECL 30541d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteFormatDTD(xmlTextWriterPtr writer, 30551d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * name, 30561d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * pubid, 30571d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * sysid, const char *format, ...) 30581d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 30591d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int rc; 30601d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_list ap; 30611d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 30621d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_start(ap, format); 30631d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 30641d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard rc = xmlTextWriterWriteVFormatDTD(writer, name, pubid, sysid, format, 30651d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard ap); 30661d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 30671d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_end(ap); 30681d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return rc; 30691d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 30701d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 30711d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 30721d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterWriteVFormatDTD: 30731d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 30741d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @name: the name of the DTD 30751d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @pubid: the public identifier, which is an alternative to the system identifier 30761d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @sysid: the system identifier, which is the URI of the DTD 30771d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @format: format string (see printf) 30785841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @argptr: pointer to the first member of the variable argument list. 30791d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 30801d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Write a DTD with a formatted markup declarations part. 30811d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 30821d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 30831d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 30841d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 30851d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteVFormatDTD(xmlTextWriterPtr writer, 30861d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * name, 30871d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * pubid, 30881d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * sysid, 30891d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const char *format, va_list argptr) 30901d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 30911d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int rc; 30921d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlChar *buf; 30931d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 30941d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (writer == NULL) 30951d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 30961d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 30971d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard buf = xmlTextWriterVSprintf(format, argptr); 3098cb0ae19174e7b26f9dbc1633e8aca3280db45a32Daniel Veillard if (buf == NULL) 3099cb0ae19174e7b26f9dbc1633e8aca3280db45a32Daniel Veillard return -1; 31001d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 31011d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard rc = xmlTextWriterWriteDTD(writer, name, pubid, sysid, buf); 31021d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 31031d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlFree(buf); 31041d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return rc; 31051d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 31061d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 31071d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 31081d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterWriteDTD: 31091d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 31101d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @name: the name of the DTD 31111d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @pubid: the public identifier, which is an alternative to the system identifier 31121d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @sysid: the system identifier, which is the URI of the DTD 3113b1d531659b2bee47492ca1c319180116eaaf566eWilliam M. Brack * @subset: string content of the DTD 31141d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 31151d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Write a DTD. 31161d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 31171d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 31181d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 31191d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 31201d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteDTD(xmlTextWriterPtr writer, 31211d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * name, 31221d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * pubid, 31231d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * sysid, const xmlChar * subset) 31241d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 31251d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int count; 31261d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int sum; 31271d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 31281d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum = 0; 31291d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlTextWriterStartDTD(writer, name, pubid, sysid); 31301d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count == -1) 31311d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 31321d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 31331d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (subset != 0) { 31341d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlTextWriterWriteString(writer, subset); 31351d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count == -1) 31361d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 31371d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 31381d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 31391d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlTextWriterEndDTD(writer); 31401d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count == -1) 31411d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 31421d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 31431d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 31441d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return sum; 31451d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 31461d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 31475841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard/** 31485841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * xmlTextWriterStartDTDElement: 31495841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @writer: the xmlTextWriterPtr 31505841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @name: the name of the DTD element 31515841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 31525841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Start an xml DTD element. 31535841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 31545841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 31555841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard */ 31561d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 31571d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterStartDTDElement(xmlTextWriterPtr writer, const xmlChar * name) 31581d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 31591d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int count; 31601d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int sum; 31611d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlLinkPtr lk; 31621d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlTextWriterStackEntry *p; 31631d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 31641d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (writer == NULL || name == NULL || *name == '\0') 31651d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 31661d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 31671d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum = 0; 31681d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard lk = xmlListFront(writer->nodes); 31691d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (lk == 0) { 31701d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 31711d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 31721d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 31731d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); 3174500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (p != 0) { 3175500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard switch (p->state) { 3176500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD: 3177500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlOutputBufferWriteString(writer->out, " ["); 3178500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (count < 0) 3179500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 3180500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum += count; 3181500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (writer->indent) { 3182500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlOutputBufferWriteString(writer->out, "\n"); 3183500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (count < 0) 3184500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 3185500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum += count; 3186500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 3187500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard p->state = XML_TEXTWRITER_DTD_TEXT; 3188500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard /* fallthrough */ 3189500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD_TEXT: 3190500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_NONE: 3191500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard break; 3192500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard default: 31931d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 3194500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 31951d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 31961d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 31971d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p = (xmlTextWriterStackEntry *) 31981d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlMalloc(sizeof(xmlTextWriterStackEntry)); 31991d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (p == 0) { 3200dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, 32011d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard "xmlTextWriterStartDTDElement : out of memory!\n"); 32021d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 32031d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 32041d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 32051d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p->name = xmlStrdup(name); 32061d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (p->name == 0) { 3207dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, 32081d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard "xmlTextWriterStartDTDElement : out of memory!\n"); 32091d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlFree(p); 32101d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 32111d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 32121d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p->state = XML_TEXTWRITER_DTD_ELEM; 32131d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 32141d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlListPushFront(writer->nodes, p); 32151d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 3216500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (writer->indent) { 3217500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlTextWriterWriteIndent(writer); 3218500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (count < 0) 3219500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 3220500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum += count; 3221500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 3222500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 32231d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, "<!ELEMENT "); 32241d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 32251d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 32261d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 32271d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, (const char *) name); 32281d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 32291d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 32301d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 32311d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 32321d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return sum; 32331d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 32341d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 32355841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard/** 3236500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard * xmlTextWriterEndDTDElement: 3237500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard * @writer: the xmlTextWriterPtr 3238500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard * 3239500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard * End an xml DTD element. 3240500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard * 3241500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 3242500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard */ 3243500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillardint 3244500a1de533e2ea03f452844f537bb247b7e43af2Daniel VeillardxmlTextWriterEndDTDElement(xmlTextWriterPtr writer) 3245500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard{ 3246500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard int count; 3247500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard int sum; 3248500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard xmlLinkPtr lk; 3249500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard xmlTextWriterStackEntry *p; 3250500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 3251500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (writer == NULL) 3252500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 3253500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 3254500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum = 0; 3255500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard lk = xmlListFront(writer->nodes); 3256500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (lk == 0) 3257500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 3258500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 3259500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); 3260500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (p == 0) 3261500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 3262500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 3263500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard switch (p->state) { 3264500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD_ELEM: 3265500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD_ELEM_TEXT: 3266500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlOutputBufferWriteString(writer->out, ">"); 3267500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (count < 0) 3268500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 3269500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum += count; 3270500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard break; 3271500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard default: 3272500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 3273500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 3274500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 3275500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (writer->indent) { 3276500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlOutputBufferWriteString(writer->out, "\n"); 3277500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (count < 0) 3278500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 3279500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum += count; 3280500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 3281500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 3282500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard xmlListPopFront(writer->nodes); 3283500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return sum; 3284500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard} 3285500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 3286500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard/** 32875841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * xmlTextWriterWriteFormatDTDElement: 32885841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @writer: the xmlTextWriterPtr 32895841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @name: the name of the DTD element 32905841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @format: format string (see printf) 32911d913863130a17a638db69c2c50f89e5b0d4aae4Daniel Veillard * @...: extra parameters for the format 32925841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 32935841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Write a formatted DTD element. 32945841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 32955841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 32965841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard */ 3297ffa3c74933baa45bef5e0d7f15473c38a4c3f9e8Daniel Veillardint XMLCDECL 32981d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteFormatDTDElement(xmlTextWriterPtr writer, 32991d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * name, 33001d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const char *format, ...) 33011d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 33021d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int rc; 33031d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_list ap; 33041d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 33051d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_start(ap, format); 33061d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 33071d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard rc = xmlTextWriterWriteVFormatDTDElement(writer, name, format, ap); 33081d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 33091d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_end(ap); 33101d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return rc; 33111d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 33121d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 33135841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard/** 33145841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * xmlTextWriterWriteVFormatDTDElement: 33155841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @writer: the xmlTextWriterPtr 33165841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @name: the name of the DTD element 33175841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @format: format string (see printf) 33185841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @argptr: pointer to the first member of the variable argument list. 33195841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 33205841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Write a formatted DTD element. 33215841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 33225841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 33235841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard */ 33241d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 33251d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteVFormatDTDElement(xmlTextWriterPtr writer, 33261d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * name, 33271d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const char *format, va_list argptr) 33281d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 33291d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int rc; 33301d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlChar *buf; 33311d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 33321d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (writer == NULL) 33331d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 33341d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 33351d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard buf = xmlTextWriterVSprintf(format, argptr); 3336cb0ae19174e7b26f9dbc1633e8aca3280db45a32Daniel Veillard if (buf == NULL) 3337cb0ae19174e7b26f9dbc1633e8aca3280db45a32Daniel Veillard return -1; 33381d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 33391d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard rc = xmlTextWriterWriteDTDElement(writer, name, buf); 33401d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 33411d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlFree(buf); 33421d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return rc; 33431d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 33441d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 33455841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard/** 33465841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * xmlTextWriterWriteDTDElement: 33475841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @writer: the xmlTextWriterPtr 33485841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @name: the name of the DTD element 33495841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @content: content of the element 33505841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 33515841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Write a DTD element. 33525841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 33535841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 33545841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard */ 33551d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 33561d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteDTDElement(xmlTextWriterPtr writer, 33571d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * name, const xmlChar * content) 33581d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 33591d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int count; 33601d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int sum; 33611d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 33621d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (content == NULL) 33631d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 33641d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 33651d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum = 0; 33661d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlTextWriterStartDTDElement(writer, name); 33671d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count == -1) 33681d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 33691d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 33701d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 33711d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlTextWriterWriteString(writer, content); 33721d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count == -1) 33731d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 33741d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 33751d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 33761d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlTextWriterEndDTDElement(writer); 33771d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count == -1) 33781d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 33791d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 33801d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 33811d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return sum; 33821d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 33831d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 33845841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard/** 33855841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * xmlTextWriterStartDTDAttlist: 33865841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @writer: the xmlTextWriterPtr 33875841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @name: the name of the DTD ATTLIST 33885841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 33895841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Start an xml DTD ATTLIST. 33905841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 33915841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 33925841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard */ 33931d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 33941d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterStartDTDAttlist(xmlTextWriterPtr writer, const xmlChar * name) 33951d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 33961d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int count; 33971d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int sum; 33981d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlLinkPtr lk; 33991d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlTextWriterStackEntry *p; 34001d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 34011d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (writer == NULL || name == NULL || *name == '\0') 34021d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 34031d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 34041d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum = 0; 34051d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard lk = xmlListFront(writer->nodes); 34061d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (lk == 0) { 34071d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 34081d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 34091d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 34101d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); 3411500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (p != 0) { 3412500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard switch (p->state) { 3413500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD: 3414500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlOutputBufferWriteString(writer->out, " ["); 3415500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (count < 0) 3416500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 3417500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum += count; 3418500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (writer->indent) { 3419500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlOutputBufferWriteString(writer->out, "\n"); 3420500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (count < 0) 3421500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 3422500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum += count; 3423500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 3424500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard p->state = XML_TEXTWRITER_DTD_TEXT; 3425500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard /* fallthrough */ 3426500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD_TEXT: 3427500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_NONE: 3428500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard break; 3429500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard default: 34301d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 3431500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 34321d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 34331d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 34341d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p = (xmlTextWriterStackEntry *) 34351d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlMalloc(sizeof(xmlTextWriterStackEntry)); 34361d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (p == 0) { 3437dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, 34381d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard "xmlTextWriterStartDTDAttlist : out of memory!\n"); 34391d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 34401d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 34411d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 34421d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p->name = xmlStrdup(name); 34431d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (p->name == 0) { 3444dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, 34451d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard "xmlTextWriterStartDTDAttlist : out of memory!\n"); 34461d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlFree(p); 34471d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 34481d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 34491d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p->state = XML_TEXTWRITER_DTD_ATTL; 34501d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 34511d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlListPushFront(writer->nodes, p); 34521d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 3453500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (writer->indent) { 3454500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlTextWriterWriteIndent(writer); 3455500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (count < 0) 3456500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 3457500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum += count; 3458500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 3459500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 34601d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, "<!ATTLIST "); 34611d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 34621d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 34631d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 3464ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard count = xmlOutputBufferWriteString(writer->out, (const char *) name); 34651d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 34661d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 34671d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 34681d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 34691d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return sum; 34701d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 34711d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 34725841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard/** 3473500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard * xmlTextWriterEndDTDAttlist: 3474500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard * @writer: the xmlTextWriterPtr 3475500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard * 3476500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard * End an xml DTD attribute list. 3477500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard * 3478500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 3479500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard */ 3480500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillardint 3481500a1de533e2ea03f452844f537bb247b7e43af2Daniel VeillardxmlTextWriterEndDTDAttlist(xmlTextWriterPtr writer) 3482500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard{ 3483500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard int count; 3484500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard int sum; 3485500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard xmlLinkPtr lk; 3486500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard xmlTextWriterStackEntry *p; 3487500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 3488500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (writer == NULL) 3489500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 3490500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 3491500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum = 0; 3492500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard lk = xmlListFront(writer->nodes); 3493500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (lk == 0) 3494500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 3495500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 3496500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); 3497500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (p == 0) 3498500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 3499500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 3500500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard switch (p->state) { 3501500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD_ATTL: 3502500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD_ATTL_TEXT: 3503500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlOutputBufferWriteString(writer->out, ">"); 3504500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (count < 0) 3505500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 3506500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum += count; 3507500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard break; 3508500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard default: 3509500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 3510500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 3511500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 3512500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (writer->indent) { 3513500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlOutputBufferWriteString(writer->out, "\n"); 3514500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (count < 0) 3515500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 3516500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum += count; 3517500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 3518500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 3519500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard xmlListPopFront(writer->nodes); 3520500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return sum; 3521500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard} 3522500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 3523500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard/** 35245841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * xmlTextWriterWriteFormatDTDAttlist: 35255841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @writer: the xmlTextWriterPtr 35265841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @name: the name of the DTD ATTLIST 35275841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @format: format string (see printf) 35281d913863130a17a638db69c2c50f89e5b0d4aae4Daniel Veillard * @...: extra parameters for the format 35295841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 35305841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Write a formatted DTD ATTLIST. 35315841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 35325841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 35335841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard */ 3534ffa3c74933baa45bef5e0d7f15473c38a4c3f9e8Daniel Veillardint XMLCDECL 35351d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteFormatDTDAttlist(xmlTextWriterPtr writer, 35361d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * name, 35371d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const char *format, ...) 35381d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 35391d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int rc; 35401d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_list ap; 35411d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 35421d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_start(ap, format); 35431d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 35441d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard rc = xmlTextWriterWriteVFormatDTDAttlist(writer, name, format, ap); 35451d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 35461d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_end(ap); 35471d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return rc; 35481d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 35491d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 35505841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard/** 35515841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * xmlTextWriterWriteVFormatDTDAttlist: 35525841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @writer: the xmlTextWriterPtr 35535841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @name: the name of the DTD ATTLIST 35545841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @format: format string (see printf) 35555841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @argptr: pointer to the first member of the variable argument list. 35565841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 35575841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Write a formatted DTD ATTLIST. 35585841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 35595841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 35605841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard */ 35611d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 35621d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteVFormatDTDAttlist(xmlTextWriterPtr writer, 35631d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * name, 35641d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const char *format, va_list argptr) 35651d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 35661d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int rc; 35671d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlChar *buf; 35681d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 35691d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (writer == NULL) 35701d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 35711d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 35721d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard buf = xmlTextWriterVSprintf(format, argptr); 3573cb0ae19174e7b26f9dbc1633e8aca3280db45a32Daniel Veillard if (buf == NULL) 3574cb0ae19174e7b26f9dbc1633e8aca3280db45a32Daniel Veillard return -1; 35751d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 35761d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard rc = xmlTextWriterWriteDTDAttlist(writer, name, buf); 35771d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 35781d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlFree(buf); 35791d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return rc; 35801d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 35811d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 35825841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard/** 35835841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * xmlTextWriterWriteDTDAttlist: 35845841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @writer: the xmlTextWriterPtr 35855841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @name: the name of the DTD ATTLIST 35865841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @content: content of the ATTLIST 35875841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 35885841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Write a DTD ATTLIST. 35895841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 35905841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 35915841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard */ 35921d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 35931d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteDTDAttlist(xmlTextWriterPtr writer, 35941d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * name, const xmlChar * content) 35951d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 35961d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int count; 35971d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int sum; 35981d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 35991d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (content == NULL) 36001d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 36011d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 36021d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum = 0; 36031d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlTextWriterStartDTDAttlist(writer, name); 36041d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count == -1) 36051d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 36061d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 36071d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 36081d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlTextWriterWriteString(writer, content); 36091d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count == -1) 36101d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 36111d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 36121d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 36131d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlTextWriterEndDTDAttlist(writer); 36141d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count == -1) 36151d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 36161d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 36171d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 36181d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return sum; 36191d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 36201d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 36215841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard/** 36225841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * xmlTextWriterStartDTDEntity: 36235841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @writer: the xmlTextWriterPtr 36245841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @pe: TRUE if this is a parameter entity, FALSE if not 36255841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @name: the name of the DTD ATTLIST 36265841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 36275841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Start an xml DTD ATTLIST. 36285841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 36295841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 36305841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard */ 36311d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 36321d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterStartDTDEntity(xmlTextWriterPtr writer, 36331d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int pe, const xmlChar * name) 36341d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 36351d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int count; 36361d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int sum; 36371d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlLinkPtr lk; 36381d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlTextWriterStackEntry *p; 36391d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 36401d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (writer == NULL || name == NULL || *name == '\0') 36411d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 36421d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 36431d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum = 0; 36441d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard lk = xmlListFront(writer->nodes); 3645500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (lk != 0) { 36461d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 3647500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); 3648500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (p != 0) { 3649500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard switch (p->state) { 3650500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD: 3651500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlOutputBufferWriteString(writer->out, " ["); 3652500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (count < 0) 3653500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 3654500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum += count; 3655500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (writer->indent) { 3656500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = 3657500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard xmlOutputBufferWriteString(writer->out, "\n"); 3658500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (count < 0) 3659500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 3660500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum += count; 3661500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 3662500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard p->state = XML_TEXTWRITER_DTD_TEXT; 3663500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard /* fallthrough */ 3664500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD_TEXT: 3665500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_NONE: 3666500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard break; 3667500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard default: 3668500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 3669500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 3670500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 36711d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 36721d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 36731d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p = (xmlTextWriterStackEntry *) 36741d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlMalloc(sizeof(xmlTextWriterStackEntry)); 36751d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (p == 0) { 3676dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, 36771d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard "xmlTextWriterStartDTDElement : out of memory!\n"); 36781d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 36791d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 36801d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 36811d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p->name = xmlStrdup(name); 36821d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (p->name == 0) { 3683dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, 36841d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard "xmlTextWriterStartDTDElement : out of memory!\n"); 36851d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlFree(p); 36861d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 36871d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 3688500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 3689500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (pe != 0) 3690500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard p->state = XML_TEXTWRITER_DTD_PENT; 3691500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard else 3692500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard p->state = XML_TEXTWRITER_DTD_ENTY; 36931d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 36941d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlListPushFront(writer->nodes, p); 36951d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 3696500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (writer->indent) { 3697500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlTextWriterWriteIndent(writer); 3698500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (count < 0) 3699500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 3700500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum += count; 3701500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 3702500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 37031d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, "<!ENTITY "); 37041d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 37051d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 37061d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 37071d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 37081d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (pe != 0) { 3709500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlOutputBufferWriteString(writer->out, "% "); 37101d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 37111d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 37121d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 37131d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 37141d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 3715ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard count = xmlOutputBufferWriteString(writer->out, (const char *) name); 37161d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 37171d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 37181d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 37191d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 37201d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return sum; 37211d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 37221d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 37235841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard/** 3724500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard * xmlTextWriterEndDTDEntity: 3725500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard * @writer: the xmlTextWriterPtr 3726500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard * 3727500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard * End an xml DTD entity. 3728500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard * 3729500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 3730500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard */ 3731500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillardint 3732500a1de533e2ea03f452844f537bb247b7e43af2Daniel VeillardxmlTextWriterEndDTDEntity(xmlTextWriterPtr writer) 3733500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard{ 3734500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard int count; 3735500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard int sum; 3736500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard xmlLinkPtr lk; 3737500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard xmlTextWriterStackEntry *p; 3738500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 3739500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (writer == NULL) 3740500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 3741500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 3742500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum = 0; 3743500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard lk = xmlListFront(writer->nodes); 3744500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (lk == 0) 3745500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 3746500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 3747500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); 3748500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (p == 0) 3749500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 3750500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 3751500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard switch (p->state) { 3752500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD_ENTY_TEXT: 3753500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); 3754500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (count < 0) 3755500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 3756500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum += count; 3757500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD_ENTY: 3758500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD_PENT: 3759500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlOutputBufferWriteString(writer->out, ">"); 3760500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (count < 0) 3761500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 3762500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum += count; 3763500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard break; 3764500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard default: 3765500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 3766500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 3767500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 3768500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (writer->indent) { 3769500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlOutputBufferWriteString(writer->out, "\n"); 3770500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (count < 0) 3771500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 3772500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum += count; 3773500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 3774500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 3775500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard xmlListPopFront(writer->nodes); 3776500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return sum; 3777500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard} 3778500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 3779500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard/** 37805841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * xmlTextWriterWriteFormatDTDInternalEntity: 37815841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @writer: the xmlTextWriterPtr 37825841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @pe: TRUE if this is a parameter entity, FALSE if not 37835841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @name: the name of the DTD entity 37845841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @format: format string (see printf) 37851d913863130a17a638db69c2c50f89e5b0d4aae4Daniel Veillard * @...: extra parameters for the format 37865841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 37875841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Write a formatted DTD internal entity. 37885841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 37895841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 37905841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard */ 3791ffa3c74933baa45bef5e0d7f15473c38a4c3f9e8Daniel Veillardint XMLCDECL 37921d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteFormatDTDInternalEntity(xmlTextWriterPtr writer, 37931d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int pe, 37941d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * name, 37951d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const char *format, ...) 37961d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 37971d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int rc; 37981d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_list ap; 37991d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 38001d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_start(ap, format); 38011d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 38021d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard rc = xmlTextWriterWriteVFormatDTDInternalEntity(writer, pe, name, 38031d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard format, ap); 38041d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 38051d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_end(ap); 38061d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return rc; 38071d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 38081d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 38095841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard/** 38105841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * xmlTextWriterWriteVFormatDTDInternalEntity: 38115841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @writer: the xmlTextWriterPtr 38125841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @pe: TRUE if this is a parameter entity, FALSE if not 38135841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @name: the name of the DTD entity 38145841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @format: format string (see printf) 38155841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @argptr: pointer to the first member of the variable argument list. 38165841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 38175841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Write a formatted DTD internal entity. 38185841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 38195841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 38205841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard */ 38211d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 38221d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteVFormatDTDInternalEntity(xmlTextWriterPtr writer, 38231d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int pe, 38241d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * name, 38251d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const char *format, 38261d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard va_list argptr) 38271d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 38281d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int rc; 38291d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlChar *buf; 38301d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 38311d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (writer == NULL) 38321d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 38331d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 38341d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard buf = xmlTextWriterVSprintf(format, argptr); 3835cb0ae19174e7b26f9dbc1633e8aca3280db45a32Daniel Veillard if (buf == NULL) 3836cb0ae19174e7b26f9dbc1633e8aca3280db45a32Daniel Veillard return -1; 38371d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 38381d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard rc = xmlTextWriterWriteDTDInternalEntity(writer, pe, name, buf); 38391d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 38401d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlFree(buf); 38411d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return rc; 38421d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 38431d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 38445841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard/** 38455841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * xmlTextWriterWriteDTDEntity: 38465841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @writer: the xmlTextWriterPtr 38475841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @pe: TRUE if this is a parameter entity, FALSE if not 38485841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @name: the name of the DTD entity 38495841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @pubid: the public identifier, which is an alternative to the system identifier 38505841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @sysid: the system identifier, which is the URI of the DTD 38515841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @ndataid: the xml notation name. 38525841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @content: content of the entity 38535841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 38545841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Write a DTD entity. 38555841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 38565841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 38575841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard */ 38581d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 38591d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteDTDEntity(xmlTextWriterPtr writer, 38601d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int pe, 38611d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * name, 38621d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * pubid, 38631d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * sysid, 38641d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * ndataid, 38651d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * content) 38661d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 3867500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if ((content == NULL) && (pubid == NULL) && (sysid == NULL)) 38681d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 38691d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if ((pe != 0) && (ndataid != NULL)) 38701d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 38711d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 3872500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if ((pubid == NULL) && (sysid == NULL)) 38731d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return xmlTextWriterWriteDTDInternalEntity(writer, pe, name, 38741d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard content); 38751d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 38761d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return xmlTextWriterWriteDTDExternalEntity(writer, pe, name, pubid, 38771d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sysid, ndataid); 38781d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 38791d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 38805841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard/** 38815841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * xmlTextWriterWriteDTDInternalEntity: 38825841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @writer: the xmlTextWriterPtr 38835841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @pe: TRUE if this is a parameter entity, FALSE if not 38845841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @name: the name of the DTD entity 38855841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @content: content of the entity 38865841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 38875841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Write a DTD internal entity. 38885841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 38895841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 38905841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard */ 38911d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 38921d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteDTDInternalEntity(xmlTextWriterPtr writer, 38931d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int pe, 38941d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * name, 38951d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * content) 38961d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 38971d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int count; 38981d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int sum; 38991d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 39001d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if ((name == NULL) || (*name == '\0') || (content == NULL)) 39011d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 39021d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 39031d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum = 0; 39041d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlTextWriterStartDTDEntity(writer, pe, name); 39051d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count == -1) 39061d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 39071d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 39081d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 39091d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlTextWriterWriteString(writer, content); 39101d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count == -1) 39111d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 39121d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 39131d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 39141d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlTextWriterEndDTDEntity(writer); 39151d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count == -1) 39161d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 39171d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 39181d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 39191d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return sum; 39201d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 39211d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 39225841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard/** 39235841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * xmlTextWriterWriteDTDExternalEntity: 39245841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @writer: the xmlTextWriterPtr 39255841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @pe: TRUE if this is a parameter entity, FALSE if not 39265841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @name: the name of the DTD entity 39275841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @pubid: the public identifier, which is an alternative to the system identifier 39285841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @sysid: the system identifier, which is the URI of the DTD 39295841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @ndataid: the xml notation name. 39305841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 3931500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard * Write a DTD external entity. The entity must have been started with xmlTextWriterStartDTDEntity 39325841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 39335841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 39345841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard */ 39351d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 39361d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteDTDExternalEntity(xmlTextWriterPtr writer, 39371d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int pe, 39381d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * name, 39391d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * pubid, 39401d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * sysid, 39411d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * ndataid) 39421d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 39431d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int count; 39441d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int sum; 39451d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 3946500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (((pubid == NULL) && (sysid == NULL))) 39471d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 39481d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if ((pe != 0) && (ndataid != NULL)) 39491d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 39501d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 39511d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum = 0; 39521d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlTextWriterStartDTDEntity(writer, pe, name); 39531d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count == -1) 39541d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 39551d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 39561d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 3957500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = 3958500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard xmlTextWriterWriteDTDExternalEntityContents(writer, pubid, sysid, 3959500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard ndataid); 3960500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (count < 0) 3961500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 3962500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum += count; 3963500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 3964500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlTextWriterEndDTDEntity(writer); 3965500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (count == -1) 3966500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 3967500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum += count; 3968500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 3969500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return sum; 3970500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard} 3971500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 3972500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard/** 3973500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard * xmlTextWriterWriteDTDExternalEntityContents: 3974500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard * @writer: the xmlTextWriterPtr 3975500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard * @pubid: the public identifier, which is an alternative to the system identifier 3976500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard * @sysid: the system identifier, which is the URI of the DTD 3977500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard * @ndataid: the xml notation name. 3978500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard * 3979500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard * Write the contents of a DTD external entity. 3980500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard * 3981500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 3982500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard */ 3983500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillardint 3984500a1de533e2ea03f452844f537bb247b7e43af2Daniel VeillardxmlTextWriterWriteDTDExternalEntityContents(xmlTextWriterPtr writer, 3985500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard const xmlChar * pubid, 3986500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard const xmlChar * sysid, 3987500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard const xmlChar * ndataid) 3988500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard{ 3989500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard int count; 3990500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard int sum; 3991500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard xmlLinkPtr lk; 3992500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard xmlTextWriterStackEntry *p; 3993500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 3994500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (writer == NULL) { 3995dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, 3996500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard "xmlTextWriterWriteDTDExternalEntityContents: xmlTextWriterPtr invalid!\n"); 3997500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 3998500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 3999500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 4000500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum = 0; 4001500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard lk = xmlListFront(writer->nodes); 4002500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (lk == 0) { 4003dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, 4004500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard "xmlTextWriterWriteDTDExternalEntityContents: you must call xmlTextWriterStartDTDEntity before the call to this function!\n"); 4005500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 4006500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 4007500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 4008500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); 4009500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (p == 0) 4010500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 4011500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 4012500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard switch (p->state) { 4013500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD_ENTY: 4014500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard break; 4015500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD_PENT: 4016500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (ndataid != NULL) { 4017dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, 4018500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard "xmlTextWriterWriteDTDExternalEntityContents: notation not allowed with parameter entities!\n"); 4019500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 4020500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 4021500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard break; 4022500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard default: 4023dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, 4024500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard "xmlTextWriterWriteDTDExternalEntityContents: you must call xmlTextWriterStartDTDEntity before the call to this function!\n"); 4025500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 4026500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 4027500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 40281d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (pubid != 0) { 40291d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (sysid == 0) { 4030dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, 4031500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard "xmlTextWriterWriteDTDExternalEntityContents: system identifier needed!\n"); 40321d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 40331d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 40341d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 40351d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, " PUBLIC "); 40361d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 40371d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 40381d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 40391d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 40401d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); 40411d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 40421d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 40431d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 40441d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 40455841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard count = 40465841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard xmlOutputBufferWriteString(writer->out, (const char *) pubid); 40471d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 40481d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 40491d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 40501d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 40511d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); 40521d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 40531d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 40541d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 40551d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 40561d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 40571d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (sysid != 0) { 40581d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (pubid == 0) { 40591d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, " SYSTEM"); 40601d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 40611d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 40621d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 40631d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 40641d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 40651d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, " "); 40661d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 40671d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 40681d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 40691d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 40701d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); 40711d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 40721d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 40731d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 40741d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 40755841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard count = 40765841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard xmlOutputBufferWriteString(writer->out, (const char *) sysid); 40771d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 40781d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 40791d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 40801d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 40811d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); 40821d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 40831d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 40841d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 40851d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 40861d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 40871d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (ndataid != NULL) { 40881d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, " NDATA "); 40891d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 40901d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 40911d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 40921d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 40935841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard count = 40945841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard xmlOutputBufferWriteString(writer->out, 40955841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard (const char *) ndataid); 40961d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 40971d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 40981d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 40991d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 41001d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 41011d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return sum; 41021d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 41031d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 41045841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard/** 41055841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * xmlTextWriterWriteDTDNotation: 41065841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @writer: the xmlTextWriterPtr 41075841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @name: the name of the xml notation 41085841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @pubid: the public identifier, which is an alternative to the system identifier 41095841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @sysid: the system identifier, which is the URI of the DTD 41105841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 41115841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Write a DTD entity. 41125841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 41135841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 41145841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard */ 41151d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 41161d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterWriteDTDNotation(xmlTextWriterPtr writer, 41171d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * name, 41181d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard const xmlChar * pubid, const xmlChar * sysid) 41191d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 41201d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int count; 41211d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int sum; 41221d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlLinkPtr lk; 41231d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlTextWriterStackEntry *p; 41241d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 41251d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (writer == NULL || name == NULL || *name == '\0') 41261d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 41271d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 41281d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum = 0; 41291d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard lk = xmlListFront(writer->nodes); 41301d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (lk == 0) { 41311d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 41321d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 41331d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 41341d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); 4135500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (p != 0) { 4136500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard switch (p->state) { 4137500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD: 4138500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlOutputBufferWriteString(writer->out, " ["); 4139500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (count < 0) 4140500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 4141500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum += count; 4142500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (writer->indent) { 4143500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlOutputBufferWriteString(writer->out, "\n"); 4144500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (count < 0) 4145500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 4146500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum += count; 4147500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 4148500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard p->state = XML_TEXTWRITER_DTD_TEXT; 4149500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard /* fallthrough */ 4150500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD_TEXT: 4151500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard break; 4152500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard default: 41531d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 4154500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 4155500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 4156500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 4157500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (writer->indent) { 4158500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlTextWriterWriteIndent(writer); 4159500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (count < 0) 41601d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 4161500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum += count; 41621d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 41631d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 41641d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, "<!NOTATION "); 41651d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 41661d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 41671d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 41681d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, (const char *) name); 41691d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 41701d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 41711d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 41721d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 41731d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (pubid != 0) { 41741d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, " PUBLIC "); 41751d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 41761d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 41771d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 41781d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); 41791d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 41801d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 41811d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 41825841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard count = 41835841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard xmlOutputBufferWriteString(writer->out, (const char *) pubid); 41841d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 41851d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 41861d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 41871d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); 41881d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 41891d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 41901d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 41911d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 41921d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 41931d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (sysid != 0) { 41941d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (pubid == 0) { 41951d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, " SYSTEM"); 41961d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 41971d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 41981d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 41991d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 42001d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, " "); 42011d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 42021d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 42031d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 42041d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); 42051d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 42061d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 42071d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 42085841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard count = 42095841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard xmlOutputBufferWriteString(writer->out, (const char *) sysid); 42101d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 42111d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 42121d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 42131d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); 42141d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 42151d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 42161d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 42171d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 42181d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 42191d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferWriteString(writer->out, ">"); 42201d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (count < 0) 42211d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 42221d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard sum += count; 42231d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 42241d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return sum; 42251d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 42261d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 42271d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 42281d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterFlush: 42291d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @writer: the xmlTextWriterPtr 42301d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 42311d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Flush the output buffer. 42321d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 42331d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns the bytes written (may be 0 because of buffering) or -1 in case of error 42341d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 42351d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardint 42361d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterFlush(xmlTextWriterPtr writer) 42371d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 42381d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int count; 42391d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 42401d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (writer == NULL) 42411d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 42421d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 42431d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (writer->out == NULL) 42441d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = 0; 42451d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard else 42461d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard count = xmlOutputBufferFlush(writer->out); 42471d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 42481d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return count; 42491d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 42501d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 42511d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 42521d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * misc 42531d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 42541d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 42551d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 42561d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlFreeTextWriterStackEntry: 42571d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @lk: the xmlLinkPtr 42581d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 42591d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Free callback for the xmlList. 42601d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 42611d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardstatic void 42621d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlFreeTextWriterStackEntry(xmlLinkPtr lk) 42631d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 42641d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlTextWriterStackEntry *p; 42651d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 42661d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); 42671d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (p == 0) 42681d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return; 42691d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 42701d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (p->name != 0) 42711d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlFree(p->name); 42721d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlFree(p); 42731d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 42741d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 42751d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 42761d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlCmpTextWriterStackEntry: 42771d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @data0: the first data 42781d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @data1: the second data 42791d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 42801d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Compare callback for the xmlList. 42811d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 42821d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns -1, 0, 1 42831d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 42841d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardstatic int 42851d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlCmpTextWriterStackEntry(const void *data0, const void *data1) 42861d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 42871d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlTextWriterStackEntry *p0; 42881d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlTextWriterStackEntry *p1; 42891d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 42901d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (data0 == data1) 42911d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return 0; 42921d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 42931d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (data0 == 0) 42941d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 42951d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 42961d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (data1 == 0) 42971d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return 1; 42981d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 42991d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p0 = (xmlTextWriterStackEntry *) data0; 43001d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p1 = (xmlTextWriterStackEntry *) data1; 43011d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 43021d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return xmlStrcmp(p0->name, p1->name); 43031d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 43041d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 43051d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 43061d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * misc 43071d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 43081d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 43091d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 4310b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards * xmlTextWriterOutputNSDecl: 4311b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards * @writer: the xmlTextWriterPtr 4312b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards * 4313b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards * Output the current namespace declarations. 4314b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards */ 4315b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richardsstatic int 4316b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob RichardsxmlTextWriterOutputNSDecl(xmlTextWriterPtr writer) 4317b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards{ 4318b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards xmlLinkPtr lk; 4319b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards xmlTextWriterNsStackEntry *np; 4320b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards int count; 4321b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards int sum; 4322b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards 4323b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards sum = 0; 4324b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards while (!xmlListEmpty(writer->nsstack)) { 4325b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards xmlChar *namespaceURI = NULL; 4326b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards xmlChar *prefix = NULL; 4327b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards 4328b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards lk = xmlListFront(writer->nsstack); 4329b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards np = (xmlTextWriterNsStackEntry *) xmlLinkGetData(lk); 4330b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards 4331b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards if (np != 0) { 4332b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards namespaceURI = xmlStrdup(np->uri); 4333b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards prefix = xmlStrdup(np->prefix); 4334b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards } 4335b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards 4336b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards xmlListPopFront(writer->nsstack); 4337b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards 4338b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards if (np != 0) { 4339b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards count = xmlTextWriterWriteAttribute(writer, prefix, namespaceURI); 4340b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards xmlFree(namespaceURI); 4341b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards xmlFree(prefix); 4342b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards 4343b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards if (count < 0) { 4344b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards xmlListDelete(writer->nsstack); 4345b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards writer->nsstack = NULL; 4346b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards return -1; 4347b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards } 4348b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards sum += count; 4349b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards } 4350b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards } 4351b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards return sum; 4352b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards} 4353b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards 4354b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards/** 43551d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlFreeTextWriterNsStackEntry: 43561d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @lk: the xmlLinkPtr 43571d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 43581d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Free callback for the xmlList. 43591d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 43601d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardstatic void 43611d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlFreeTextWriterNsStackEntry(xmlLinkPtr lk) 43621d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 43631d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlTextWriterNsStackEntry *p; 43641d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 43651d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p = (xmlTextWriterNsStackEntry *) xmlLinkGetData(lk); 43661d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (p == 0) 43671d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return; 43681d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 43691d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (p->prefix != 0) 43701d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlFree(p->prefix); 43711d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (p->uri != 0) 43721d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlFree(p->uri); 43731d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 43741d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlFree(p); 43751d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 43761d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 43771d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 43781d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlCmpTextWriterNsStackEntry: 43791d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @data0: the first data 43801d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @data1: the second data 43811d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 43821d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Compare callback for the xmlList. 43831d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 43841d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns -1, 0, 1 43851d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 43861d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardstatic int 43871d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlCmpTextWriterNsStackEntry(const void *data0, const void *data1) 43881d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 43891d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlTextWriterNsStackEntry *p0; 43901d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlTextWriterNsStackEntry *p1; 43911d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int rc; 43921d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 43931d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (data0 == data1) 43941d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return 0; 43951d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 43961d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (data0 == 0) 43971d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return -1; 43981d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 43991d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (data1 == 0) 44001d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return 1; 44011d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 44021d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p0 = (xmlTextWriterNsStackEntry *) data0; 44031d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard p1 = (xmlTextWriterNsStackEntry *) data1; 44041d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 44051d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard rc = xmlStrcmp(p0->prefix, p1->prefix); 44061d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 4407b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards if ((rc != 0) || (p0->elem != p1->elem)) 4408b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards rc = -1; 44091d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 44101d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return rc; 44111d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 44121d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 44131d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard/** 44145841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * xmlTextWriterWriteDocCallback: 44155841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @context: the xmlBufferPtr 44165841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @str: the data to write 44175841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @len: the length of the data 44185841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 44195841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Write callback for the xmlOutputBuffer with target xmlBuffer 44205841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 44215841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Returns -1, 0, 1 44225841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard */ 44235841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillardstatic int 44245841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel VeillardxmlTextWriterWriteDocCallback(void *context, const xmlChar * str, int len) 44255841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard{ 44265841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) context; 44275841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard int rc; 44285841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard 44291d913863130a17a638db69c2c50f89e5b0d4aae4Daniel Veillard if ((rc = xmlParseChunk(ctxt, (const char *) str, len, 0)) != 0) { 4430dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsgInt(NULL, XML_ERR_INTERNAL_ERROR, 44315841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard "xmlTextWriterWriteDocCallback : XML error %d !\n", 44325841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard rc); 44335841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard return -1; 44345841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard } 44355841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard 44365841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard return len; 44375841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard} 44385841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard 44395841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard/** 44405841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * xmlTextWriterCloseDocCallback: 44415841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @context: the xmlBufferPtr 44425841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 44435841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Close callback for the xmlOutputBuffer with target xmlBuffer 44445841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 44455841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * Returns -1, 0, 1 44465841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard */ 44475841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillardstatic int 44485841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel VeillardxmlTextWriterCloseDocCallback(void *context) 44495841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard{ 44505841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) context; 44515841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard int rc; 44525841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard 44535841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard if ((rc = xmlParseChunk(ctxt, NULL, 0, 1)) != 0) { 4454dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsgInt(NULL, XML_ERR_INTERNAL_ERROR, 44555841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard "xmlTextWriterWriteDocCallback : XML error %d !\n", 44565841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard rc); 44575841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard return -1; 44585841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard } 44595841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard 44605841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard return 0; 44615841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard} 44625841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard 44635841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard/** 44641d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * xmlTextWriterVSprintf: 44651d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @format: see printf 44661d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * @argptr: pointer to the first member of the variable argument list. 44671d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 44681d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Utility function for formatted output 44691d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * 44701d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard * Returns a new xmlChar buffer with the data or NULL on error. This buffer must be freed. 44711d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard */ 44721d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillardstatic xmlChar * 44731d211e227372e5ed75a69fbad5f50d185d0af936Daniel VeillardxmlTextWriterVSprintf(const char *format, va_list argptr) 44741d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard{ 44751d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int size; 44761d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard int count; 44771d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlChar *buf; 4478f4caa5e698007f195d1c99b0ef1e06add0c852f4William M. Brack va_list locarg; 44791d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 44801d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard size = BUFSIZ; 44811d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard buf = (xmlChar *) xmlMalloc(size); 44821d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (buf == NULL) { 4483dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY, 44841d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard "xmlTextWriterVSprintf : out of memory!\n"); 44851d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return NULL; 44861d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 44871d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 4488f4caa5e698007f195d1c99b0ef1e06add0c852f4William M. Brack VA_COPY(locarg, argptr); 4489f4caa5e698007f195d1c99b0ef1e06add0c852f4William M. Brack while (((count = vsnprintf((char *) buf, size, format, locarg)) < 0) 44901d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard || (count == size - 1) || (count == size) || (count > size)) { 4491f4caa5e698007f195d1c99b0ef1e06add0c852f4William M. Brack va_end(locarg); 44921d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard xmlFree(buf); 44931d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard size += BUFSIZ; 44941d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard buf = (xmlChar *) xmlMalloc(size); 44951d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard if (buf == NULL) { 4496dd6d300896cfeacbacf7c5bceb5bec2f36790efeDaniel Veillard xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY, 44971d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard "xmlTextWriterVSprintf : out of memory!\n"); 44981d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return NULL; 44991d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 4500f4caa5e698007f195d1c99b0ef1e06add0c852f4William M. Brack VA_COPY(locarg, argptr); 45011d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard } 4502f4caa5e698007f195d1c99b0ef1e06add0c852f4William M. Brack va_end(locarg); 45031d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 45041d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard return buf; 45051d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard} 45061d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard 45075841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard/** 45085841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * xmlTextWriterStartDocumentCallback: 45095841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * @ctx: the user data (XML parser context) 45105841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * 45115841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard * called at the start of document processing. 45125841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard */ 45135841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillardstatic void 45145841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel VeillardxmlTextWriterStartDocumentCallback(void *ctx) 45155841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard{ 45165841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; 45175841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard xmlDocPtr doc; 45185841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard 45195841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard if (ctxt->html) { 45205841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard#ifdef LIBXML_HTML_ENABLED 45215841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard if (ctxt->myDoc == NULL) 45225841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard ctxt->myDoc = htmlNewDocNoDtD(NULL, NULL); 45235841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard if (ctxt->myDoc == NULL) { 45245841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) 45255841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard ctxt->sax->error(ctxt->userData, 45265841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard "SAX.startDocument(): out of memory\n"); 45275841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard ctxt->errNo = XML_ERR_NO_MEMORY; 45285841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard ctxt->instate = XML_PARSER_EOF; 45295841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard ctxt->disableSAX = 1; 45305841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard return; 45315841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard } 45325841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard#else 4533d0cf7f6eea7331cc398c232d7879e4239d989e14Daniel Veillard xmlWriterErrMsg(NULL, XML_ERR_INTERNAL_ERROR, 45345841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard "libxml2 built without HTML support\n"); 45355841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard ctxt->errNo = XML_ERR_INTERNAL_ERROR; 45365841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard ctxt->instate = XML_PARSER_EOF; 45375841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard ctxt->disableSAX = 1; 45385841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard return; 45395841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard#endif 45405841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard } else { 45415841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard doc = ctxt->myDoc; 45425841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard if (doc == NULL) 45435841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard doc = ctxt->myDoc = xmlNewDoc(ctxt->version); 45445841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard if (doc != NULL) { 45455841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard if (doc->children == NULL) { 45465841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard if (ctxt->encoding != NULL) 45475841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard doc->encoding = xmlStrdup(ctxt->encoding); 45485841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard else 45495841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard doc->encoding = NULL; 45505841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard doc->standalone = ctxt->standalone; 45515841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard } 45525841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard } else { 45535841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) 45545841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard ctxt->sax->error(ctxt->userData, 45555841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard "SAX.startDocument(): out of memory\n"); 45565841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard ctxt->errNo = XML_ERR_NO_MEMORY; 45575841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard ctxt->instate = XML_PARSER_EOF; 45585841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard ctxt->disableSAX = 1; 45595841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard return; 45605841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard } 45615841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard } 45625841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard if ((ctxt->myDoc != NULL) && (ctxt->myDoc->URL == NULL) && 45635841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard (ctxt->input != NULL) && (ctxt->input->filename != NULL)) { 45645841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard ctxt->myDoc->URL = 45655841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard xmlCanonicPath((const xmlChar *) ctxt->input->filename); 45665841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard if (ctxt->myDoc->URL == NULL) 45675841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard ctxt->myDoc->URL = 45685841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard xmlStrdup((const xmlChar *) ctxt->input->filename); 45695841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard } 45705841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard} 45715841f0e0a44fdfaf6cee6511fbb71d5a76e3ff23Daniel Veillard 45722cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard/** 45732cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard * xmlTextWriterSetIndent: 45742cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard * @writer: the xmlTextWriterPtr 45752cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard * @indent: do indentation? 45762cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard * 45772cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard * Set indentation output. indent = 0 do not indentation. indent > 0 do indentation. 45782cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard * 45792cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard * Returns -1 on error or 0 otherwise. 45802cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard */ 45812cca446b86a77022d5b847b106544aede7207dbcDaniel Veillardint 4582ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel VeillardxmlTextWriterSetIndent(xmlTextWriterPtr writer, int indent) 45832cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard{ 4584e43cc574e49cd8173e157d8c31973f709a4cb7ecDaniel Veillard if ((writer == NULL) || (indent < 0)) 4585ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard return -1; 45862cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard 4587ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard writer->indent = indent; 4588ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard writer->doindent = 1; 45892cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard 4590ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard return 0; 45912cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard} 45922cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard 45932cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard/** 45942cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard * xmlTextWriterSetIndentString: 45952cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard * @writer: the xmlTextWriterPtr 45962cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard * @str: the xmlChar string 45972cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard * 45982cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard * Set string indentation. 45992cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard * 46002cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard * Returns -1 on error or 0 otherwise. 46012cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard */ 46022cca446b86a77022d5b847b106544aede7207dbcDaniel Veillardint 4603ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel VeillardxmlTextWriterSetIndentString(xmlTextWriterPtr writer, const xmlChar * str) 46042cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard{ 4605e43cc574e49cd8173e157d8c31973f709a4cb7ecDaniel Veillard if ((writer == NULL) || (!str)) 4606ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard return -1; 46072cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard 4608ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard if (writer->ichar != NULL) 4609ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard xmlFree(writer->ichar); 4610ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard writer->ichar = xmlStrdup(str); 4611ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard 4612ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard if (!writer->ichar) 4613ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard return -1; 4614ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard else 4615ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard return 0; 46162cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard} 46172cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard 46182cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard/** 4619429d3a0aae2eda7ba9451f9c9f8523c61cc0368bCsaba Raduly * xmlTextWriterSetQuoteChar: 4620429d3a0aae2eda7ba9451f9c9f8523c61cc0368bCsaba Raduly * @writer: the xmlTextWriterPtr 4621429d3a0aae2eda7ba9451f9c9f8523c61cc0368bCsaba Raduly * @quotechar: the quote character 4622429d3a0aae2eda7ba9451f9c9f8523c61cc0368bCsaba Raduly * 4623429d3a0aae2eda7ba9451f9c9f8523c61cc0368bCsaba Raduly * Set the character used for quoting attributes. 4624429d3a0aae2eda7ba9451f9c9f8523c61cc0368bCsaba Raduly * 4625429d3a0aae2eda7ba9451f9c9f8523c61cc0368bCsaba Raduly * Returns -1 on error or 0 otherwise. 4626429d3a0aae2eda7ba9451f9c9f8523c61cc0368bCsaba Raduly */ 4627429d3a0aae2eda7ba9451f9c9f8523c61cc0368bCsaba Radulyint 4628429d3a0aae2eda7ba9451f9c9f8523c61cc0368bCsaba RadulyxmlTextWriterSetQuoteChar(xmlTextWriterPtr writer, xmlChar quotechar) 4629429d3a0aae2eda7ba9451f9c9f8523c61cc0368bCsaba Raduly{ 4630429d3a0aae2eda7ba9451f9c9f8523c61cc0368bCsaba Raduly if ((writer == NULL) || ((quotechar != '\'') && (quotechar != '"'))) 4631429d3a0aae2eda7ba9451f9c9f8523c61cc0368bCsaba Raduly return -1; 4632429d3a0aae2eda7ba9451f9c9f8523c61cc0368bCsaba Raduly 4633429d3a0aae2eda7ba9451f9c9f8523c61cc0368bCsaba Raduly writer->qchar = quotechar; 4634429d3a0aae2eda7ba9451f9c9f8523c61cc0368bCsaba Raduly 4635429d3a0aae2eda7ba9451f9c9f8523c61cc0368bCsaba Raduly return 0; 4636429d3a0aae2eda7ba9451f9c9f8523c61cc0368bCsaba Raduly} 4637429d3a0aae2eda7ba9451f9c9f8523c61cc0368bCsaba Raduly 4638429d3a0aae2eda7ba9451f9c9f8523c61cc0368bCsaba Raduly/** 46392cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard * xmlTextWriterWriteIndent: 46402cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard * @writer: the xmlTextWriterPtr 46412cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard * 46422cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard * Write indent string. 46432cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard * 46442cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard * Returns -1 on error or the number of strings written. 4645ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard */ 46462cca446b86a77022d5b847b106544aede7207dbcDaniel Veillardstatic int 4647ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel VeillardxmlTextWriterWriteIndent(xmlTextWriterPtr writer) 4648ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard{ 4649ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard int lksize; 4650ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard int i; 4651ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard int ret; 4652ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard 4653ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard lksize = xmlListSize(writer->nodes); 4654ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard if (lksize < 1) 4655ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard return (-1); /* list is empty */ 4656ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard for (i = 0; i < (lksize - 1); i++) { 4657ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard ret = xmlOutputBufferWriteString(writer->out, 4658ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard (const char *) writer->ichar); 4659ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard if (ret == -1) 4660ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard return (-1); 4661ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard } 4662ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard 4663ab69f366d0a9178749f2f0a888f6167605bf78f2Daniel Veillard return (lksize - 1); 46642cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard} 46652cca446b86a77022d5b847b106544aede7207dbcDaniel Veillard 4666500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard/** 4667500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard * xmlTextWriterHandleStateDependencies: 4668500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard * @writer: the xmlTextWriterPtr 4669500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard * @p: the xmlTextWriterStackEntry 4670500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard * 4671500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard * Write state dependent strings. 4672500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard * 4673500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard * Returns -1 on error or the number of characters written. 4674500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard */ 4675500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillardstatic int 4676500a1de533e2ea03f452844f537bb247b7e43af2Daniel VeillardxmlTextWriterHandleStateDependencies(xmlTextWriterPtr writer, 4677500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard xmlTextWriterStackEntry * p) 4678500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard{ 4679500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard int count; 4680500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard int sum; 4681500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard char extra[3]; 4682500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 4683500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (writer == NULL) 4684500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 4685500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 4686500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (p == NULL) 4687500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return 0; 4688500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 4689500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum = 0; 4690500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard extra[0] = extra[1] = extra[2] = '\0'; 4691500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (p != 0) { 4692500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum = 0; 4693500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard switch (p->state) { 4694500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_NAME: 4695b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards /* Output namespace declarations */ 4696b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards count = xmlTextWriterOutputNSDecl(writer); 4697b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards if (count < 0) 4698b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards return -1; 4699b8769d6f249617cd7ceae6bfd7a20027b1bd1fcfRob Richards sum += count; 4700500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard extra[0] = '>'; 4701500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard p->state = XML_TEXTWRITER_TEXT; 4702500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard break; 4703500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_PI: 4704500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard extra[0] = ' '; 4705500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard p->state = XML_TEXTWRITER_PI_TEXT; 4706500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard break; 4707500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD: 4708500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard extra[0] = ' '; 4709500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard extra[1] = '['; 4710500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard p->state = XML_TEXTWRITER_DTD_TEXT; 4711500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard break; 4712500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD_ELEM: 4713500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard extra[0] = ' '; 4714500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard p->state = XML_TEXTWRITER_DTD_ELEM_TEXT; 4715500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard break; 4716500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD_ATTL: 4717500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard extra[0] = ' '; 4718500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard p->state = XML_TEXTWRITER_DTD_ATTL_TEXT; 4719500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard break; 4720500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD_ENTY: 4721500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard case XML_TEXTWRITER_DTD_PENT: 4722500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard extra[0] = ' '; 4723500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard extra[1] = writer->qchar; 4724500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard p->state = XML_TEXTWRITER_DTD_ENTY_TEXT; 4725500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard break; 4726500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard default: 4727500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard break; 4728500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 4729500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 4730500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 4731500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (*extra != '\0') { 4732500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard count = xmlOutputBufferWriteString(writer->out, extra); 4733500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard if (count < 0) 4734500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return -1; 4735500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard sum += count; 4736500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard } 4737500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 4738500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard return sum; 4739500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard} 4740500a1de533e2ea03f452844f537bb247b7e43af2Daniel Veillard 47415d4644ef6e38479a648615eca758c5e962a141d5Daniel Veillard#define bottom_xmlwriter 47425d4644ef6e38479a648615eca758c5e962a141d5Daniel Veillard#include "elfgcchack.h" 47431d211e227372e5ed75a69fbad5f50d185d0af936Daniel Veillard#endif 4744