1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-01-17 02:03:36 +03:00

applied update from Alfred Mickautsch and the added patch from Lucas

* xmlwriter.c include/libxml/xmlwriter.h: applied update
  from Alfred Mickautsch and the added patch from Lucas Brasilino
Daniel
This commit is contained in:
Daniel Veillard 2004-02-17 11:40:32 +00:00
parent 31ae462a4d
commit ab69f366d0
3 changed files with 537 additions and 400 deletions

View File

@ -1,3 +1,8 @@
Tue Feb 17 12:39:08 CET 2004 Daniel Veillard <daniel@veillard.com>
* xmlwriter.c include/libxml/xmlwriter.h: applied update
from Alfred Mickautsch and the added patch from Lucas Brasilino
Sun Feb 15 12:01:30 CET 2004 Daniel Veillard <daniel@veillard.com>
* benchmark.png index.html xml.html: updating the benchmark

View File

@ -1,3 +1,4 @@
/*
* Summary: text writing API for XML
* Description: text writing API for XML
@ -19,26 +20,26 @@
extern "C" {
#endif
typedef struct _xmlTextWriter xmlTextWriter;
typedef xmlTextWriter *xmlTextWriterPtr;
typedef struct _xmlTextWriter xmlTextWriter;
typedef xmlTextWriter *xmlTextWriterPtr;
/*
* Constructors & Destructor
*/
XMLPUBFUN xmlTextWriterPtr XMLCALL
xmlNewTextWriter (xmlOutputBufferPtr out);
XMLPUBFUN xmlTextWriterPtr XMLCALL
XMLPUBFUN xmlTextWriterPtr XMLCALL
xmlNewTextWriter(xmlOutputBufferPtr out);
XMLPUBFUN xmlTextWriterPtr XMLCALL
xmlNewTextWriterFilename(const char *uri, int compression);
XMLPUBFUN xmlTextWriterPtr XMLCALL
XMLPUBFUN xmlTextWriterPtr XMLCALL
xmlNewTextWriterMemory(xmlBufferPtr buf, int compression);
XMLPUBFUN xmlTextWriterPtr XMLCALL
XMLPUBFUN xmlTextWriterPtr XMLCALL
xmlNewTextWriterPushParser(xmlParserCtxtPtr ctxt, int compression);
XMLPUBFUN xmlTextWriterPtr XMLCALL
XMLPUBFUN xmlTextWriterPtr XMLCALL
xmlNewTextWriterDoc(xmlDocPtr * doc, int compression);
XMLPUBFUN xmlTextWriterPtr XMLCALL
XMLPUBFUN xmlTextWriterPtr XMLCALL
xmlNewTextWriterTree(xmlDocPtr doc,
xmlNodePtr node, int compression);
XMLPUBFUN void XMLCALL xmlFreeTextWriter(xmlTextWriterPtr writer);
XMLPUBFUN void XMLCALL xmlFreeTextWriter(xmlTextWriterPtr writer);
/*
* Functions
@ -48,184 +49,188 @@ XMLPUBFUN void XMLCALL xmlFreeTextWriter(xmlTextWriterPtr writer);
/*
* Document
*/
XMLPUBFUN int XMLCALL
xmlTextWriterStartDocument (xmlTextWriterPtr writer,
const char *version,
const char *encoding,
const char *standalone);
XMLPUBFUN int XMLCALL
xmlTextWriterEndDocument (xmlTextWriterPtr writer);
XMLPUBFUN int XMLCALL
xmlTextWriterStartDocument(xmlTextWriterPtr writer,
const char *version,
const char *encoding,
const char *standalone);
XMLPUBFUN int XMLCALL
xmlTextWriterEndDocument(xmlTextWriterPtr writer);
/*
* Comments
*/
XMLPUBFUN int XMLCALL
xmlTextWriterWriteFormatComment (xmlTextWriterPtr writer,
const char *format, ...);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatComment(xmlTextWriterPtr writer,
const char *format,
va_list argptr);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteComment (xmlTextWriterPtr writer,
const xmlChar * content);
XMLPUBFUN int XMLCALL
xmlTextWriterStartComment(xmlTextWriterPtr writer);
XMLPUBFUN int XMLCALL xmlTextWriterEndComment(xmlTextWriterPtr writer);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteFormatComment(xmlTextWriterPtr writer,
const char *format, ...);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatComment(xmlTextWriterPtr writer,
const char *format,
va_list argptr);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteComment(xmlTextWriterPtr writer,
const xmlChar * content);
/*
* Elements
*/
XMLPUBFUN int XMLCALL
xmlTextWriterStartElement (xmlTextWriterPtr writer,
const xmlChar * name);
XMLPUBFUN int XMLCALL
xmlTextWriterStartElementNS (xmlTextWriterPtr writer,
const xmlChar * prefix,
const xmlChar * name,
const xmlChar * namespaceURI);
XMLPUBFUN int XMLCALL
xmlTextWriterStartElement(xmlTextWriterPtr writer,
const xmlChar * name);
XMLPUBFUN int XMLCALL
xmlTextWriterStartElementNS(xmlTextWriterPtr writer,
const xmlChar * prefix,
const xmlChar * name,
const xmlChar * namespaceURI);
XMLPUBFUN int XMLCALL xmlTextWriterEndElement(xmlTextWriterPtr writer);
XMLPUBFUN int XMLCALL
xmlTextWriterFullEndElement (xmlTextWriterPtr writer);
XMLPUBFUN int XMLCALL
xmlTextWriterFullEndElement(xmlTextWriterPtr writer);
/*
* Elements conveniency functions
*/
XMLPUBFUN int XMLCALL
xmlTextWriterWriteFormatElement (xmlTextWriterPtr writer,
const xmlChar * name,
const char *format, ...);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatElement(xmlTextWriterPtr writer,
const xmlChar * name,
const char *format,
va_list argptr);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteElement (xmlTextWriterPtr writer,
const xmlChar * name,
const xmlChar * content);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteFormatElementNS(xmlTextWriterPtr writer,
const xmlChar * prefix,
const xmlChar * name,
const xmlChar * namespaceURI,
const char *format, ...);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatElementNS(xmlTextWriterPtr writer,
const xmlChar * prefix,
const xmlChar * name,
const xmlChar * namespaceURI,
const char *format,
va_list argptr);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteElementNS (xmlTextWriterPtr writer,
const xmlChar * prefix,
const xmlChar * name,
const xmlChar * namespaceURI,
const xmlChar * content);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteFormatElement(xmlTextWriterPtr writer,
const xmlChar * name,
const char *format, ...);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatElement(xmlTextWriterPtr writer,
const xmlChar * name,
const char *format,
va_list argptr);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteElement(xmlTextWriterPtr writer,
const xmlChar * name,
const xmlChar * content);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteFormatElementNS(xmlTextWriterPtr writer,
const xmlChar * prefix,
const xmlChar * name,
const xmlChar * namespaceURI,
const char *format, ...);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatElementNS(xmlTextWriterPtr writer,
const xmlChar * prefix,
const xmlChar * name,
const xmlChar * namespaceURI,
const char *format,
va_list argptr);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteElementNS(xmlTextWriterPtr writer,
const xmlChar * prefix,
const xmlChar * name,
const xmlChar * namespaceURI,
const xmlChar * content);
/*
* Text
*/
XMLPUBFUN int XMLCALL
xmlTextWriterWriteFormatRaw (xmlTextWriterPtr writer,
const char *format, ...);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatRaw (xmlTextWriterPtr writer,
XMLPUBFUN int XMLCALL
xmlTextWriterWriteFormatRaw(xmlTextWriterPtr writer,
const char *format, ...);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatRaw(xmlTextWriterPtr writer,
const char *format, va_list argptr);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteRawLen (xmlTextWriterPtr writer,
XMLPUBFUN int XMLCALL
xmlTextWriterWriteRawLen(xmlTextWriterPtr writer,
const xmlChar * content, int len);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteRaw (xmlTextWriterPtr writer,
const xmlChar * content);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteFormatString (xmlTextWriterPtr writer,
const char *format, ...);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatString (xmlTextWriterPtr writer,
const char *format,
va_list argptr);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteString (xmlTextWriterPtr writer,
const xmlChar * content);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteBase64 (xmlTextWriterPtr writer,
XMLPUBFUN int XMLCALL
xmlTextWriterWriteRaw(xmlTextWriterPtr writer,
const xmlChar * content);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteFormatString(xmlTextWriterPtr writer,
const char *format, ...);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatString(xmlTextWriterPtr writer,
const char *format,
va_list argptr);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteString(xmlTextWriterPtr writer,
const xmlChar * content);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteBase64(xmlTextWriterPtr writer,
const char *data, int start, int len);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteBinHex (xmlTextWriterPtr writer,
XMLPUBFUN int XMLCALL
xmlTextWriterWriteBinHex(xmlTextWriterPtr writer,
const char *data, int start, int len);
/*
* Attributes
*/
XMLPUBFUN int XMLCALL
xmlTextWriterStartAttribute (xmlTextWriterPtr writer,
const xmlChar * name);
XMLPUBFUN int XMLCALL
xmlTextWriterStartAttributeNS (xmlTextWriterPtr writer,
const xmlChar * prefix,
const xmlChar * name,
const xmlChar * namespaceURI);
XMLPUBFUN int XMLCALL
xmlTextWriterEndAttribute (xmlTextWriterPtr writer);
XMLPUBFUN int XMLCALL
xmlTextWriterStartAttribute(xmlTextWriterPtr writer,
const xmlChar * name);
XMLPUBFUN int XMLCALL
xmlTextWriterStartAttributeNS(xmlTextWriterPtr writer,
const xmlChar * prefix,
const xmlChar * name,
const xmlChar * namespaceURI);
XMLPUBFUN int XMLCALL
xmlTextWriterEndAttribute(xmlTextWriterPtr writer);
/*
* Attributes conveniency functions
*/
XMLPUBFUN int XMLCALL
xmlTextWriterWriteFormatAttribute(xmlTextWriterPtr writer,
const xmlChar * name,
const char *format, ...);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatAttribute(xmlTextWriterPtr writer,
const xmlChar * name,
const char *format,
va_list argptr);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteAttribute (xmlTextWriterPtr writer,
const xmlChar * name,
const xmlChar * content);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteFormatAttributeNS(xmlTextWriterPtr writer,
const xmlChar * prefix,
const xmlChar * name,
const xmlChar * namespaceURI,
const char *format, ...);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatAttributeNS(xmlTextWriterPtr writer,
const xmlChar * prefix,
const xmlChar * name,
const xmlChar * namespaceURI,
const char *format,
va_list argptr);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteAttributeNS (xmlTextWriterPtr writer,
const xmlChar * prefix,
const xmlChar * name,
const xmlChar * namespaceURI,
const xmlChar * content);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteFormatAttribute(xmlTextWriterPtr writer,
const xmlChar * name,
const char *format, ...);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatAttribute(xmlTextWriterPtr writer,
const xmlChar * name,
const char *format,
va_list argptr);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteAttribute(xmlTextWriterPtr writer,
const xmlChar * name,
const xmlChar * content);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteFormatAttributeNS(xmlTextWriterPtr writer,
const xmlChar * prefix,
const xmlChar * name,
const xmlChar * namespaceURI,
const char *format, ...);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatAttributeNS(xmlTextWriterPtr writer,
const xmlChar * prefix,
const xmlChar * name,
const xmlChar * namespaceURI,
const char *format,
va_list argptr);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteAttributeNS(xmlTextWriterPtr writer,
const xmlChar * prefix,
const xmlChar * name,
const xmlChar * namespaceURI,
const xmlChar * content);
/*
* PI's
*/
XMLPUBFUN int XMLCALL
xmlTextWriterStartPI (xmlTextWriterPtr writer,
const xmlChar * target);
XMLPUBFUN int XMLCALL xmlTextWriterEndPI(xmlTextWriterPtr writer);
XMLPUBFUN int XMLCALL
xmlTextWriterStartPI(xmlTextWriterPtr writer,
const xmlChar * target);
XMLPUBFUN int XMLCALL xmlTextWriterEndPI(xmlTextWriterPtr writer);
/*
* PI conveniency functions
*/
XMLPUBFUN int XMLCALL
xmlTextWriterWriteFormatPI (xmlTextWriterPtr writer,
const xmlChar * target,
const char *format, ...);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatPI (xmlTextWriterPtr writer,
const xmlChar * target,
XMLPUBFUN int XMLCALL
xmlTextWriterWriteFormatPI(xmlTextWriterPtr writer,
const xmlChar * target,
const char *format, ...);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatPI(xmlTextWriterPtr writer,
const xmlChar * target,
const char *format, va_list argptr);
XMLPUBFUN int XMLCALL
xmlTextWriterWritePI (xmlTextWriterPtr writer,
const xmlChar * target,
const xmlChar * content);
XMLPUBFUN int XMLCALL
xmlTextWriterWritePI(xmlTextWriterPtr writer,
const xmlChar * target,
const xmlChar * content);
/**
* xmlTextWriterWriteProcessingInstruction:
*
@ -236,53 +241,54 @@ XMLPUBFUN int XMLCALL
/*
* CDATA
*/
XMLPUBFUN int XMLCALL xmlTextWriterStartCDATA(xmlTextWriterPtr writer);
XMLPUBFUN int XMLCALL xmlTextWriterEndCDATA(xmlTextWriterPtr writer);
XMLPUBFUN int XMLCALL xmlTextWriterStartCDATA(xmlTextWriterPtr writer);
XMLPUBFUN int XMLCALL xmlTextWriterEndCDATA(xmlTextWriterPtr writer);
/*
* CDATA conveniency functions
*/
XMLPUBFUN int XMLCALL
xmlTextWriterWriteFormatCDATA (xmlTextWriterPtr writer,
const char *format, ...);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatCDATA (xmlTextWriterPtr writer,
XMLPUBFUN int XMLCALL
xmlTextWriterWriteFormatCDATA(xmlTextWriterPtr writer,
const char *format, ...);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatCDATA(xmlTextWriterPtr writer,
const char *format, va_list argptr);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteCDATA (xmlTextWriterPtr writer,
const xmlChar * content);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteCDATA(xmlTextWriterPtr writer,
const xmlChar * content);
/*
* DTD
*/
XMLPUBFUN int XMLCALL
xmlTextWriterStartDTD (xmlTextWriterPtr writer,
const xmlChar * name,
const xmlChar * pubid,
const xmlChar * sysid);
XMLPUBFUN int XMLCALL xmlTextWriterEndDTD(xmlTextWriterPtr writer);
XMLPUBFUN int XMLCALL
xmlTextWriterStartDTD(xmlTextWriterPtr writer,
const xmlChar * name,
const xmlChar * pubid,
const xmlChar * sysid);
XMLPUBFUN int XMLCALL xmlTextWriterEndDTD(xmlTextWriterPtr writer);
/*
* DTD conveniency functions
*/
XMLPUBFUN int XMLCALL
xmlTextWriterWriteFormatDTD (xmlTextWriterPtr writer,
const xmlChar * name,
const xmlChar * pubid,
const xmlChar * sysid,
const char *format, ...);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatDTD (xmlTextWriterPtr writer,
const xmlChar * name,
const xmlChar * pubid,
const xmlChar * sysid,
XMLPUBFUN int XMLCALL
xmlTextWriterWriteFormatDTD(xmlTextWriterPtr writer,
const xmlChar * name,
const xmlChar * pubid,
const xmlChar * sysid,
const char *format, ...);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatDTD(xmlTextWriterPtr writer,
const xmlChar * name,
const xmlChar * pubid,
const xmlChar * sysid,
const char *format, va_list argptr);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteDTD (xmlTextWriterPtr writer,
const xmlChar * name,
const xmlChar * pubid,
const xmlChar * sysid,
const xmlChar * subset);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteDTD(xmlTextWriterPtr writer,
const xmlChar * name,
const xmlChar * pubid,
const xmlChar * sysid,
const xmlChar * subset);
/**
* xmlTextWriterWriteDocType:
*
@ -293,9 +299,10 @@ XMLPUBFUN int XMLCALL
/*
* DTD element definition
*/
XMLPUBFUN int XMLCALL
xmlTextWriterStartDTDElement (xmlTextWriterPtr writer,
const xmlChar * name);
XMLPUBFUN int XMLCALL
xmlTextWriterStartDTDElement(xmlTextWriterPtr writer,
const xmlChar * name);
/**
* xmlTextWriterEndDTDElement:
*
@ -306,26 +313,27 @@ XMLPUBFUN int XMLCALL
/*
* DTD element definition conveniency functions
*/
XMLPUBFUN int XMLCALL
xmlTextWriterWriteFormatDTDElement(xmlTextWriterPtr writer,
const xmlChar * name,
const char *format, ...);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatDTDElement(xmlTextWriterPtr writer,
const xmlChar * name,
const char *format,
va_list argptr);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteDTDElement (xmlTextWriterPtr writer,
const xmlChar * name,
const xmlChar * content);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteFormatDTDElement(xmlTextWriterPtr writer,
const xmlChar * name,
const char *format, ...);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatDTDElement(xmlTextWriterPtr writer,
const xmlChar * name,
const char *format,
va_list argptr);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteDTDElement(xmlTextWriterPtr writer,
const xmlChar * name,
const xmlChar * content);
/*
* DTD attribute list definition
*/
XMLPUBFUN int XMLCALL
xmlTextWriterStartDTDAttlist (xmlTextWriterPtr writer,
const xmlChar * name);
XMLPUBFUN int XMLCALL
xmlTextWriterStartDTDAttlist(xmlTextWriterPtr writer,
const xmlChar * name);
/**
* xmlTextWriterEndDTDAttlist:
*
@ -336,26 +344,27 @@ XMLPUBFUN int XMLCALL
/*
* DTD attribute list definition conveniency functions
*/
XMLPUBFUN int XMLCALL
xmlTextWriterWriteFormatDTDAttlist(xmlTextWriterPtr writer,
const xmlChar * name,
const char *format, ...);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatDTDAttlist(xmlTextWriterPtr writer,
const xmlChar * name,
const char *format,
va_list argptr);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteDTDAttlist (xmlTextWriterPtr writer,
const xmlChar * name,
const xmlChar * content);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteFormatDTDAttlist(xmlTextWriterPtr writer,
const xmlChar * name,
const char *format, ...);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatDTDAttlist(xmlTextWriterPtr writer,
const xmlChar * name,
const char *format,
va_list argptr);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteDTDAttlist(xmlTextWriterPtr writer,
const xmlChar * name,
const xmlChar * content);
/*
* DTD entity definition
*/
XMLPUBFUN int XMLCALL
xmlTextWriterStartDTDEntity (xmlTextWriterPtr writer,
XMLPUBFUN int XMLCALL
xmlTextWriterStartDTDEntity(xmlTextWriterPtr writer,
int pe, const xmlChar * name);
/**
* xmlTextWriterEndDTDEntity:
*
@ -366,58 +375,60 @@ XMLPUBFUN int XMLCALL
/*
* DTD entity definition conveniency functions
*/
XMLPUBFUN int XMLCALL
xmlTextWriterWriteFormatDTDInternalEntity(xmlTextWriterPtr writer,
int pe,
const xmlChar * name,
const char *format, ...);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatDTDInternalEntity(xmlTextWriterPtr writer,
int pe,
const xmlChar * name,
const char *format,
va_list argptr);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteDTDInternalEntity(xmlTextWriterPtr writer,
int pe,
const xmlChar * name,
const xmlChar * content);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteDTDExternalEntity(xmlTextWriterPtr writer,
int pe,
const xmlChar * name,
const xmlChar * pubid,
const xmlChar * sysid,
const xmlChar * ndataid);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteDTDEntity (xmlTextWriterPtr writer,
int pe,
const xmlChar * name,
const xmlChar * pubid,
const xmlChar * sysid,
const xmlChar * ndataid,
const xmlChar * content);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteFormatDTDInternalEntity(xmlTextWriterPtr writer,
int pe,
const xmlChar * name,
const char *format, ...);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatDTDInternalEntity(xmlTextWriterPtr writer,
int pe,
const xmlChar * name,
const char *format,
va_list argptr);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteDTDInternalEntity(xmlTextWriterPtr writer,
int pe,
const xmlChar * name,
const xmlChar * content);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteDTDExternalEntity(xmlTextWriterPtr writer,
int pe,
const xmlChar * name,
const xmlChar * pubid,
const xmlChar * sysid,
const xmlChar * ndataid);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteDTDEntity(xmlTextWriterPtr writer,
int pe,
const xmlChar * name,
const xmlChar * pubid,
const xmlChar * sysid,
const xmlChar * ndataid,
const xmlChar * content);
/*
* DTD notation definition
*/
XMLPUBFUN int XMLCALL
xmlTextWriterWriteDTDNotation (xmlTextWriterPtr writer,
const xmlChar * name,
const xmlChar * pubid,
const xmlChar * sysid);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteDTDNotation(xmlTextWriterPtr writer,
const xmlChar * name,
const xmlChar * pubid,
const xmlChar * sysid);
/*
* Indentation
*/
XMLPUBFUN int XMLCALL
xmlTextWriterSetIndent (xmlTextWriterPtr writer, int indent);
XMLPUBFUN int XMLCALL
xmlTextWriterSetIndentString (xmlTextWriterPtr writer, xmlChar *str);
XMLPUBFUN int XMLCALL
xmlTextWriterSetIndent(xmlTextWriterPtr writer, int indent);
XMLPUBFUN int XMLCALL
xmlTextWriterSetIndentString(xmlTextWriterPtr writer,
const xmlChar * str);
/*
* misc
*/
XMLPUBFUN int XMLCALL xmlTextWriterFlush(xmlTextWriterPtr writer);
XMLPUBFUN int XMLCALL xmlTextWriterFlush(xmlTextWriterPtr writer);
#ifdef __cplusplus
}

View File

@ -39,7 +39,8 @@ typedef enum {
XML_TEXTWRITER_DTD_TEXT,
XML_TEXTWRITER_DTD_ELEM,
XML_TEXTWRITER_DTD_ATTL,
XML_TEXTWRITER_DTD_ENTY
XML_TEXTWRITER_DTD_ENTY,
XML_TEXTWRITER_COMMENT
} xmlTextWriterState;
typedef struct _xmlTextWriterStackEntry xmlTextWriterStackEntry;
@ -57,14 +58,14 @@ struct _xmlTextWriterNsStackEntry {
};
struct _xmlTextWriter {
xmlOutputBufferPtr out; /* output buffer */
xmlListPtr nodes; /* element name stack */
xmlListPtr nsstack; /* name spaces stack */
xmlOutputBufferPtr out; /* output buffer */
xmlListPtr nodes; /* element name stack */
xmlListPtr nsstack; /* name spaces stack */
int level;
int indent; /* enable indent */
int doindent; /* internal indent flag */
xmlChar *ichar; /* indent character */
char qchar; /* character used for quoting attribute values */
int indent; /* enable indent */
int doindent; /* internal indent flag */
xmlChar *ichar; /* indent character */
char qchar; /* character used for quoting attribute values */
xmlParserCtxtPtr ctxt;
};
@ -85,7 +86,7 @@ static xmlChar *xmlTextWriterVSprintf(const char *format, va_list argptr);
static int xmlOutputBufferWriteBase64(xmlOutputBufferPtr out, int len,
const unsigned char *data);
static void xmlTextWriterStartDocumentCallback(void *ctx);
static int xmlTextWriterWriteIndent (xmlTextWriterPtr writer);
static int xmlTextWriterWriteIndent(xmlTextWriterPtr writer);
/**
* xmlNewTextWriter:
@ -132,11 +133,12 @@ xmlNewTextWriter(xmlOutputBufferPtr out)
}
ret->out = out;
ret->ichar = xmlStrdup (BAD_CAST " ");
ret->ichar = xmlStrdup(BAD_CAST " ");
ret->qchar = '"';
if (!ret->ichar) return NULL;
if (!ret->ichar)
return NULL;
return ret;
}
@ -551,17 +553,151 @@ xmlTextWriterEndDocument(xmlTextWriterPtr writer)
return -1;
sum += count;
break;
case XML_TEXTWRITER_COMMENT:
count = xmlTextWriterEndComment(writer);
if (count < 0)
return -1;
sum += count;
break;
default:
break;
break;
}
}
if (!writer->indent) {
count = xmlOutputBufferWriteString(writer->out, "\n");
if(count < 0)
count = xmlOutputBufferWriteString(writer->out, "\n");
if (count < 0)
return -1;
sum += count;
}
return sum;
}
/**
* xmlTextWriterStartComment:
* @writer: the xmlTextWriterPtr
*
* Start an xml comment.
*
* Returns the bytes written (may be 0 because of buffering) or -1 in case of error
*/
int
xmlTextWriterStartComment(xmlTextWriterPtr writer)
{
int count;
int sum;
xmlLinkPtr lk;
xmlTextWriterStackEntry *p;
if (writer == NULL)
return -1;
sum = 0;
lk = xmlListFront(writer->nodes);
if (lk != 0) {
p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk);
if (p != 0) {
switch (p->state) {
case XML_TEXTWRITER_TEXT:
case XML_TEXTWRITER_NONE:
break;
case XML_TEXTWRITER_NAME:
count = xmlOutputBufferWriteString(writer->out, ">");
if (count < 0)
return -1;
sum += count;
p->state = XML_TEXTWRITER_TEXT;
break;
default:
return -1;
}
}
}
p = (xmlTextWriterStackEntry *)
xmlMalloc(sizeof(xmlTextWriterStackEntry));
if (p == 0) {
xmlGenericError(xmlGenericErrorContext,
"xmlTextWriterStartElement : out of memory!\n");
return -1;
}
p->name = 0;
p->state = XML_TEXTWRITER_COMMENT;
xmlListPushFront(writer->nodes, p);
if (writer->indent) {
count = xmlOutputBufferWriteString(writer->out, "\n");
if (count < 0)
return -1;
sum += count;
count = xmlTextWriterWriteIndent(writer);
if (count < 0)
return -1;
sum += count;
}
count = xmlOutputBufferWriteString(writer->out, "<!--");
if (count < 0)
return -1;
sum += count;
return sum;
}
/**
* xmlTextWriterEndComment:
* @writer: the xmlTextWriterPtr
*
* End the current xml coment.
*
* Returns the bytes written (may be 0 because of buffering) or -1 in case of error
*/
int
xmlTextWriterEndComment(xmlTextWriterPtr writer)
{
int count;
int sum;
xmlLinkPtr lk;
xmlTextWriterStackEntry *p;
if (writer == NULL)
return -1;
lk = xmlListFront(writer->nodes);
if (lk == 0)
return -1;
p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk);
if (p == 0)
return -1;
sum = 0;
switch (p->state) {
case XML_TEXTWRITER_COMMENT:
count = xmlOutputBufferWriteString(writer->out, "-->");
if (count < 0)
return -1;
sum += count;
break;
default:
return -1;
}
if (writer->indent) {
count = xmlOutputBufferWriteString(writer->out, "\n");
if (count < 0)
return -1;
sum += count;
}
xmlListPopFront(writer->nodes);
return sum;
}
@ -634,64 +770,21 @@ xmlTextWriterWriteComment(xmlTextWriterPtr writer, const xmlChar * content)
{
int count;
int sum;
xmlLinkPtr lk;
xmlTextWriterStackEntry *p;
if ((writer == NULL) || (writer->out == NULL))
return -1;
if (content == NULL)
return 0;
sum = 0;
lk = xmlListFront(writer->nodes);
if (lk != 0) {
p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk);
if (p != 0) {
switch (p->state) {
case XML_TEXTWRITER_PI:
case XML_TEXTWRITER_PI_TEXT:
return -1;
case XML_TEXTWRITER_NONE:
case XML_TEXTWRITER_TEXT:
break;
case XML_TEXTWRITER_NAME:
count = xmlOutputBufferWriteString(writer->out, ">");
if (count < 0)
return -1;
sum += count;
p->state = XML_TEXTWRITER_TEXT;
break;
default:
break;
}
}
}
if (writer->indent) {
count = xmlOutputBufferWriteString (writer->out, "\n");
sum += count;
}
count = xmlOutputBufferWriteString(writer->out, "<!--");
count = xmlTextWriterStartComment(writer);
if (count < 0)
return -1;
sum += count;
count = xmlOutputBufferWriteString(writer->out,
(const char *) content);
count = xmlTextWriterWriteString(writer, content);
if (count < 0)
return -1;
sum += count;
count = xmlOutputBufferWriteString(writer->out, "-->");
count = xmlTextWriterEndComment(writer);
if (count < 0)
return -1;
sum += count;
if (writer->indent) {
count = xmlOutputBufferWriteString (writer->out, "\n");
sum += count;
}
return sum;
}
@ -731,12 +824,13 @@ xmlTextWriterStartElement(xmlTextWriterPtr writer, const xmlChar * name)
if (count < 0)
return -1;
sum += count;
if (writer->indent)
count = xmlOutputBufferWriteString (writer->out, "\n");
if (writer->indent)
count =
xmlOutputBufferWriteString(writer->out, "\n");
p->state = XML_TEXTWRITER_TEXT;
break;
default:
break;
default:
break;
}
}
}
@ -760,9 +854,9 @@ xmlTextWriterStartElement(xmlTextWriterPtr writer, const xmlChar * name)
xmlListPushFront(writer->nodes, p);
if (writer->indent) {
count = xmlTextWriterWriteIndent (writer);
sum += count;
if (writer->indent) {
count = xmlTextWriterWriteIndent(writer);
sum += count;
}
count = xmlOutputBufferWriteString(writer->out, "<");
@ -868,25 +962,26 @@ xmlTextWriterEndElement(xmlTextWriterPtr writer)
sum += count;
/* fallthrough */
case XML_TEXTWRITER_NAME:
if (writer->indent) /* next element needs indent */
writer->doindent = 1;
if (writer->indent) /* next element needs indent */
writer->doindent = 1;
count = xmlOutputBufferWriteString(writer->out, "/>");
if (count < 0)
return -1;
sum += count;
break;
case XML_TEXTWRITER_TEXT:
if ((writer->indent) && (writer->doindent)) {
count = xmlTextWriterWriteIndent (writer);
sum += count;
writer->doindent = 1;
} else writer->doindent = 1;
if ((writer->indent) && (writer->doindent)) {
count = xmlTextWriterWriteIndent(writer);
sum += count;
writer->doindent = 1;
} else
writer->doindent = 1;
count = xmlOutputBufferWriteString(writer->out, "</");
if (count < 0)
return -1;
sum += count;
count = xmlOutputBufferWriteString(writer->out,
(const char *)p->name);
(const char *) p->name);
if (count < 0)
return -1;
sum += count;
@ -900,8 +995,8 @@ xmlTextWriterEndElement(xmlTextWriterPtr writer)
}
if (writer->indent) {
count = xmlOutputBufferWriteString (writer->out, "\n");
sum += count;
count = xmlOutputBufferWriteString(writer->out, "\n");
sum += count;
}
xmlListPopFront(writer->nodes);
@ -955,7 +1050,7 @@ xmlTextWriterFullEndElement(xmlTextWriterPtr writer)
return -1;
sum += count;
count = xmlOutputBufferWriteString(writer->out,
(const char *) p->name);
(const char *) p->name);
if (count < 0)
return -1;
sum += count;
@ -1177,11 +1272,11 @@ xmlTextWriterWriteVFormatString(xmlTextWriterPtr writer,
int
xmlTextWriterWriteString(xmlTextWriterPtr writer, const xmlChar * content)
{
int count=0;
int count = 0;
int sum;
xmlLinkPtr lk;
xmlTextWriterStackEntry *p;
xmlChar *buf=NULL;
xmlChar *buf = NULL;
if (writer == NULL)
return -1;
@ -1216,13 +1311,13 @@ xmlTextWriterWriteString(xmlTextWriterPtr writer, const xmlChar * content)
case XML_TEXTWRITER_TEXT:
encode:
buf = xmlEncodeSpecialChars(NULL, content);
if (buf == NULL)
count = -1;
if (buf == NULL)
count = -1;
break;
case XML_TEXTWRITER_ATTRIBUTE:
xmlAttrSerializeTxtContent(writer->out->buffer, NULL,
NULL, content);
break;
xmlAttrSerializeTxtContent(writer->out->buffer, NULL,
NULL, content);
break;
case XML_TEXTWRITER_DTD:
count = xmlOutputBufferWriteString(writer->out, " [");
if (count < 0)
@ -1233,16 +1328,17 @@ xmlTextWriterWriteString(xmlTextWriterPtr writer, const xmlChar * content)
case XML_TEXTWRITER_DTD_TEXT:
case XML_TEXTWRITER_DTD_ELEM:
case XML_TEXTWRITER_CDATA:
case XML_TEXTWRITER_COMMENT:
buf = xmlStrdup(content);
if (buf == NULL)
count = -1;
if (buf == NULL)
count = -1;
break;
default:
break;
default:
break;
}
if (writer->indent)
writer->doindent = 0;
writer->doindent = 0;
if (buf != 0) {
count =
@ -1327,11 +1423,6 @@ xmlOutputBufferWriteBase64(xmlOutputBufferPtr out, int len,
break;
}
count = xmlOutputBufferWrite(out, 2, B64CRLF);
if (count == -1)
return -1;
sum += count;
return sum;
}
@ -1347,7 +1438,7 @@ xmlOutputBufferWriteBase64(xmlOutputBufferPtr out, int len,
* Returns the bytes written (may be 0 because of buffering) or -1 in case of error
*/
int
xmlTextWriterWriteBase64(xmlTextWriterPtr writer, const char * data,
xmlTextWriterWriteBase64(xmlTextWriterPtr writer, const char *data,
int start, int len)
{
int count;
@ -1395,6 +1486,9 @@ xmlTextWriterWriteBase64(xmlTextWriterPtr writer, const char * data,
break;
}
if (writer->indent)
writer->doindent = 0;
count =
xmlOutputBufferWriteBase64(writer->out, len,
(unsigned char *) data + start);
@ -1417,11 +1511,35 @@ xmlTextWriterWriteBase64(xmlTextWriterPtr writer, const char * data,
* Returns the bytes written (may be 0 because of buffering) or -1 in case of error
*/
static int
xmlOutputBufferWriteBinHex(xmlOutputBufferPtr out ATTRIBUTE_UNUSED,
int len ATTRIBUTE_UNUSED,
const unsigned char *data ATTRIBUTE_UNUSED)
xmlOutputBufferWriteBinHex(xmlOutputBufferPtr out,
int len, const unsigned char *data)
{
return -1;
int count;
int sum;
static char hex[] = "0123456789ABCDEF";
int i;
if ((out == NULL) || ((data == 0) && (len != 0))) {
return -1;
}
sum = 0;
for (i = 0; i < len; i++) {
count =
xmlOutputBufferWrite(out, 1,
(const char *) &hex[data[i] >> 4]);
if (count == -1)
return -1;
sum += count;
count =
xmlOutputBufferWrite(out, 1,
(const char *) &hex[data[i] & 0xF]);
if (count == -1)
return -1;
sum += count;
}
return sum;
}
/**
@ -1436,7 +1554,7 @@ xmlOutputBufferWriteBinHex(xmlOutputBufferPtr out ATTRIBUTE_UNUSED,
* Returns the bytes written (may be 0 because of buffering) or -1 in case of error
*/
int
xmlTextWriterWriteBinHex(xmlTextWriterPtr writer, const char * data,
xmlTextWriterWriteBinHex(xmlTextWriterPtr writer, const char *data,
int start, int len)
{
int count;
@ -1484,6 +1602,9 @@ xmlTextWriterWriteBinHex(xmlTextWriterPtr writer, const char * data,
break;
}
if (writer->indent)
writer->doindent = 0;
count =
xmlOutputBufferWriteBinHex(writer->out, len,
(unsigned char *) data + start);
@ -2163,10 +2284,10 @@ xmlTextWriterStartPI(xmlTextWriterPtr writer, const xmlChar * target)
sum += count;
p->state = XML_TEXTWRITER_TEXT;
break;
case XML_TEXTWRITER_NONE:
case XML_TEXTWRITER_TEXT:
case XML_TEXTWRITER_DTD:
break;
case XML_TEXTWRITER_NONE:
case XML_TEXTWRITER_TEXT:
case XML_TEXTWRITER_DTD:
break;
case XML_TEXTWRITER_PI:
case XML_TEXTWRITER_PI_TEXT:
xmlGenericError(xmlGenericErrorContext,
@ -2579,7 +2700,7 @@ xmlTextWriterStartDTD(xmlTextWriterPtr writer,
sum = 0;
lk = xmlListFront(writer->nodes);
if (lk != 0) {
if ((lk != NULL) && (xmlLinkGetData(lk) != NULL)) {
xmlGenericError(xmlGenericErrorContext,
"xmlTextWriterStartDTD : DTD allowed only in prolog!\n");
return -1;
@ -3081,7 +3202,7 @@ xmlTextWriterStartDTDAttlist(xmlTextWriterPtr writer, const xmlChar * name)
if (count < 0)
return -1;
sum += count;
count = xmlOutputBufferWriteString(writer->out, (const char *)name);
count = xmlOutputBufferWriteString(writer->out, (const char *) name);
if (count < 0)
return -1;
sum += count;
@ -3276,7 +3397,7 @@ xmlTextWriterStartDTDEntity(xmlTextWriterPtr writer,
sum += count;
}
count = xmlOutputBufferWriteString(writer->out, (const char *)name);
count = xmlOutputBufferWriteString(writer->out, (const char *) name);
if (count < 0)
return -1;
sum += count;
@ -4018,15 +4139,15 @@ xmlTextWriterStartDocumentCallback(void *ctx)
* Returns -1 on error or 0 otherwise.
*/
int
xmlTextWriterSetIndent (xmlTextWriterPtr writer, int indent)
xmlTextWriterSetIndent(xmlTextWriterPtr writer, int indent)
{
if (indent < 0)
return -1;
if (indent < 0)
return -1;
writer->indent = indent;
writer->doindent = 1;
writer->indent = indent;
writer->doindent = 1;
return 0;
return 0;
}
/**
@ -4039,20 +4160,20 @@ xmlTextWriterSetIndent (xmlTextWriterPtr writer, int indent)
* Returns -1 on error or 0 otherwise.
*/
int
xmlTextWriterSetIndentString (xmlTextWriterPtr writer, xmlChar *str)
xmlTextWriterSetIndentString(xmlTextWriterPtr writer, const xmlChar * str)
{
if (!str)
return -1;
if (!str)
return -1;
if (writer->ichar != NULL)
xmlFree(writer->ichar);
writer->ichar = xmlStrdup (str);
if (!writer->ichar)
return -1;
else
return 0;
if (writer->ichar != NULL)
xmlFree(writer->ichar);
writer->ichar = xmlStrdup(str);
if (!writer->ichar)
return -1;
else
return 0;
}
/**
@ -4062,25 +4183,25 @@ xmlTextWriterSetIndentString (xmlTextWriterPtr writer, xmlChar *str)
* Write indent string.
*
* Returns -1 on error or the number of strings written.
*/
*/
static int
xmlTextWriterWriteIndent (xmlTextWriterPtr writer)
xmlTextWriterWriteIndent(xmlTextWriterPtr writer)
{
int lksize;
int i;
int ret;
lksize = xmlListSize (writer->nodes);
if (lksize < 1)
return (-1); /* list is empty */
for (i = 0; i < (lksize-1); i++) {
ret = xmlOutputBufferWriteString (writer->out,
(const char *)writer->ichar);
if (ret == -1)
return (-1);
}
int lksize;
int i;
int ret;
return (lksize - 1);
lksize = xmlListSize(writer->nodes);
if (lksize < 1)
return (-1); /* list is empty */
for (i = 0; i < (lksize - 1); i++) {
ret = xmlOutputBufferWriteString(writer->out,
(const char *) writer->ichar);
if (ret == -1)
return (-1);
}
return (lksize - 1);
}
#endif