codekingpro/portable-devtools
116k
1/*2 * Summary: the XMLReader implementation3 * Description: API of the XML streaming API based on C# interfaces.4 *5 * Copy: See Copyright for the status of this software.6 *7 * Author: Daniel Veillard8 */9 10#ifndef __XML_XMLREADER_H__11#define __XML_XMLREADER_H__12 13#include <libxml/xmlversion.h>14#include <libxml/tree.h>15#include <libxml/xmlIO.h>16#ifdef LIBXML_SCHEMAS_ENABLED17#include <libxml/relaxng.h>18#include <libxml/xmlschemas.h>19#endif20 21#ifdef __cplusplus22extern "C" {23#endif24 25/**26 * xmlParserSeverities:27 *28 * How severe an error callback is when the per-reader error callback API29 * is used.30 */31typedef enum {32 XML_PARSER_SEVERITY_VALIDITY_WARNING = 1,33 XML_PARSER_SEVERITY_VALIDITY_ERROR = 2,34 XML_PARSER_SEVERITY_WARNING = 3,35 XML_PARSER_SEVERITY_ERROR = 436} xmlParserSeverities;37 38#ifdef LIBXML_READER_ENABLED39 40/**41 * xmlTextReaderMode:42 *43 * Internal state values for the reader.44 */45typedef enum {46 XML_TEXTREADER_MODE_INITIAL = 0,47 XML_TEXTREADER_MODE_INTERACTIVE = 1,48 XML_TEXTREADER_MODE_ERROR = 2,49 XML_TEXTREADER_MODE_EOF =3,50 XML_TEXTREADER_MODE_CLOSED = 4,51 XML_TEXTREADER_MODE_READING = 552} xmlTextReaderMode;53 54/**55 * xmlParserProperties:56 *57 * Some common options to use with xmlTextReaderSetParserProp, but it58 * is better to use xmlParserOption and the xmlReaderNewxxx and59 * xmlReaderForxxx APIs now.60 */61typedef enum {62 XML_PARSER_LOADDTD = 1,63 XML_PARSER_DEFAULTATTRS = 2,64 XML_PARSER_VALIDATE = 3,65 XML_PARSER_SUBST_ENTITIES = 466} xmlParserProperties;67 68/**69 * xmlReaderTypes:70 *71 * Predefined constants for the different types of nodes.72 */73typedef enum {74 XML_READER_TYPE_NONE = 0,75 XML_READER_TYPE_ELEMENT = 1,76 XML_READER_TYPE_ATTRIBUTE = 2,77 XML_READER_TYPE_TEXT = 3,78 XML_READER_TYPE_CDATA = 4,79 XML_READER_TYPE_ENTITY_REFERENCE = 5,80 XML_READER_TYPE_ENTITY = 6,81 XML_READER_TYPE_PROCESSING_INSTRUCTION = 7,82 XML_READER_TYPE_COMMENT = 8,83 XML_READER_TYPE_DOCUMENT = 9,84 XML_READER_TYPE_DOCUMENT_TYPE = 10,85 XML_READER_TYPE_DOCUMENT_FRAGMENT = 11,86 XML_READER_TYPE_NOTATION = 12,87 XML_READER_TYPE_WHITESPACE = 13,88 XML_READER_TYPE_SIGNIFICANT_WHITESPACE = 14,89 XML_READER_TYPE_END_ELEMENT = 15,90 XML_READER_TYPE_END_ENTITY = 16,91 XML_READER_TYPE_XML_DECLARATION = 1792} xmlReaderTypes;93 94/**95 * xmlTextReader:96 *97 * Structure for an xmlReader context.98 */99typedef struct _xmlTextReader xmlTextReader;100 101/**102 * xmlTextReaderPtr:103 *104 * Pointer to an xmlReader context.105 */106typedef xmlTextReader *xmlTextReaderPtr;107 108/*109 * Constructors & Destructor110 */111XMLPUBFUN xmlTextReaderPtr112 xmlNewTextReader (xmlParserInputBufferPtr input,113 const char *URI);114XMLPUBFUN xmlTextReaderPtr115 xmlNewTextReaderFilename(const char *URI);116 117XMLPUBFUN void118 xmlFreeTextReader (xmlTextReaderPtr reader);119 120XMLPUBFUN int121 xmlTextReaderSetup(xmlTextReaderPtr reader,122 xmlParserInputBufferPtr input, const char *URL,123 const char *encoding, int options);124 125/*126 * Iterators127 */128XMLPUBFUN int129 xmlTextReaderRead (xmlTextReaderPtr reader);130 131#ifdef LIBXML_WRITER_ENABLED132XMLPUBFUN xmlChar *133 xmlTextReaderReadInnerXml(xmlTextReaderPtr reader);134 135XMLPUBFUN xmlChar *136 xmlTextReaderReadOuterXml(xmlTextReaderPtr reader);137#endif138 139XMLPUBFUN xmlChar *140 xmlTextReaderReadString (xmlTextReaderPtr reader);141XMLPUBFUN int142 xmlTextReaderReadAttributeValue(xmlTextReaderPtr reader);143 144/*145 * Attributes of the node146 */147XMLPUBFUN int148 xmlTextReaderAttributeCount(xmlTextReaderPtr reader);149XMLPUBFUN int150 xmlTextReaderDepth (xmlTextReaderPtr reader);151XMLPUBFUN int152 xmlTextReaderHasAttributes(xmlTextReaderPtr reader);153XMLPUBFUN int154 xmlTextReaderHasValue(xmlTextReaderPtr reader);155XMLPUBFUN int156 xmlTextReaderIsDefault (xmlTextReaderPtr reader);157XMLPUBFUN int158 xmlTextReaderIsEmptyElement(xmlTextReaderPtr reader);159XMLPUBFUN int160 xmlTextReaderNodeType (xmlTextReaderPtr reader);161XMLPUBFUN int162 xmlTextReaderQuoteChar (xmlTextReaderPtr reader);163XMLPUBFUN int164 xmlTextReaderReadState (xmlTextReaderPtr reader);165XMLPUBFUN int166 xmlTextReaderIsNamespaceDecl(xmlTextReaderPtr reader);167 168XMLPUBFUN const xmlChar *169 xmlTextReaderConstBaseUri (xmlTextReaderPtr reader);170XMLPUBFUN const xmlChar *171 xmlTextReaderConstLocalName (xmlTextReaderPtr reader);172XMLPUBFUN const xmlChar *173 xmlTextReaderConstName (xmlTextReaderPtr reader);174XMLPUBFUN const xmlChar *175 xmlTextReaderConstNamespaceUri(xmlTextReaderPtr reader);176XMLPUBFUN const xmlChar *177 xmlTextReaderConstPrefix (xmlTextReaderPtr reader);178XMLPUBFUN const xmlChar *179 xmlTextReaderConstXmlLang (xmlTextReaderPtr reader);180XMLPUBFUN const xmlChar *181 xmlTextReaderConstString (xmlTextReaderPtr reader,182 const xmlChar *str);183XMLPUBFUN const xmlChar *184 xmlTextReaderConstValue (xmlTextReaderPtr reader);185 186/*187 * use the Const version of the routine for188 * better performance and simpler code189 */190XMLPUBFUN xmlChar *191 xmlTextReaderBaseUri (xmlTextReaderPtr reader);192XMLPUBFUN xmlChar *193 xmlTextReaderLocalName (xmlTextReaderPtr reader);194XMLPUBFUN xmlChar *195 xmlTextReaderName (xmlTextReaderPtr reader);196XMLPUBFUN xmlChar *197 xmlTextReaderNamespaceUri(xmlTextReaderPtr reader);198XMLPUBFUN xmlChar *199 xmlTextReaderPrefix (xmlTextReaderPtr reader);200XMLPUBFUN xmlChar *201 xmlTextReaderXmlLang (xmlTextReaderPtr reader);202XMLPUBFUN xmlChar *203 xmlTextReaderValue (xmlTextReaderPtr reader);204 205/*206 * Methods of the XmlTextReader207 */208XMLPUBFUN int209 xmlTextReaderClose (xmlTextReaderPtr reader);210XMLPUBFUN xmlChar *211 xmlTextReaderGetAttributeNo (xmlTextReaderPtr reader,212 int no);213XMLPUBFUN xmlChar *214 xmlTextReaderGetAttribute (xmlTextReaderPtr reader,215 const xmlChar *name);216XMLPUBFUN xmlChar *217 xmlTextReaderGetAttributeNs (xmlTextReaderPtr reader,218 const xmlChar *localName,219 const xmlChar *namespaceURI);220XMLPUBFUN xmlParserInputBufferPtr221 xmlTextReaderGetRemainder (xmlTextReaderPtr reader);222XMLPUBFUN xmlChar *223 xmlTextReaderLookupNamespace(xmlTextReaderPtr reader,224 const xmlChar *prefix);225XMLPUBFUN int226 xmlTextReaderMoveToAttributeNo(xmlTextReaderPtr reader,227 int no);228XMLPUBFUN int229 xmlTextReaderMoveToAttribute(xmlTextReaderPtr reader,230 const xmlChar *name);231XMLPUBFUN int232 xmlTextReaderMoveToAttributeNs(xmlTextReaderPtr reader,233 const xmlChar *localName,234 const xmlChar *namespaceURI);235XMLPUBFUN int236 xmlTextReaderMoveToFirstAttribute(xmlTextReaderPtr reader);237XMLPUBFUN int238 xmlTextReaderMoveToNextAttribute(xmlTextReaderPtr reader);239XMLPUBFUN int240 xmlTextReaderMoveToElement (xmlTextReaderPtr reader);241XMLPUBFUN int242 xmlTextReaderNormalization (xmlTextReaderPtr reader);243XMLPUBFUN const xmlChar *244 xmlTextReaderConstEncoding (xmlTextReaderPtr reader);245 246/*247 * Extensions248 */249XMLPUBFUN int250 xmlTextReaderSetParserProp (xmlTextReaderPtr reader,251 int prop,252 int value);253XMLPUBFUN int254 xmlTextReaderGetParserProp (xmlTextReaderPtr reader,255 int prop);256XMLPUBFUN xmlNodePtr257 xmlTextReaderCurrentNode (xmlTextReaderPtr reader);258 259XMLPUBFUN int260 xmlTextReaderGetParserLineNumber(xmlTextReaderPtr reader);261 262XMLPUBFUN int263 xmlTextReaderGetParserColumnNumber(xmlTextReaderPtr reader);264 265XMLPUBFUN xmlNodePtr266 xmlTextReaderPreserve (xmlTextReaderPtr reader);267#ifdef LIBXML_PATTERN_ENABLED268XMLPUBFUN int269 xmlTextReaderPreservePattern(xmlTextReaderPtr reader,270 const xmlChar *pattern,271 const xmlChar **namespaces);272#endif /* LIBXML_PATTERN_ENABLED */273XMLPUBFUN xmlDocPtr274 xmlTextReaderCurrentDoc (xmlTextReaderPtr reader);275XMLPUBFUN xmlNodePtr276 xmlTextReaderExpand (xmlTextReaderPtr reader);277XMLPUBFUN int278 xmlTextReaderNext (xmlTextReaderPtr reader);279XMLPUBFUN int280 xmlTextReaderNextSibling (xmlTextReaderPtr reader);281XMLPUBFUN int282 xmlTextReaderIsValid (xmlTextReaderPtr reader);283#ifdef LIBXML_SCHEMAS_ENABLED284XMLPUBFUN int285 xmlTextReaderRelaxNGValidate(xmlTextReaderPtr reader,286 const char *rng);287XMLPUBFUN int288 xmlTextReaderRelaxNGValidateCtxt(xmlTextReaderPtr reader,289 xmlRelaxNGValidCtxtPtr ctxt,290 int options);291 292XMLPUBFUN int293 xmlTextReaderRelaxNGSetSchema(xmlTextReaderPtr reader,294 xmlRelaxNGPtr schema);295XMLPUBFUN int296 xmlTextReaderSchemaValidate (xmlTextReaderPtr reader,297 const char *xsd);298XMLPUBFUN int299 xmlTextReaderSchemaValidateCtxt(xmlTextReaderPtr reader,300 xmlSchemaValidCtxtPtr ctxt,301 int options);302XMLPUBFUN int303 xmlTextReaderSetSchema (xmlTextReaderPtr reader,304 xmlSchemaPtr schema);305#endif306XMLPUBFUN const xmlChar *307 xmlTextReaderConstXmlVersion(xmlTextReaderPtr reader);308XMLPUBFUN int309 xmlTextReaderStandalone (xmlTextReaderPtr reader);310 311 312/*313 * Index lookup314 */315XMLPUBFUN long316 xmlTextReaderByteConsumed (xmlTextReaderPtr reader);317 318/*319 * New more complete APIs for simpler creation and reuse of readers320 */321XMLPUBFUN xmlTextReaderPtr322 xmlReaderWalker (xmlDocPtr doc);323XMLPUBFUN xmlTextReaderPtr324 xmlReaderForDoc (const xmlChar * cur,325 const char *URL,326 const char *encoding,327 int options);328XMLPUBFUN xmlTextReaderPtr329 xmlReaderForFile (const char *filename,330 const char *encoding,331 int options);332XMLPUBFUN xmlTextReaderPtr333 xmlReaderForMemory (const char *buffer,334 int size,335 const char *URL,336 const char *encoding,337 int options);338XMLPUBFUN xmlTextReaderPtr339 xmlReaderForFd (int fd,340 const char *URL,341 const char *encoding,342 int options);343XMLPUBFUN xmlTextReaderPtr344 xmlReaderForIO (xmlInputReadCallback ioread,345 xmlInputCloseCallback ioclose,346 void *ioctx,347 const char *URL,348 const char *encoding,349 int options);350 351XMLPUBFUN int352 xmlReaderNewWalker (xmlTextReaderPtr reader,353 xmlDocPtr doc);354XMLPUBFUN int355 xmlReaderNewDoc (xmlTextReaderPtr reader,356 const xmlChar * cur,357 const char *URL,358 const char *encoding,359 int options);360XMLPUBFUN int361 xmlReaderNewFile (xmlTextReaderPtr reader,362 const char *filename,363 const char *encoding,364 int options);365XMLPUBFUN int366 xmlReaderNewMemory (xmlTextReaderPtr reader,367 const char *buffer,368 int size,369 const char *URL,370 const char *encoding,371 int options);372XMLPUBFUN int373 xmlReaderNewFd (xmlTextReaderPtr reader,374 int fd,375 const char *URL,376 const char *encoding,377 int options);378XMLPUBFUN int379 xmlReaderNewIO (xmlTextReaderPtr reader,380 xmlInputReadCallback ioread,381 xmlInputCloseCallback ioclose,382 void *ioctx,383 const char *URL,384 const char *encoding,385 int options);386/*387 * Error handling extensions388 */389typedef void * xmlTextReaderLocatorPtr;390 391/**392 * xmlTextReaderErrorFunc:393 * @arg: the user argument394 * @msg: the message395 * @severity: the severity of the error396 * @locator: a locator indicating where the error occurred397 *398 * Signature of an error callback from a reader parser399 */400typedef void (*xmlTextReaderErrorFunc)(void *arg,401 const char *msg,402 xmlParserSeverities severity,403 xmlTextReaderLocatorPtr locator);404XMLPUBFUN int405 xmlTextReaderLocatorLineNumber(xmlTextReaderLocatorPtr locator);406XMLPUBFUN xmlChar *407 xmlTextReaderLocatorBaseURI (xmlTextReaderLocatorPtr locator);408XMLPUBFUN void409 xmlTextReaderSetErrorHandler(xmlTextReaderPtr reader,410 xmlTextReaderErrorFunc f,411 void *arg);412XMLPUBFUN void413 xmlTextReaderSetStructuredErrorHandler(xmlTextReaderPtr reader,414 xmlStructuredErrorFunc f,415 void *arg);416XMLPUBFUN void417 xmlTextReaderGetErrorHandler(xmlTextReaderPtr reader,418 xmlTextReaderErrorFunc *f,419 void **arg);420 421#endif /* LIBXML_READER_ENABLED */422 423#ifdef __cplusplus424}425#endif426 427#endif /* __XML_XMLREADER_H__ */428 429 