Path: blob/master/libs/xml2/include/libxml/xmlreader.h
4394 views
/*1* Summary: the XMLReader implementation2* Description: API of the XML streaming API based on C# interfaces.3*4* Copy: See Copyright for the status of this software.5*6* Author: Daniel Veillard7*/89#ifndef __XML_XMLREADER_H__10#define __XML_XMLREADER_H__1112#include <libxml/xmlversion.h>13#include <libxml/tree.h>14#include <libxml/xmlerror.h>15#include <libxml/xmlIO.h>16#ifdef LIBXML_SCHEMAS_ENABLED17#include <libxml/relaxng.h>18#include <libxml/xmlschemas.h>19#endif20/* for compatibility */21#include <libxml/parser.h>2223#ifdef __cplusplus24extern "C" {25#endif2627/**28* xmlParserSeverities:29*30* How severe an error callback is when the per-reader error callback API31* is used.32*/33typedef enum {34XML_PARSER_SEVERITY_VALIDITY_WARNING = 1,35XML_PARSER_SEVERITY_VALIDITY_ERROR = 2,36XML_PARSER_SEVERITY_WARNING = 3,37XML_PARSER_SEVERITY_ERROR = 438} xmlParserSeverities;3940#ifdef LIBXML_READER_ENABLED4142/**43* xmlTextReaderMode:44*45* Internal state values for the reader.46*/47typedef enum {48XML_TEXTREADER_MODE_INITIAL = 0,49XML_TEXTREADER_MODE_INTERACTIVE = 1,50XML_TEXTREADER_MODE_ERROR = 2,51XML_TEXTREADER_MODE_EOF =3,52XML_TEXTREADER_MODE_CLOSED = 4,53XML_TEXTREADER_MODE_READING = 554} xmlTextReaderMode;5556/**57* xmlParserProperties:58*59* Some common options to use with xmlTextReaderSetParserProp, but it60* is better to use xmlParserOption and the xmlReaderNewxxx and61* xmlReaderForxxx APIs now.62*/63typedef enum {64XML_PARSER_LOADDTD = 1,65XML_PARSER_DEFAULTATTRS = 2,66XML_PARSER_VALIDATE = 3,67XML_PARSER_SUBST_ENTITIES = 468} xmlParserProperties;6970/**71* xmlReaderTypes:72*73* Predefined constants for the different types of nodes.74*/75typedef enum {76XML_READER_TYPE_NONE = 0,77XML_READER_TYPE_ELEMENT = 1,78XML_READER_TYPE_ATTRIBUTE = 2,79XML_READER_TYPE_TEXT = 3,80XML_READER_TYPE_CDATA = 4,81XML_READER_TYPE_ENTITY_REFERENCE = 5,82XML_READER_TYPE_ENTITY = 6,83XML_READER_TYPE_PROCESSING_INSTRUCTION = 7,84XML_READER_TYPE_COMMENT = 8,85XML_READER_TYPE_DOCUMENT = 9,86XML_READER_TYPE_DOCUMENT_TYPE = 10,87XML_READER_TYPE_DOCUMENT_FRAGMENT = 11,88XML_READER_TYPE_NOTATION = 12,89XML_READER_TYPE_WHITESPACE = 13,90XML_READER_TYPE_SIGNIFICANT_WHITESPACE = 14,91XML_READER_TYPE_END_ELEMENT = 15,92XML_READER_TYPE_END_ENTITY = 16,93XML_READER_TYPE_XML_DECLARATION = 1794} xmlReaderTypes;9596/**97* xmlTextReader:98*99* Structure for an xmlReader context.100*/101typedef struct _xmlTextReader xmlTextReader;102103/**104* xmlTextReaderPtr:105*106* Pointer to an xmlReader context.107*/108typedef xmlTextReader *xmlTextReaderPtr;109110/*111* Constructors & Destructor112*/113XMLPUBFUN xmlTextReaderPtr114xmlNewTextReader (xmlParserInputBufferPtr input,115const char *URI);116XMLPUBFUN xmlTextReaderPtr117xmlNewTextReaderFilename(const char *URI);118119XMLPUBFUN void120xmlFreeTextReader (xmlTextReaderPtr reader);121122XMLPUBFUN int123xmlTextReaderSetup(xmlTextReaderPtr reader,124xmlParserInputBufferPtr input, const char *URL,125const char *encoding, int options);126XMLPUBFUN void127xmlTextReaderSetMaxAmplification(xmlTextReaderPtr reader,128unsigned maxAmpl);129130/*131* Iterators132*/133XMLPUBFUN int134xmlTextReaderRead (xmlTextReaderPtr reader);135136#ifdef LIBXML_WRITER_ENABLED137XMLPUBFUN xmlChar *138xmlTextReaderReadInnerXml(xmlTextReaderPtr reader);139140XMLPUBFUN xmlChar *141xmlTextReaderReadOuterXml(xmlTextReaderPtr reader);142#endif143144XMLPUBFUN xmlChar *145xmlTextReaderReadString (xmlTextReaderPtr reader);146XMLPUBFUN int147xmlTextReaderReadAttributeValue(xmlTextReaderPtr reader);148149/*150* Attributes of the node151*/152XMLPUBFUN int153xmlTextReaderAttributeCount(xmlTextReaderPtr reader);154XMLPUBFUN int155xmlTextReaderDepth (xmlTextReaderPtr reader);156XMLPUBFUN int157xmlTextReaderHasAttributes(xmlTextReaderPtr reader);158XMLPUBFUN int159xmlTextReaderHasValue(xmlTextReaderPtr reader);160XMLPUBFUN int161xmlTextReaderIsDefault (xmlTextReaderPtr reader);162XMLPUBFUN int163xmlTextReaderIsEmptyElement(xmlTextReaderPtr reader);164XMLPUBFUN int165xmlTextReaderNodeType (xmlTextReaderPtr reader);166XMLPUBFUN int167xmlTextReaderQuoteChar (xmlTextReaderPtr reader);168XMLPUBFUN int169xmlTextReaderReadState (xmlTextReaderPtr reader);170XMLPUBFUN int171xmlTextReaderIsNamespaceDecl(xmlTextReaderPtr reader);172173XMLPUBFUN const xmlChar *174xmlTextReaderConstBaseUri (xmlTextReaderPtr reader);175XMLPUBFUN const xmlChar *176xmlTextReaderConstLocalName (xmlTextReaderPtr reader);177XMLPUBFUN const xmlChar *178xmlTextReaderConstName (xmlTextReaderPtr reader);179XMLPUBFUN const xmlChar *180xmlTextReaderConstNamespaceUri(xmlTextReaderPtr reader);181XMLPUBFUN const xmlChar *182xmlTextReaderConstPrefix (xmlTextReaderPtr reader);183XMLPUBFUN const xmlChar *184xmlTextReaderConstXmlLang (xmlTextReaderPtr reader);185XMLPUBFUN const xmlChar *186xmlTextReaderConstString (xmlTextReaderPtr reader,187const xmlChar *str);188XMLPUBFUN const xmlChar *189xmlTextReaderConstValue (xmlTextReaderPtr reader);190191/*192* use the Const version of the routine for193* better performance and simpler code194*/195XMLPUBFUN xmlChar *196xmlTextReaderBaseUri (xmlTextReaderPtr reader);197XMLPUBFUN xmlChar *198xmlTextReaderLocalName (xmlTextReaderPtr reader);199XMLPUBFUN xmlChar *200xmlTextReaderName (xmlTextReaderPtr reader);201XMLPUBFUN xmlChar *202xmlTextReaderNamespaceUri(xmlTextReaderPtr reader);203XMLPUBFUN xmlChar *204xmlTextReaderPrefix (xmlTextReaderPtr reader);205XMLPUBFUN xmlChar *206xmlTextReaderXmlLang (xmlTextReaderPtr reader);207XMLPUBFUN xmlChar *208xmlTextReaderValue (xmlTextReaderPtr reader);209210/*211* Methods of the XmlTextReader212*/213XMLPUBFUN int214xmlTextReaderClose (xmlTextReaderPtr reader);215XMLPUBFUN xmlChar *216xmlTextReaderGetAttributeNo (xmlTextReaderPtr reader,217int no);218XMLPUBFUN xmlChar *219xmlTextReaderGetAttribute (xmlTextReaderPtr reader,220const xmlChar *name);221XMLPUBFUN xmlChar *222xmlTextReaderGetAttributeNs (xmlTextReaderPtr reader,223const xmlChar *localName,224const xmlChar *namespaceURI);225XMLPUBFUN xmlParserInputBufferPtr226xmlTextReaderGetRemainder (xmlTextReaderPtr reader);227XMLPUBFUN xmlChar *228xmlTextReaderLookupNamespace(xmlTextReaderPtr reader,229const xmlChar *prefix);230XMLPUBFUN int231xmlTextReaderMoveToAttributeNo(xmlTextReaderPtr reader,232int no);233XMLPUBFUN int234xmlTextReaderMoveToAttribute(xmlTextReaderPtr reader,235const xmlChar *name);236XMLPUBFUN int237xmlTextReaderMoveToAttributeNs(xmlTextReaderPtr reader,238const xmlChar *localName,239const xmlChar *namespaceURI);240XMLPUBFUN int241xmlTextReaderMoveToFirstAttribute(xmlTextReaderPtr reader);242XMLPUBFUN int243xmlTextReaderMoveToNextAttribute(xmlTextReaderPtr reader);244XMLPUBFUN int245xmlTextReaderMoveToElement (xmlTextReaderPtr reader);246XMLPUBFUN int247xmlTextReaderNormalization (xmlTextReaderPtr reader);248XMLPUBFUN const xmlChar *249xmlTextReaderConstEncoding (xmlTextReaderPtr reader);250251/*252* Extensions253*/254XMLPUBFUN int255xmlTextReaderSetParserProp (xmlTextReaderPtr reader,256int prop,257int value);258XMLPUBFUN int259xmlTextReaderGetParserProp (xmlTextReaderPtr reader,260int prop);261XMLPUBFUN xmlNodePtr262xmlTextReaderCurrentNode (xmlTextReaderPtr reader);263264XMLPUBFUN int265xmlTextReaderGetParserLineNumber(xmlTextReaderPtr reader);266267XMLPUBFUN int268xmlTextReaderGetParserColumnNumber(xmlTextReaderPtr reader);269270XMLPUBFUN xmlNodePtr271xmlTextReaderPreserve (xmlTextReaderPtr reader);272#ifdef LIBXML_PATTERN_ENABLED273XMLPUBFUN int274xmlTextReaderPreservePattern(xmlTextReaderPtr reader,275const xmlChar *pattern,276const xmlChar **namespaces);277#endif /* LIBXML_PATTERN_ENABLED */278XMLPUBFUN xmlDocPtr279xmlTextReaderCurrentDoc (xmlTextReaderPtr reader);280XMLPUBFUN xmlNodePtr281xmlTextReaderExpand (xmlTextReaderPtr reader);282XMLPUBFUN int283xmlTextReaderNext (xmlTextReaderPtr reader);284XMLPUBFUN int285xmlTextReaderNextSibling (xmlTextReaderPtr reader);286XMLPUBFUN int287xmlTextReaderIsValid (xmlTextReaderPtr reader);288#ifdef LIBXML_SCHEMAS_ENABLED289XMLPUBFUN int290xmlTextReaderRelaxNGValidate(xmlTextReaderPtr reader,291const char *rng);292XMLPUBFUN int293xmlTextReaderRelaxNGValidateCtxt(xmlTextReaderPtr reader,294xmlRelaxNGValidCtxtPtr ctxt,295int options);296297XMLPUBFUN int298xmlTextReaderRelaxNGSetSchema(xmlTextReaderPtr reader,299xmlRelaxNGPtr schema);300XMLPUBFUN int301xmlTextReaderSchemaValidate (xmlTextReaderPtr reader,302const char *xsd);303XMLPUBFUN int304xmlTextReaderSchemaValidateCtxt(xmlTextReaderPtr reader,305xmlSchemaValidCtxtPtr ctxt,306int options);307XMLPUBFUN int308xmlTextReaderSetSchema (xmlTextReaderPtr reader,309xmlSchemaPtr schema);310#endif311XMLPUBFUN const xmlChar *312xmlTextReaderConstXmlVersion(xmlTextReaderPtr reader);313XMLPUBFUN int314xmlTextReaderStandalone (xmlTextReaderPtr reader);315316317/*318* Index lookup319*/320XMLPUBFUN long321xmlTextReaderByteConsumed (xmlTextReaderPtr reader);322323/*324* New more complete APIs for simpler creation and reuse of readers325*/326XMLPUBFUN xmlTextReaderPtr327xmlReaderWalker (xmlDocPtr doc);328XMLPUBFUN xmlTextReaderPtr329xmlReaderForDoc (const xmlChar * cur,330const char *URL,331const char *encoding,332int options);333XMLPUBFUN xmlTextReaderPtr334xmlReaderForFile (const char *filename,335const char *encoding,336int options);337XMLPUBFUN xmlTextReaderPtr338xmlReaderForMemory (const char *buffer,339int size,340const char *URL,341const char *encoding,342int options);343XMLPUBFUN xmlTextReaderPtr344xmlReaderForFd (int fd,345const char *URL,346const char *encoding,347int options);348XMLPUBFUN xmlTextReaderPtr349xmlReaderForIO (xmlInputReadCallback ioread,350xmlInputCloseCallback ioclose,351void *ioctx,352const char *URL,353const char *encoding,354int options);355356XMLPUBFUN int357xmlReaderNewWalker (xmlTextReaderPtr reader,358xmlDocPtr doc);359XMLPUBFUN int360xmlReaderNewDoc (xmlTextReaderPtr reader,361const xmlChar * cur,362const char *URL,363const char *encoding,364int options);365XMLPUBFUN int366xmlReaderNewFile (xmlTextReaderPtr reader,367const char *filename,368const char *encoding,369int options);370XMLPUBFUN int371xmlReaderNewMemory (xmlTextReaderPtr reader,372const char *buffer,373int size,374const char *URL,375const char *encoding,376int options);377XMLPUBFUN int378xmlReaderNewFd (xmlTextReaderPtr reader,379int fd,380const char *URL,381const char *encoding,382int options);383XMLPUBFUN int384xmlReaderNewIO (xmlTextReaderPtr reader,385xmlInputReadCallback ioread,386xmlInputCloseCallback ioclose,387void *ioctx,388const char *URL,389const char *encoding,390int options);391/*392* Error handling extensions393*/394typedef void * xmlTextReaderLocatorPtr;395396/**397* xmlTextReaderErrorFunc:398* @arg: the user argument399* @msg: the message400* @severity: the severity of the error401* @locator: a locator indicating where the error occurred402*403* Signature of an error callback from a reader parser404*/405typedef void (*xmlTextReaderErrorFunc)(void *arg,406const char *msg,407xmlParserSeverities severity,408xmlTextReaderLocatorPtr locator);409XMLPUBFUN int410xmlTextReaderLocatorLineNumber(xmlTextReaderLocatorPtr locator);411XMLPUBFUN xmlChar *412xmlTextReaderLocatorBaseURI (xmlTextReaderLocatorPtr locator);413XMLPUBFUN void414xmlTextReaderSetErrorHandler(xmlTextReaderPtr reader,415xmlTextReaderErrorFunc f,416void *arg);417XMLPUBFUN void418xmlTextReaderSetStructuredErrorHandler(xmlTextReaderPtr reader,419xmlStructuredErrorFunc f,420void *arg);421XMLPUBFUN void422xmlTextReaderGetErrorHandler(xmlTextReaderPtr reader,423xmlTextReaderErrorFunc *f,424void **arg);425426#endif /* LIBXML_READER_ENABLED */427428#ifdef __cplusplus429}430#endif431432#endif /* __XML_XMLREADER_H__ */433434435