Home | History | Annotate | Download | only in libxml
      1 
      2 /*
      3  * Summary: text writing API for XML
      4  * Description: text writing API for XML
      5  *
      6  * Copy: See Copyright for the status of this software.
      7  *
      8  * Author: Alfred Mickautsch <alfred (at) mickautsch.de>
      9  */
     10 
     11 #ifndef __XML_XMLWRITER_H__
     12 #define __XML_XMLWRITER_H__
     13 
     14 #include <libxml/xmlversion.h>
     15 
     16 #ifdef LIBXML_WRITER_ENABLED
     17 
     18 #include <stdarg.h>
     19 #include <libxml/xmlIO.h>
     20 #include <libxml/list.h>
     21 #include <libxml/xmlstring.h>
     22 
     23 #ifdef __cplusplus
     24 extern "C" {
     25 #endif
     26 
     27     typedef struct _xmlTextWriter xmlTextWriter;
     28     typedef xmlTextWriter *xmlTextWriterPtr;
     29 
     30 /*
     31  * Constructors & Destructor
     32  */
     33     XMLPUBFUN xmlTextWriterPtr XMLCALL
     34         xmlNewTextWriter(xmlOutputBufferPtr out);
     35     XMLPUBFUN xmlTextWriterPtr XMLCALL
     36         xmlNewTextWriterFilename(const char *uri, int compression);
     37     XMLPUBFUN xmlTextWriterPtr XMLCALL
     38         xmlNewTextWriterMemory(xmlBufferPtr buf, int compression);
     39     XMLPUBFUN xmlTextWriterPtr XMLCALL
     40         xmlNewTextWriterPushParser(xmlParserCtxtPtr ctxt, int compression);
     41     XMLPUBFUN xmlTextWriterPtr XMLCALL
     42         xmlNewTextWriterDoc(xmlDocPtr * doc, int compression);
     43     XMLPUBFUN xmlTextWriterPtr XMLCALL
     44         xmlNewTextWriterTree(xmlDocPtr doc, xmlNodePtr node,
     45                              int compression);
     46     XMLPUBFUN void XMLCALL xmlFreeTextWriter(xmlTextWriterPtr writer);
     47 
     48 /*
     49  * Functions
     50  */
     51 
     52 
     53 /*
     54  * Document
     55  */
     56     XMLPUBFUN int XMLCALL
     57         xmlTextWriterStartDocument(xmlTextWriterPtr writer,
     58                                    const char *version,
     59                                    const char *encoding,
     60                                    const char *standalone);
     61     XMLPUBFUN int XMLCALL xmlTextWriterEndDocument(xmlTextWriterPtr
     62                                                    writer);
     63 
     64 /*
     65  * Comments
     66  */
     67     XMLPUBFUN int XMLCALL xmlTextWriterStartComment(xmlTextWriterPtr
     68                                                     writer);
     69     XMLPUBFUN int XMLCALL xmlTextWriterEndComment(xmlTextWriterPtr writer);
     70     XMLPUBFUN int XMLCALL
     71         xmlTextWriterWriteFormatComment(xmlTextWriterPtr writer,
     72                                         const char *format, ...)
     73 					LIBXML_ATTR_FORMAT(2,3);
     74     XMLPUBFUN int XMLCALL
     75         xmlTextWriterWriteVFormatComment(xmlTextWriterPtr writer,
     76                                          const char *format,
     77                                          va_list argptr)
     78 					 LIBXML_ATTR_FORMAT(2,0);
     79     XMLPUBFUN int XMLCALL xmlTextWriterWriteComment(xmlTextWriterPtr
     80                                                     writer,
     81                                                     const xmlChar *
     82                                                     content);
     83 
     84 /*
     85  * Elements
     86  */
     87     XMLPUBFUN int XMLCALL
     88         xmlTextWriterStartElement(xmlTextWriterPtr writer,
     89                                   const xmlChar * name);
     90     XMLPUBFUN int XMLCALL xmlTextWriterStartElementNS(xmlTextWriterPtr
     91                                                       writer,
     92                                                       const xmlChar *
     93                                                       prefix,
     94                                                       const xmlChar * name,
     95                                                       const xmlChar *
     96                                                       namespaceURI);
     97     XMLPUBFUN int XMLCALL xmlTextWriterEndElement(xmlTextWriterPtr writer);
     98     XMLPUBFUN int XMLCALL xmlTextWriterFullEndElement(xmlTextWriterPtr
     99                                                       writer);
    100 
    101 /*
    102  * Elements conveniency functions
    103  */
    104     XMLPUBFUN int XMLCALL
    105         xmlTextWriterWriteFormatElement(xmlTextWriterPtr writer,
    106                                         const xmlChar * name,
    107                                         const char *format, ...)
    108 					LIBXML_ATTR_FORMAT(3,4);
    109     XMLPUBFUN int XMLCALL
    110         xmlTextWriterWriteVFormatElement(xmlTextWriterPtr writer,
    111                                          const xmlChar * name,
    112                                          const char *format,
    113                                          va_list argptr)
    114 					 LIBXML_ATTR_FORMAT(3,0);
    115     XMLPUBFUN int XMLCALL xmlTextWriterWriteElement(xmlTextWriterPtr
    116                                                     writer,
    117                                                     const xmlChar * name,
    118                                                     const xmlChar *
    119                                                     content);
    120     XMLPUBFUN int XMLCALL
    121         xmlTextWriterWriteFormatElementNS(xmlTextWriterPtr writer,
    122                                           const xmlChar * prefix,
    123                                           const xmlChar * name,
    124                                           const xmlChar * namespaceURI,
    125                                           const char *format, ...)
    126 					  LIBXML_ATTR_FORMAT(5,6);
    127     XMLPUBFUN int XMLCALL
    128         xmlTextWriterWriteVFormatElementNS(xmlTextWriterPtr writer,
    129                                            const xmlChar * prefix,
    130                                            const xmlChar * name,
    131                                            const xmlChar * namespaceURI,
    132                                            const char *format,
    133                                            va_list argptr)
    134 					   LIBXML_ATTR_FORMAT(5,0);
    135     XMLPUBFUN int XMLCALL xmlTextWriterWriteElementNS(xmlTextWriterPtr
    136                                                       writer,
    137                                                       const xmlChar *
    138                                                       prefix,
    139                                                       const xmlChar * name,
    140                                                       const xmlChar *
    141                                                       namespaceURI,
    142                                                       const xmlChar *
    143                                                       content);
    144 
    145 /*
    146  * Text
    147  */
    148     XMLPUBFUN int XMLCALL
    149         xmlTextWriterWriteFormatRaw(xmlTextWriterPtr writer,
    150                                     const char *format, ...)
    151 				    LIBXML_ATTR_FORMAT(2,3);
    152     XMLPUBFUN int XMLCALL
    153         xmlTextWriterWriteVFormatRaw(xmlTextWriterPtr writer,
    154                                      const char *format, va_list argptr)
    155 				     LIBXML_ATTR_FORMAT(2,0);
    156     XMLPUBFUN int XMLCALL
    157         xmlTextWriterWriteRawLen(xmlTextWriterPtr writer,
    158                                  const xmlChar * content, int len);
    159     XMLPUBFUN int XMLCALL
    160         xmlTextWriterWriteRaw(xmlTextWriterPtr writer,
    161                               const xmlChar * content);
    162     XMLPUBFUN int XMLCALL xmlTextWriterWriteFormatString(xmlTextWriterPtr
    163                                                          writer,
    164                                                          const char
    165                                                          *format, ...)
    166 							 LIBXML_ATTR_FORMAT(2,3);
    167     XMLPUBFUN int XMLCALL xmlTextWriterWriteVFormatString(xmlTextWriterPtr
    168                                                           writer,
    169                                                           const char
    170                                                           *format,
    171                                                           va_list argptr)
    172 							  LIBXML_ATTR_FORMAT(2,0);
    173     XMLPUBFUN int XMLCALL xmlTextWriterWriteString(xmlTextWriterPtr writer,
    174                                                    const xmlChar *
    175                                                    content);
    176     XMLPUBFUN int XMLCALL xmlTextWriterWriteBase64(xmlTextWriterPtr writer,
    177                                                    const char *data,
    178                                                    int start, int len);
    179     XMLPUBFUN int XMLCALL xmlTextWriterWriteBinHex(xmlTextWriterPtr writer,
    180                                                    const char *data,
    181                                                    int start, int len);
    182 
    183 /*
    184  * Attributes
    185  */
    186     XMLPUBFUN int XMLCALL
    187         xmlTextWriterStartAttribute(xmlTextWriterPtr writer,
    188                                     const xmlChar * name);
    189     XMLPUBFUN int XMLCALL xmlTextWriterStartAttributeNS(xmlTextWriterPtr
    190                                                         writer,
    191                                                         const xmlChar *
    192                                                         prefix,
    193                                                         const xmlChar *
    194                                                         name,
    195                                                         const xmlChar *
    196                                                         namespaceURI);
    197     XMLPUBFUN int XMLCALL xmlTextWriterEndAttribute(xmlTextWriterPtr
    198                                                     writer);
    199 
    200 /*
    201  * Attributes conveniency functions
    202  */
    203     XMLPUBFUN int XMLCALL
    204         xmlTextWriterWriteFormatAttribute(xmlTextWriterPtr writer,
    205                                           const xmlChar * name,
    206                                           const char *format, ...)
    207 					  LIBXML_ATTR_FORMAT(3,4);
    208     XMLPUBFUN int XMLCALL
    209         xmlTextWriterWriteVFormatAttribute(xmlTextWriterPtr writer,
    210                                            const xmlChar * name,
    211                                            const char *format,
    212                                            va_list argptr)
    213 					   LIBXML_ATTR_FORMAT(3,0);
    214     XMLPUBFUN int XMLCALL xmlTextWriterWriteAttribute(xmlTextWriterPtr
    215                                                       writer,
    216                                                       const xmlChar * name,
    217                                                       const xmlChar *
    218                                                       content);
    219     XMLPUBFUN int XMLCALL
    220         xmlTextWriterWriteFormatAttributeNS(xmlTextWriterPtr writer,
    221                                             const xmlChar * prefix,
    222                                             const xmlChar * name,
    223                                             const xmlChar * namespaceURI,
    224                                             const char *format, ...)
    225 					    LIBXML_ATTR_FORMAT(5,6);
    226     XMLPUBFUN int XMLCALL
    227         xmlTextWriterWriteVFormatAttributeNS(xmlTextWriterPtr writer,
    228                                              const xmlChar * prefix,
    229                                              const xmlChar * name,
    230                                              const xmlChar * namespaceURI,
    231                                              const char *format,
    232                                              va_list argptr)
    233 					     LIBXML_ATTR_FORMAT(5,0);
    234     XMLPUBFUN int XMLCALL xmlTextWriterWriteAttributeNS(xmlTextWriterPtr
    235                                                         writer,
    236                                                         const xmlChar *
    237                                                         prefix,
    238                                                         const xmlChar *
    239                                                         name,
    240                                                         const xmlChar *
    241                                                         namespaceURI,
    242                                                         const xmlChar *
    243                                                         content);
    244 
    245 /*
    246  * PI's
    247  */
    248     XMLPUBFUN int XMLCALL
    249         xmlTextWriterStartPI(xmlTextWriterPtr writer,
    250                              const xmlChar * target);
    251     XMLPUBFUN int XMLCALL xmlTextWriterEndPI(xmlTextWriterPtr writer);
    252 
    253 /*
    254  * PI conveniency functions
    255  */
    256     XMLPUBFUN int XMLCALL
    257         xmlTextWriterWriteFormatPI(xmlTextWriterPtr writer,
    258                                    const xmlChar * target,
    259                                    const char *format, ...)
    260 				   LIBXML_ATTR_FORMAT(3,4);
    261     XMLPUBFUN int XMLCALL
    262         xmlTextWriterWriteVFormatPI(xmlTextWriterPtr writer,
    263                                     const xmlChar * target,
    264                                     const char *format, va_list argptr)
    265 				    LIBXML_ATTR_FORMAT(3,0);
    266     XMLPUBFUN int XMLCALL
    267         xmlTextWriterWritePI(xmlTextWriterPtr writer,
    268                              const xmlChar * target,
    269                              const xmlChar * content);
    270 
    271 /**
    272  * xmlTextWriterWriteProcessingInstruction:
    273  *
    274  * This macro maps to xmlTextWriterWritePI
    275  */
    276 #define xmlTextWriterWriteProcessingInstruction xmlTextWriterWritePI
    277 
    278 /*
    279  * CDATA
    280  */
    281     XMLPUBFUN int XMLCALL xmlTextWriterStartCDATA(xmlTextWriterPtr writer);
    282     XMLPUBFUN int XMLCALL xmlTextWriterEndCDATA(xmlTextWriterPtr writer);
    283 
    284 /*
    285  * CDATA conveniency functions
    286  */
    287     XMLPUBFUN int XMLCALL
    288         xmlTextWriterWriteFormatCDATA(xmlTextWriterPtr writer,
    289                                       const char *format, ...)
    290 				      LIBXML_ATTR_FORMAT(2,3);
    291     XMLPUBFUN int XMLCALL
    292         xmlTextWriterWriteVFormatCDATA(xmlTextWriterPtr writer,
    293                                        const char *format, va_list argptr)
    294 				       LIBXML_ATTR_FORMAT(2,0);
    295     XMLPUBFUN int XMLCALL
    296         xmlTextWriterWriteCDATA(xmlTextWriterPtr writer,
    297                                 const xmlChar * content);
    298 
    299 /*
    300  * DTD
    301  */
    302     XMLPUBFUN int XMLCALL
    303         xmlTextWriterStartDTD(xmlTextWriterPtr writer,
    304                               const xmlChar * name,
    305                               const xmlChar * pubid,
    306                               const xmlChar * sysid);
    307     XMLPUBFUN int XMLCALL xmlTextWriterEndDTD(xmlTextWriterPtr writer);
    308 
    309 /*
    310  * DTD conveniency functions
    311  */
    312     XMLPUBFUN int XMLCALL
    313         xmlTextWriterWriteFormatDTD(xmlTextWriterPtr writer,
    314                                     const xmlChar * name,
    315                                     const xmlChar * pubid,
    316                                     const xmlChar * sysid,
    317                                     const char *format, ...)
    318 				    LIBXML_ATTR_FORMAT(5,6);
    319     XMLPUBFUN int XMLCALL
    320         xmlTextWriterWriteVFormatDTD(xmlTextWriterPtr writer,
    321                                      const xmlChar * name,
    322                                      const xmlChar * pubid,
    323                                      const xmlChar * sysid,
    324                                      const char *format, va_list argptr)
    325 				     LIBXML_ATTR_FORMAT(5,0);
    326     XMLPUBFUN int XMLCALL
    327         xmlTextWriterWriteDTD(xmlTextWriterPtr writer,
    328                               const xmlChar * name,
    329                               const xmlChar * pubid,
    330                               const xmlChar * sysid,
    331                               const xmlChar * subset);
    332 
    333 /**
    334  * xmlTextWriterWriteDocType:
    335  *
    336  * this macro maps to xmlTextWriterWriteDTD
    337  */
    338 #define xmlTextWriterWriteDocType xmlTextWriterWriteDTD
    339 
    340 /*
    341  * DTD element definition
    342  */
    343     XMLPUBFUN int XMLCALL
    344         xmlTextWriterStartDTDElement(xmlTextWriterPtr writer,
    345                                      const xmlChar * name);
    346     XMLPUBFUN int XMLCALL xmlTextWriterEndDTDElement(xmlTextWriterPtr
    347                                                      writer);
    348 
    349 /*
    350  * DTD element definition conveniency functions
    351  */
    352     XMLPUBFUN int XMLCALL
    353         xmlTextWriterWriteFormatDTDElement(xmlTextWriterPtr writer,
    354                                            const xmlChar * name,
    355                                            const char *format, ...)
    356 					   LIBXML_ATTR_FORMAT(3,4);
    357     XMLPUBFUN int XMLCALL
    358         xmlTextWriterWriteVFormatDTDElement(xmlTextWriterPtr writer,
    359                                             const xmlChar * name,
    360                                             const char *format,
    361                                             va_list argptr)
    362 					    LIBXML_ATTR_FORMAT(3,0);
    363     XMLPUBFUN int XMLCALL xmlTextWriterWriteDTDElement(xmlTextWriterPtr
    364                                                        writer,
    365                                                        const xmlChar *
    366                                                        name,
    367                                                        const xmlChar *
    368                                                        content);
    369 
    370 /*
    371  * DTD attribute list definition
    372  */
    373     XMLPUBFUN int XMLCALL
    374         xmlTextWriterStartDTDAttlist(xmlTextWriterPtr writer,
    375                                      const xmlChar * name);
    376     XMLPUBFUN int XMLCALL xmlTextWriterEndDTDAttlist(xmlTextWriterPtr
    377                                                      writer);
    378 
    379 /*
    380  * DTD attribute list definition conveniency functions
    381  */
    382     XMLPUBFUN int XMLCALL
    383         xmlTextWriterWriteFormatDTDAttlist(xmlTextWriterPtr writer,
    384                                            const xmlChar * name,
    385                                            const char *format, ...)
    386 					   LIBXML_ATTR_FORMAT(3,4);
    387     XMLPUBFUN int XMLCALL
    388         xmlTextWriterWriteVFormatDTDAttlist(xmlTextWriterPtr writer,
    389                                             const xmlChar * name,
    390                                             const char *format,
    391                                             va_list argptr)
    392 					    LIBXML_ATTR_FORMAT(3,0);
    393     XMLPUBFUN int XMLCALL xmlTextWriterWriteDTDAttlist(xmlTextWriterPtr
    394                                                        writer,
    395                                                        const xmlChar *
    396                                                        name,
    397                                                        const xmlChar *
    398                                                        content);
    399 
    400 /*
    401  * DTD entity definition
    402  */
    403     XMLPUBFUN int XMLCALL
    404         xmlTextWriterStartDTDEntity(xmlTextWriterPtr writer,
    405                                     int pe, const xmlChar * name);
    406     XMLPUBFUN int XMLCALL xmlTextWriterEndDTDEntity(xmlTextWriterPtr
    407                                                     writer);
    408 
    409 /*
    410  * DTD entity definition conveniency functions
    411  */
    412     XMLPUBFUN int XMLCALL
    413         xmlTextWriterWriteFormatDTDInternalEntity(xmlTextWriterPtr writer,
    414                                                   int pe,
    415                                                   const xmlChar * name,
    416                                                   const char *format, ...)
    417 						  LIBXML_ATTR_FORMAT(4,5);
    418     XMLPUBFUN int XMLCALL
    419         xmlTextWriterWriteVFormatDTDInternalEntity(xmlTextWriterPtr writer,
    420                                                    int pe,
    421                                                    const xmlChar * name,
    422                                                    const char *format,
    423                                                    va_list argptr)
    424 						   LIBXML_ATTR_FORMAT(4,0);
    425     XMLPUBFUN int XMLCALL
    426         xmlTextWriterWriteDTDInternalEntity(xmlTextWriterPtr writer,
    427                                             int pe,
    428                                             const xmlChar * name,
    429                                             const xmlChar * content);
    430     XMLPUBFUN int XMLCALL
    431         xmlTextWriterWriteDTDExternalEntity(xmlTextWriterPtr writer,
    432                                             int pe,
    433                                             const xmlChar * name,
    434                                             const xmlChar * pubid,
    435                                             const xmlChar * sysid,
    436                                             const xmlChar * ndataid);
    437     XMLPUBFUN int XMLCALL
    438         xmlTextWriterWriteDTDExternalEntityContents(xmlTextWriterPtr
    439                                                     writer,
    440                                                     const xmlChar * pubid,
    441                                                     const xmlChar * sysid,
    442                                                     const xmlChar *
    443                                                     ndataid);
    444     XMLPUBFUN int XMLCALL xmlTextWriterWriteDTDEntity(xmlTextWriterPtr
    445                                                       writer, int pe,
    446                                                       const xmlChar * name,
    447                                                       const xmlChar *
    448                                                       pubid,
    449                                                       const xmlChar *
    450                                                       sysid,
    451                                                       const xmlChar *
    452                                                       ndataid,
    453                                                       const xmlChar *
    454                                                       content);
    455 
    456 /*
    457  * DTD notation definition
    458  */
    459     XMLPUBFUN int XMLCALL
    460         xmlTextWriterWriteDTDNotation(xmlTextWriterPtr writer,
    461                                       const xmlChar * name,
    462                                       const xmlChar * pubid,
    463                                       const xmlChar * sysid);
    464 
    465 /*
    466  * Indentation
    467  */
    468     XMLPUBFUN int XMLCALL
    469         xmlTextWriterSetIndent(xmlTextWriterPtr writer, int indent);
    470     XMLPUBFUN int XMLCALL
    471         xmlTextWriterSetIndentString(xmlTextWriterPtr writer,
    472                                      const xmlChar * str);
    473 
    474 /*
    475  * misc
    476  */
    477     XMLPUBFUN int XMLCALL xmlTextWriterFlush(xmlTextWriterPtr writer);
    478 
    479 #ifdef __cplusplus
    480 }
    481 #endif
    482 
    483 #endif /* LIBXML_WRITER_ENABLED */
    484 
    485 #endif                          /* __XML_XMLWRITER_H__ */
    486