Gnome XML Library Reference Manual
<<< Previous Page | Home | Up | Next Page >>>

# xmlIO

## Name

xmlIO --

## Synopsis

    int         (*xmlInputMatchCallback)        (char const *filename);
    void*       (*xmlInputOpenCallback)         (char const *filename);
    int         (*xmlInputReadCallback)         (void *context,
                                                 char *buffer,
                                                 int len);
    void        (*xmlInputCloseCallback)        (void *context);
    struct      xmlParserInputBuffer;
    typedef     xmlParserInputBufferPtr;
    int         (*xmlOutputMatchCallback)       (char const *filename);
    void*       (*xmlOutputOpenCallback)        (char const *filename);
    int         (*xmlOutputWriteCallback)       (void *context,
                                                 const char *buffer,
                                                 int len);
    void        (*xmlOutputCloseCallback)       (void *context);
    struct      xmlOutputBuffer;
    typedef     xmlOutputBufferPtr;
    void        xmlRegisterDefaultInputCallbacks
                                                (void);
    xmlParserInputBufferPtr xmlAllocParserInputBuffer
                                                (xmlCharEncoding enc);
    xmlParserInputBufferPtr xmlParserInputBufferCreateFname
                                                (const char *URI,
                                                 xmlCharEncoding enc);
    xmlParserInputBufferPtr xmlParserInputBufferCreateFilename
                                                (const char *URI,
                                                 xmlCharEncoding enc);
    xmlParserInputBufferPtr xmlParserInputBufferCreateFile
                                                (FILE *file,
                                                 xmlCharEncoding enc);
    xmlParserInputBufferPtr xmlParserInputBufferCreateFd
                                                (int fd,
                                                 xmlCharEncoding enc);
    xmlParserInputBufferPtr xmlParserInputBufferCreateMem
                                                (const char *mem,
                                                 int size,
                                                 xmlCharEncoding enc);
    xmlParserInputBufferPtr xmlParserInputBufferCreateIO
                                                (xmlInputReadCallback ioread,
                                                 xmlInputCloseCallback ioclose,
                                                 void *ioctx,
                                                 xmlCharEncoding enc);
    int         xmlParserInputBufferRead        (xmlParserInputBufferPtr in,
                                                 int len);
    int         xmlParserInputBufferGrow        (xmlParserInputBufferPtr in,
                                                 int len);
    int         xmlParserInputBufferPush        (xmlParserInputBufferPtr in,
                                                 int len,
                                                 const char *buf);
    void        xmlFreeParserInputBuffer        (xmlParserInputBufferPtr in);
    char*       xmlParserGetDirectory           (const char *filename);
    int         xmlRegisterInputCallbacks       (xmlInputMatchCallback match,
                                                 xmlInputOpenCallback open,
                                                 xmlInputReadCallback read,
                                                 xmlInputCloseCallback close);
    void        xmlRegisterDefaultOutputCallbacks
                                                (void);
    xmlOutputBufferPtr xmlAllocOutputBuffer     (xmlCharEncodingHandlerPtr encoder);
    xmlOutputBufferPtr xmlOutputBufferCreateFilename
                                                (const char *URI,
                                                 xmlCharEncodingHandlerPtr encoder,
                                                 int compression);
    xmlOutputBufferPtr xmlOutputBufferCreateFile
                                                (FILE *file,
                                                 xmlCharEncodingHandlerPtr encoder);
    xmlOutputBufferPtr xmlOutputBufferCreateFd  (int fd,
                                                 xmlCharEncodingHandlerPtr encoder);
    xmlOutputBufferPtr xmlOutputBufferCreateIO  (xmlOutputWriteCallback iowrite,
                                                 xmlOutputCloseCallback ioclose,
                                                 void *ioctx,
                                                 xmlCharEncodingHandlerPtr encoder);
    int         xmlOutputBufferWrite            (xmlOutputBufferPtr out,
                                                 int len,
                                                 const char *buf);
    int         xmlOutputBufferWriteString      (xmlOutputBufferPtr out,
                                                 const char *str);
    int         xmlOutputBufferFlush            (xmlOutputBufferPtr out);
    int         xmlOutputBufferClose            (xmlOutputBufferPtr out);
    int         xmlRegisterOutputCallbacks      (xmlOutputMatchCallback match,
                                                 xmlOutputOpenCallback open,
                                                 xmlOutputWriteCallback write,
                                                 xmlOutputCloseCallback close);
    int         xmlSaveFileTo                   (xmlOutputBuffer *buf,
                                                 xmlDocPtr cur,
                                                 const char *encoding);
    void        xmlNodeDumpOutput               (xmlOutputBufferPtr buf,
                                                 xmlDocPtr doc,
                                                 xmlNodePtr cur,
                                                 int level,
                                                 int format,
                                                 const char *encoding);

