libmobi
C library for handling MOBI format ebook documents
Data Structures | Macros | Typedefs | Enumerations | Functions
xmlwriter.h File Reference
#include <stdio.h>
#include "buffer.h"
#include "structure.h"

Go to the source code of this file.

Data Structures

struct  xmlBuffer
 Buffer for xml output. For libxml2 compatibility, it is a wrapper for MOBIBuffer. More...
 
struct  MOBIXmlState
 Xml writer states list structure First element in the list is currently processed element. Last element is root of the document. More...
 
struct  xmlTextWriter
 Xml TextWriter structure. More...
 

Macros

#define BAD_CAST   (xmlChar *)
 
#define LIBXML_TEST_VERSION
 
#define xmlCleanupParser()
 

Typedefs

typedef unsigned char xmlChar
 
typedef xmlBufferxmlBufferPtr
 
typedef struct MOBIXmlState MOBIXmlState
 Xml writer states list structure First element in the list is currently processed element. Last element is root of the document.
 
typedef xmlTextWriterxmlTextWriterPtr
 

Enumerations

enum  MOBI_XML_MODE { MOBI_XMLMODE_NONE = 0 , MOBI_XMLMODE_NAME , MOBI_XMLMODE_ATTR , MOBI_XMLMODE_TEXT }
 Xml writer states.
 

Functions

xmlBufferPtr xmlBufferCreate (void)
 Create xml buffer. More...
 
void xmlBufferFree (xmlBufferPtr buf)
 Free XML buffer. More...
 
xmlTextWriterPtr xmlNewTextWriterMemory (xmlBufferPtr xmlbuf, int compression)
 Initialize TextWriter structure. More...
 
void xmlFreeTextWriter (xmlTextWriterPtr writer)
 Deallocate TextWriter instance and all its resources. More...
 
int xmlTextWriterStartDocument (xmlTextWriterPtr writer, const char *version, const char *encoding, const char *standalone)
 Start xml document. More...
 
int xmlTextWriterEndDocument (xmlTextWriterPtr writer)
 End xml document. More...
 
int xmlTextWriterStartElement (xmlTextWriterPtr writer, const xmlChar *name)
 Start xml element. More...
 
int xmlTextWriterEndElement (xmlTextWriterPtr writer)
 End current element. More...
 
int xmlTextWriterWriteAttribute (xmlTextWriterPtr writer, const xmlChar *name, const xmlChar *content)
 Write attribute with given name and content. More...
 
int xmlTextWriterEndAttribute (xmlTextWriterPtr writer)
 End current attribute. More...
 
int xmlTextWriterWriteAttributeNS (xmlTextWriterPtr writer, const xmlChar *prefix, const xmlChar *name, const xmlChar *namespaceURI, const xmlChar *content)
 Write attribute with namespace support. More...
 
int xmlTextWriterStartElementNS (xmlTextWriterPtr writer, const xmlChar *prefix, const xmlChar *name, const xmlChar *namespaceURI)
 Start element with namespace support. More...
 
int xmlTextWriterWriteElementNS (xmlTextWriterPtr writer, const xmlChar *prefix, const xmlChar *name, const xmlChar *namespaceURI, const xmlChar *content)
 Write element with namespace support. More...
 
int xmlTextWriterWriteString (xmlTextWriterPtr writer, const xmlChar *content)
 Write xml string. More...
 
int xmlTextWriterSetIndent (xmlTextWriterPtr writer, int indent)
 Set indentation option. More...
 

Detailed Description

Copyright (c) 2016 Bartek Fabiszewski http://www.fabiszewski.net

This file is part of libmobi. Licensed under LGPL, either version 3, or any later. See http://www.gnu.org/licenses/

Function Documentation

◆ xmlBufferCreate()

xmlBufferPtr xmlBufferCreate ( void  )

Create xml buffer.

Libxml2 compatibility wrapper for MOBIBuffer structure. Must be deallocated with xmlBufferFree

Returns
Buffer pointer

◆ xmlBufferFree()

void xmlBufferFree ( xmlBufferPtr  buf)

Free XML buffer.

Parameters
[in,out]bufXML buffer

◆ xmlFreeTextWriter()

void xmlFreeTextWriter ( xmlTextWriterPtr  writer)

Deallocate TextWriter instance and all its resources.

Parameters
[in,out]writerTextWriter

◆ xmlNewTextWriterMemory()

xmlTextWriterPtr xmlNewTextWriterMemory ( xmlBufferPtr  xmlbuf,
int  compression 
)