## Description

## Details

### xmlInputMatchCallback ()

    int         (*xmlInputMatchCallback)        (char const *filename);

`filename` : |
Returns : |

### xmlInputOpenCallback ()

    void*       (*xmlInputOpenCallback)         (char const *filename);

`filename` : |

### xmlInputReadCallback ()

    int         (*xmlInputReadCallback)         (void *context,
                                                 char *buffer,
                                                 int len);

`context` : |
`buffer` : |
`len` : |
Returns : |

### xmlInputCloseCallback ()

    void        (*xmlInputCloseCallback)        (void *context);

`context` : |

### struct xmlParserInputBuffer

    struct xmlParserInputBuffer {
        void*                  context;
        xmlInputReadCallback   readcallback;
        xmlInputCloseCallback  closecallback;

        xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */

        xmlBufferPtr buffer;    /* Local buffer encoded in UTF-8 */
        xmlBufferPtr raw;       /* if encoder != NULL buffer for raw input */
    };

### xmlParserInputBufferPtr

    typedef xmlParserInputBuffer *xmlParserInputBufferPtr;

### xmlOutputMatchCallback ()

    int         (*xmlOutputMatchCallback)       (char const *filename);

`filename` : |
Returns : |

### xmlOutputOpenCallback ()

    void*       (*xmlOutputOpenCallback)        (char const *filename);

`filename` : |

### xmlOutputWriteCallback ()

    int         (*xmlOutputWriteCallback)       (void *context,
                                                 const char *buffer,
                                                 int len);

`context` : |
`buffer` : |
`len` : |
Returns : |

### xmlOutputCloseCallback ()

    void        (*xmlOutputCloseCallback)       (void *context);

`context` : |

### struct xmlOutputBuffer

    struct xmlOutputBuffer {
        void*                   context;
        xmlOutputWriteCallback  writecallback;
        xmlOutputCloseCallback  closecallback;

        xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */

        xmlBufferPtr buffer;    /* Local buffer encoded in UTF-8 or ISOLatin */
        xmlBufferPtr conv;      /* if encoder != NULL buffer for output */
        int written;            /* total number of byte written */
    };

### xmlOutputBufferPtr

    typedef xmlOutputBuffer *xmlOutputBufferPtr;

### xmlRegisterDefaultInputCallbacks ()

    void        xmlRegisterDefaultInputCallbacks
                                                (void);

Registers the default compiled-in I/O handlers.

### xmlAllocParserInputBuffer ()

    xmlParserInputBufferPtr xmlAllocParserInputBuffer
                                                (xmlCharEncoding enc);

Create a buffered parser input for progressive parsing

`enc` : | the charset encoding if known
Returns : | the new parser input or NULL

### xmlParserInputBufferCreateFname ()

    xmlParserInputBufferPtr xmlParserInputBufferCreateFname
                                                (const char *URI,
                                                 xmlCharEncoding enc);

`URI` : |
`enc` : |
Returns : |

### xmlParserInputBufferCreateFilename ()

    xmlParserInputBufferPtr xmlParserInputBufferCreateFilename
                                                (const char *URI,
                                                 xmlCharEncoding enc);

Create a buffered parser input for the progressive parsing of a file If filename is "-' then we use stdin as the input. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time. Do an encoding check if enc == XML_CHAR_ENCODING_NONE

`URI` : | a C string containing the URI or filename
`enc` : | the charset encoding if known
Returns : | the new parser input or NULL

### xmlParserInputBufferCreateFile ()

    xmlParserInputBufferPtr xmlParserInputBufferCreateFile
                                                (FILE *file,
                                                 xmlCharEncoding enc);

Create a buffered parser input for the progressive parsing of a FILE * buffered C I/O

`file` : | a FILE*
`enc` : | the charset encoding if known
Returns : | the new parser input or NULL

### xmlParserInputBufferCreateFd ()

    xmlParserInputBufferPtr xmlParserInputBufferCreateFd
                                                (int fd,
                                                 xmlCharEncoding enc);

Create a buffered parser input for the progressive parsing for the input from a file descriptor

`fd` : | a file descriptor number
`enc` : | the charset encoding if known
Returns : | the new parser input or NULL

### xmlParserInputBufferCreateMem ()

    xmlParserInputBufferPtr xmlParserInputBufferCreateMem
                                                (const char *mem,
                                                 int size,
                                                 xmlCharEncoding enc);

Create a buffered parser input for the progressive parsing for the input from a memory area.

`mem` : | the memory input
`size` : | the length of the memory block
`enc` : | the charset encoding if known
Returns : | the new parser input or NULL

### xmlParserInputBufferCreateIO ()

    xmlParserInputBufferPtr xmlParserInputBufferCreateIO
                                                (xmlInputReadCallback ioread,
                                                 xmlInputCloseCallback ioclose,
                                                 void *ioctx,
                                                 xmlCharEncoding enc);

Create a buffered parser input for the progressive parsing for the input from an I/O handler

`ioread` : | an I/O read function
`ioclose` : | an I/O close function
`ioctx` : | an I/O handler
`enc` : | the charset encoding if known
Returns : | the new parser input or NULL

### xmlParserInputBufferRead ()

    int         xmlParserInputBufferRead        (xmlParserInputBufferPtr in,
                                                 int len);

Refresh the content of the input buffer, the old data are considered consumed This routine handle the I18N transcoding to internal UTF-8

`in` : | a buffered parser input
`len` : | indicative value of the amount of chars to read
Returns : | the number of chars read and stored in the buffer, or -1 in case of error.

### xmlParserInputBufferGrow ()

    int         xmlParserInputBufferGrow        (xmlParserInputBufferPtr in,
                                                 int len);

Grow up the content of the input buffer, the old data are preserved This routine handle the I18N transcoding to internal UTF-8 This routine is used when operating the parser in normal (pull) mode

TODO: one should be able to remove one extra copy by copying directy onto in->buffer or in->raw

`in` : | a buffered parser input
`len` : | indicative value of the amount of chars to read
Returns : | the number of chars read and stored in the buffer, or -1 in case of error.

### xmlParserInputBufferPush ()

    int         xmlParserInputBufferPush        (xmlParserInputBufferPtr in,
                                                 int len,
                                                 const char *buf);

Push the content of the arry in the input buffer This routine handle the I18N transcoding to internal UTF-8 This is used when operating the parser in progressive (push) mode.

`in` : | a buffered parser input
`len` : | the size in bytes of the array.
`buf` : | an char array
Returns : | the number of chars read and stored in the buffer, or -1 in case of error.

### xmlFreeParserInputBuffer ()

    void        xmlFreeParserInputBuffer        (xmlParserInputBufferPtr in);

Free up the memory used by a buffered parser input

`in` : | a buffered parser input

### xmlParserGetDirectory ()

    char*       xmlParserGetDirectory           (const char *filename);

`filename` : |
Returns : |

### xmlRegisterInputCallbacks ()

    int         xmlRegisterInputCallbacks       (xmlInputMatchCallback match,
                                                 xmlInputOpenCallback open,
                                                 xmlInputReadCallback read,
                                                 xmlInputCloseCallback close);

Register a new set of I/O callback for handling parser input.

`match` : | the xmlInputMatchCallback
`open` : | the xmlInputOpenCallback
`read` : | the xmlInputReadCallback
`close` : | the xmlInputCloseCallback
Returns : | the registered handler number or -1 in case of error

### xmlRegisterDefaultOutputCallbacks ()

    void        xmlRegisterDefaultOutputCallbacks
                                                (void);

Registers the default compiled-in I/O handlers.

### xmlAllocOutputBuffer ()

    xmlOutputBufferPtr xmlAllocOutputBuffer     (xmlCharEncodingHandlerPtr encoder);

Create a buffered parser output

`encoder` : | the encoding converter or NULL
Returns : | the new parser output or NULL

### xmlOutputBufferCreateFilename ()

    xmlOutputBufferPtr xmlOutputBufferCreateFilename
                                                (const char *URI,
                                                 xmlCharEncodingHandlerPtr encoder,
                                                 int compression);

Create a buffered output for the progressive saving of a file If filename is "-' then we use stdout as the output. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time. TODO: currently if compression is set, the library only support writing to a local file.