Initialize TextWriter structure.

Parameters
[in]xmlbufInitialized xml output buffer
[in]compressionUnused
Returns
TextWriter pointer

◆ xmlTextWriterEndAttribute()

int xmlTextWriterEndAttribute ( xmlTextWriterPtr  writer)

End current attribute.

Parameters
[in,out]writerTextWriter
Returns
XML_OK (0) on success, XML_ERROR (-1) on failure

◆ xmlTextWriterEndDocument()

int xmlTextWriterEndDocument ( xmlTextWriterPtr  writer)

End xml document.

All open elements will be closed. xmlBuffer will be flushed.

Parameters
[in]writerTextWriter
Returns
XML_OK (0) on success, XML_ERROR (-1) on failure

◆ xmlTextWriterEndElement()

int xmlTextWriterEndElement ( xmlTextWriterPtr  writer)

End current element.

Parameters
[in]writerTextWriter
Returns
XML_OK (0) on success, XML_ERROR (-1) on failure

◆ xmlTextWriterSetIndent()

int xmlTextWriterSetIndent ( xmlTextWriterPtr  writer,
int  indent 
)

Set indentation option.

Parameters
[in,out]writerTextWriter
[in]indentIndent output if value greater than zero
Returns
XML_OK (0) on success, XML_ERROR (-1) on failure

◆ xmlTextWriterStartDocument()

int xmlTextWriterStartDocument ( xmlTextWriterPtr  writer,
const char *  version,
const char *  encoding,
const char *  standalone 
)

Start xml document.

Only utf-8 encoding supported.

Parameters
[in]writerTextWriter
[in]versionValue of version attribute, "1.0" if NULL
[in]encodingUnused, defaults to utf-8
[in]standaloneUnused, omitted in declaration
Returns
TextWriter pointer

◆ xmlTextWriterStartElement()

int xmlTextWriterStartElement ( xmlTextWriterPtr  writer,
const xmlChar *  name 
)

Start xml element.

Parameters
[in,out]writerTextWriter
[in]nameElement name
Returns
XML_OK (0) on success, XML_ERROR (-1) on failure

◆ xmlTextWriterStartElementNS()

int xmlTextWriterStartElementNS ( xmlTextWriterPtr  writer,
const xmlChar *  prefix,
const xmlChar *  name,
const xmlChar *  namespaceURI 
)

Start element with namespace support.

Parameters
[in,out]writerTextWriter
[in]prefixNamespace prefix or NULL
[in]nameElement name
[in]namespaceURINamespace uri or NULL
Returns
XML_OK (0) on success, XML_ERROR (-1) on failure

◆ xmlTextWriterWriteAttribute()

int xmlTextWriterWriteAttribute ( xmlTextWriterPtr  writer,
const xmlChar *  name,
const xmlChar *  content 
)

Write attribute with given name and content.

Parameters
[in,out]writerTextWriter
[in]nameAttribute name
[in]contentAttribute content
Returns
XML_OK (0) on success, XML_ERROR (-1) on failure

◆ xmlTextWriterWriteAttributeNS()

int xmlTextWriterWriteAttributeNS ( xmlTextWriterPtr  writer,
const xmlChar *  prefix,
const xmlChar *  name,
const xmlChar *  namespaceURI,
const xmlChar *  content 
)

Write attribute with namespace support.

Parameters
[in,out]writerTextWriter
[in]prefixNamespace prefix or NULL
[in]nameAttribute name
[in]namespaceURINamespace uri or NULL
[in]contentAttribute content
Returns
XML_OK (0) on success, XML_ERROR (-1) on failure

◆ xmlTextWriterWriteElementNS()

int xmlTextWriterWriteElementNS ( xmlTextWriterPtr  writer,
const xmlChar *  prefix,
const xmlChar *  name,
const xmlChar *  namespaceURI,
const xmlChar *  content 
)

Write element with namespace support.

Parameters
[in,out]writerTextWriter
[in]prefixNamespace prefix or NULL
[in]nameElement name
[in]namespaceURINamespace uri or NULL
[in]contentElement content
Returns
XML_OK (0) on success, XML_ERROR (-1) on failure

◆ xmlTextWriterWriteString()

int xmlTextWriterWriteString ( xmlTextWriterPtr  writer,
const xmlChar *  content 
)

Write xml string.

Parameters
[in,out]writerTextWriter
[in]contentAttribute content
Returns
XML_OK (0) on success, XML_ERROR (-1) on failure