`URI` : | a C string containing the URI or filename
`encoder` : | the encoding converter or NULL
`compression` : | the compression ration (0 none, 9 max).
Returns : | the new output or NULL

### xmlOutputBufferCreateFile ()

    xmlOutputBufferPtr xmlOutputBufferCreateFile
                                                (FILE *file,
                                                 xmlCharEncodingHandlerPtr encoder);

Create a buffered output for the progressive saving to a FILE * buffered C I/O

`file` : | a FILE*
`encoder` : | the encoding converter or NULL
Returns : | the new parser output or NULL

### xmlOutputBufferCreateFd ()

    xmlOutputBufferPtr xmlOutputBufferCreateFd  (int fd,
                                                 xmlCharEncodingHandlerPtr encoder);

Create a buffered output for the progressive saving to a file descriptor

`fd` : | a file descriptor number
`encoder` : | the encoding converter or NULL
Returns : | the new parser output or NULL

### xmlOutputBufferCreateIO ()

    xmlOutputBufferPtr xmlOutputBufferCreateIO  (xmlOutputWriteCallback iowrite,
                                                 xmlOutputCloseCallback ioclose,
                                                 void *ioctx,
                                                 xmlCharEncodingHandlerPtr encoder);

Create a buffered output for the progressive saving to an I/O handler

`iowrite` : | an I/O write function
`ioclose` : | an I/O close function
`ioctx` : | an I/O handler
`encoder` : |
Returns : | the new parser output or NULL

### xmlOutputBufferWrite ()

    int         xmlOutputBufferWrite            (xmlOutputBufferPtr out,
                                                 int len,
                                                 const char *buf);

Write the content of the array in the output I/O buffer This routine handle the I18N transcoding from internal UTF-8 The buffer is lossless, i.e. will store in case of partial or delayed writes.

`out` : | a buffered parser output
`len` : | the size in bytes of the array.
`buf` : | an char array
Returns : | the number of chars immediately written, or -1 in case of error.

### xmlOutputBufferWriteString ()

    int         xmlOutputBufferWriteString      (xmlOutputBufferPtr out,
                                                 const char *str);

Write the content of the string in the output I/O buffer This routine handle the I18N transcoding from internal UTF-8 The buffer is lossless, i.e. will store in case of partial or delayed writes.

`out` : | a buffered parser output
`str` : | a zero terminated C string
Returns : | the number of chars immediately written, or -1 in case of error.

### xmlOutputBufferFlush ()

    int         xmlOutputBufferFlush            (xmlOutputBufferPtr out);

flushes the output I/O channel

`out` : | a buffered output
Returns : | the number of byte written or -1 in case of error.

### xmlOutputBufferClose ()

    int         xmlOutputBufferClose            (xmlOutputBufferPtr out);

flushes and close the output I/O channel and free up all the associated resources

`out` : | a buffered output
Returns : | the number of byte written or -1 in case of error.

### xmlRegisterOutputCallbacks ()

    int         xmlRegisterOutputCallbacks      (xmlOutputMatchCallback match,
                                                 xmlOutputOpenCallback open,
                                                 xmlOutputWriteCallback write,
                                                 xmlOutputCloseCallback close);

Register a new set of I/O callback for handling output.

`match` : | the xmlOutputMatchCallback
`open` : | the xmlOutputOpenCallback
`write` : | the xmlOutputWriteCallback
`close` : | the xmlOutputCloseCallback
Returns : | the registered handler number or -1 in case of error

### xmlSaveFileTo ()

    int         xmlSaveFileTo                   (xmlOutputBuffer *buf,
                                                 xmlDocPtr cur,
                                                 const char *encoding);

Dump an XML document to an I/O buffer.

`buf` : | an output I/O buffer
`cur` : | the document
`encoding` : | the encoding if any assuming the i/O layer handles the trancoding
Returns : | the number of byte written or -1 in case of failure.

### xmlNodeDumpOutput ()

    void        xmlNodeDumpOutput               (xmlOutputBufferPtr buf,
                                                 xmlDocPtr doc,
                                                 xmlNodePtr cur,
                                                 int level,
                                                 int format,
                                                 const char *encoding);

Dump an XML node, recursive behaviour,children are printed too.

`buf` : | the XML buffer output
`doc` : | the document
`cur` : | the current node
`level` : | the imbrication level for indenting
`format` : | is formatting allowed
`encoding` : | an optional encoding string

<<< Previous Page | Home | Up | Next Page >>>
nanoftp | parserInternals