Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 10:41:51

0001 /*
0002  * Summary: the XMLReader implementation
0003  * Description: API of the XML streaming API based on C# interfaces.
0004  *
0005  * Copy: See Copyright for the status of this software.
0006  *
0007  * Author: Daniel Veillard
0008  */
0009 
0010 #ifndef __XML_XMLREADER_H__
0011 #define __XML_XMLREADER_H__
0012 
0013 #include <libxml/xmlversion.h>
0014 #include <libxml/tree.h>
0015 #include <libxml/xmlerror.h>
0016 #include <libxml/xmlIO.h>
0017 #ifdef LIBXML_SCHEMAS_ENABLED
0018 #include <libxml/relaxng.h>
0019 #include <libxml/xmlschemas.h>
0020 #endif
0021 /* for compatibility */
0022 #include <libxml/parser.h>
0023 
0024 #ifdef __cplusplus
0025 extern "C" {
0026 #endif
0027 
0028 /**
0029  * xmlParserSeverities:
0030  *
0031  * How severe an error callback is when the per-reader error callback API
0032  * is used.
0033  */
0034 typedef enum {
0035     XML_PARSER_SEVERITY_VALIDITY_WARNING = 1,
0036     XML_PARSER_SEVERITY_VALIDITY_ERROR = 2,
0037     XML_PARSER_SEVERITY_WARNING = 3,
0038     XML_PARSER_SEVERITY_ERROR = 4
0039 } xmlParserSeverities;
0040 
0041 #ifdef LIBXML_READER_ENABLED
0042 
0043 /**
0044  * xmlTextReaderMode:
0045  *
0046  * Internal state values for the reader.
0047  */
0048 typedef enum {
0049     XML_TEXTREADER_MODE_INITIAL = 0,
0050     XML_TEXTREADER_MODE_INTERACTIVE = 1,
0051     XML_TEXTREADER_MODE_ERROR = 2,
0052     XML_TEXTREADER_MODE_EOF =3,
0053     XML_TEXTREADER_MODE_CLOSED = 4,
0054     XML_TEXTREADER_MODE_READING = 5
0055 } xmlTextReaderMode;
0056 
0057 /**
0058  * xmlParserProperties:
0059  *
0060  * Some common options to use with xmlTextReaderSetParserProp, but it
0061  * is better to use xmlParserOption and the xmlReaderNewxxx and
0062  * xmlReaderForxxx APIs now.
0063  */
0064 typedef enum {
0065     XML_PARSER_LOADDTD = 1,
0066     XML_PARSER_DEFAULTATTRS = 2,
0067     XML_PARSER_VALIDATE = 3,
0068     XML_PARSER_SUBST_ENTITIES = 4
0069 } xmlParserProperties;
0070 
0071 /**
0072  * xmlReaderTypes:
0073  *
0074  * Predefined constants for the different types of nodes.
0075  */
0076 typedef enum {
0077     XML_READER_TYPE_NONE = 0,
0078     XML_READER_TYPE_ELEMENT = 1,
0079     XML_READER_TYPE_ATTRIBUTE = 2,
0080     XML_READER_TYPE_TEXT = 3,
0081     XML_READER_TYPE_CDATA = 4,
0082     XML_READER_TYPE_ENTITY_REFERENCE = 5,
0083     XML_READER_TYPE_ENTITY = 6,
0084     XML_READER_TYPE_PROCESSING_INSTRUCTION = 7,
0085     XML_READER_TYPE_COMMENT = 8,
0086     XML_READER_TYPE_DOCUMENT = 9,
0087     XML_READER_TYPE_DOCUMENT_TYPE = 10,
0088     XML_READER_TYPE_DOCUMENT_FRAGMENT = 11,
0089     XML_READER_TYPE_NOTATION = 12,
0090     XML_READER_TYPE_WHITESPACE = 13,
0091     XML_READER_TYPE_SIGNIFICANT_WHITESPACE = 14,
0092     XML_READER_TYPE_END_ELEMENT = 15,
0093     XML_READER_TYPE_END_ENTITY = 16,
0094     XML_READER_TYPE_XML_DECLARATION = 17
0095 } xmlReaderTypes;
0096 
0097 /**
0098  * xmlTextReader:
0099  *
0100  * Structure for an xmlReader context.
0101  */
0102 typedef struct _xmlTextReader xmlTextReader;
0103 
0104 /**
0105  * xmlTextReaderPtr:
0106  *
0107  * Pointer to an xmlReader context.
0108  */
0109 typedef xmlTextReader *xmlTextReaderPtr;
0110 
0111 /*
0112  * Constructors & Destructor
0113  */
0114 XMLPUBFUN xmlTextReaderPtr
0115             xmlNewTextReader    (xmlParserInputBufferPtr input,
0116                                              const char *URI);
0117 XMLPUBFUN xmlTextReaderPtr
0118             xmlNewTextReaderFilename(const char *URI);
0119 
0120 XMLPUBFUN void
0121             xmlFreeTextReader   (xmlTextReaderPtr reader);
0122 
0123 XMLPUBFUN int
0124             xmlTextReaderSetup(xmlTextReaderPtr reader,
0125                    xmlParserInputBufferPtr input, const char *URL,
0126                    const char *encoding, int options);
0127 XMLPUBFUN void
0128             xmlTextReaderSetMaxAmplification(xmlTextReaderPtr reader,
0129                    unsigned maxAmpl);
0130 XMLPUBFUN const xmlError *
0131             xmlTextReaderGetLastError(xmlTextReaderPtr reader);
0132 
0133 /*
0134  * Iterators
0135  */
0136 XMLPUBFUN int
0137             xmlTextReaderRead   (xmlTextReaderPtr reader);
0138 
0139 #ifdef LIBXML_WRITER_ENABLED
0140 XMLPUBFUN xmlChar *
0141             xmlTextReaderReadInnerXml(xmlTextReaderPtr reader);
0142 
0143 XMLPUBFUN xmlChar *
0144             xmlTextReaderReadOuterXml(xmlTextReaderPtr reader);
0145 #endif
0146 
0147 XMLPUBFUN xmlChar *
0148             xmlTextReaderReadString (xmlTextReaderPtr reader);
0149 XMLPUBFUN int
0150             xmlTextReaderReadAttributeValue(xmlTextReaderPtr reader);
0151 
0152 /*
0153  * Attributes of the node
0154  */
0155 XMLPUBFUN int
0156             xmlTextReaderAttributeCount(xmlTextReaderPtr reader);
0157 XMLPUBFUN int
0158             xmlTextReaderDepth  (xmlTextReaderPtr reader);
0159 XMLPUBFUN int
0160             xmlTextReaderHasAttributes(xmlTextReaderPtr reader);
0161 XMLPUBFUN int
0162             xmlTextReaderHasValue(xmlTextReaderPtr reader);
0163 XMLPUBFUN int
0164             xmlTextReaderIsDefault  (xmlTextReaderPtr reader);
0165 XMLPUBFUN int
0166             xmlTextReaderIsEmptyElement(xmlTextReaderPtr reader);
0167 XMLPUBFUN int
0168             xmlTextReaderNodeType   (xmlTextReaderPtr reader);
0169 XMLPUBFUN int
0170             xmlTextReaderQuoteChar  (xmlTextReaderPtr reader);
0171 XMLPUBFUN int
0172             xmlTextReaderReadState  (xmlTextReaderPtr reader);
0173 XMLPUBFUN int
0174                         xmlTextReaderIsNamespaceDecl(xmlTextReaderPtr reader);
0175 
0176 XMLPUBFUN const xmlChar *
0177             xmlTextReaderConstBaseUri   (xmlTextReaderPtr reader);
0178 XMLPUBFUN const xmlChar *
0179             xmlTextReaderConstLocalName (xmlTextReaderPtr reader);
0180 XMLPUBFUN const xmlChar *
0181             xmlTextReaderConstName  (xmlTextReaderPtr reader);
0182 XMLPUBFUN const xmlChar *
0183             xmlTextReaderConstNamespaceUri(xmlTextReaderPtr reader);
0184 XMLPUBFUN const xmlChar *
0185             xmlTextReaderConstPrefix    (xmlTextReaderPtr reader);
0186 XMLPUBFUN const xmlChar *
0187             xmlTextReaderConstXmlLang   (xmlTextReaderPtr reader);
0188 XMLPUBFUN const xmlChar *
0189             xmlTextReaderConstString    (xmlTextReaderPtr reader,
0190                          const xmlChar *str);
0191 XMLPUBFUN const xmlChar *
0192             xmlTextReaderConstValue (xmlTextReaderPtr reader);
0193 
0194 /*
0195  * use the Const version of the routine for
0196  * better performance and simpler code
0197  */
0198 XMLPUBFUN xmlChar *
0199             xmlTextReaderBaseUri    (xmlTextReaderPtr reader);
0200 XMLPUBFUN xmlChar *
0201             xmlTextReaderLocalName  (xmlTextReaderPtr reader);
0202 XMLPUBFUN xmlChar *
0203             xmlTextReaderName   (xmlTextReaderPtr reader);
0204 XMLPUBFUN xmlChar *
0205             xmlTextReaderNamespaceUri(xmlTextReaderPtr reader);
0206 XMLPUBFUN xmlChar *
0207             xmlTextReaderPrefix (xmlTextReaderPtr reader);
0208 XMLPUBFUN xmlChar *
0209             xmlTextReaderXmlLang    (xmlTextReaderPtr reader);
0210 XMLPUBFUN xmlChar *
0211             xmlTextReaderValue  (xmlTextReaderPtr reader);
0212 
0213 /*
0214  * Methods of the XmlTextReader
0215  */
0216 XMLPUBFUN int
0217             xmlTextReaderClose      (xmlTextReaderPtr reader);
0218 XMLPUBFUN xmlChar *
0219             xmlTextReaderGetAttributeNo (xmlTextReaderPtr reader,
0220                          int no);
0221 XMLPUBFUN xmlChar *
0222             xmlTextReaderGetAttribute   (xmlTextReaderPtr reader,
0223                          const xmlChar *name);
0224 XMLPUBFUN xmlChar *
0225             xmlTextReaderGetAttributeNs (xmlTextReaderPtr reader,
0226                          const xmlChar *localName,
0227                          const xmlChar *namespaceURI);
0228 XMLPUBFUN xmlParserInputBufferPtr
0229             xmlTextReaderGetRemainder   (xmlTextReaderPtr reader);
0230 XMLPUBFUN xmlChar *
0231             xmlTextReaderLookupNamespace(xmlTextReaderPtr reader,
0232                          const xmlChar *prefix);
0233 XMLPUBFUN int
0234             xmlTextReaderMoveToAttributeNo(xmlTextReaderPtr reader,
0235                          int no);
0236 XMLPUBFUN int
0237             xmlTextReaderMoveToAttribute(xmlTextReaderPtr reader,
0238                          const xmlChar *name);
0239 XMLPUBFUN int
0240             xmlTextReaderMoveToAttributeNs(xmlTextReaderPtr reader,
0241                          const xmlChar *localName,
0242                          const xmlChar *namespaceURI);
0243 XMLPUBFUN int
0244             xmlTextReaderMoveToFirstAttribute(xmlTextReaderPtr reader);
0245 XMLPUBFUN int
0246             xmlTextReaderMoveToNextAttribute(xmlTextReaderPtr reader);
0247 XMLPUBFUN int
0248             xmlTextReaderMoveToElement  (xmlTextReaderPtr reader);
0249 XMLPUBFUN int
0250             xmlTextReaderNormalization  (xmlTextReaderPtr reader);
0251 XMLPUBFUN const xmlChar *
0252             xmlTextReaderConstEncoding  (xmlTextReaderPtr reader);
0253 
0254 /*
0255  * Extensions
0256  */
0257 XMLPUBFUN int
0258             xmlTextReaderSetParserProp  (xmlTextReaderPtr reader,
0259                          int prop,
0260                          int value);
0261 XMLPUBFUN int
0262             xmlTextReaderGetParserProp  (xmlTextReaderPtr reader,
0263                          int prop);
0264 XMLPUBFUN xmlNodePtr
0265             xmlTextReaderCurrentNode    (xmlTextReaderPtr reader);
0266 
0267 XMLPUBFUN int
0268             xmlTextReaderGetParserLineNumber(xmlTextReaderPtr reader);
0269 
0270 XMLPUBFUN int
0271             xmlTextReaderGetParserColumnNumber(xmlTextReaderPtr reader);
0272 
0273 XMLPUBFUN xmlNodePtr
0274             xmlTextReaderPreserve   (xmlTextReaderPtr reader);
0275 #ifdef LIBXML_PATTERN_ENABLED
0276 XMLPUBFUN int
0277             xmlTextReaderPreservePattern(xmlTextReaderPtr reader,
0278                          const xmlChar *pattern,
0279                          const xmlChar **namespaces);
0280 #endif /* LIBXML_PATTERN_ENABLED */
0281 XMLPUBFUN xmlDocPtr
0282             xmlTextReaderCurrentDoc (xmlTextReaderPtr reader);
0283 XMLPUBFUN xmlNodePtr
0284             xmlTextReaderExpand     (xmlTextReaderPtr reader);
0285 XMLPUBFUN int
0286             xmlTextReaderNext       (xmlTextReaderPtr reader);
0287 XMLPUBFUN int
0288             xmlTextReaderNextSibling    (xmlTextReaderPtr reader);
0289 XMLPUBFUN int
0290             xmlTextReaderIsValid    (xmlTextReaderPtr reader);
0291 #ifdef LIBXML_SCHEMAS_ENABLED
0292 XMLPUBFUN int
0293             xmlTextReaderRelaxNGValidate(xmlTextReaderPtr reader,
0294                          const char *rng);
0295 XMLPUBFUN int
0296             xmlTextReaderRelaxNGValidateCtxt(xmlTextReaderPtr reader,
0297                          xmlRelaxNGValidCtxtPtr ctxt,
0298                          int options);
0299 
0300 XMLPUBFUN int
0301             xmlTextReaderRelaxNGSetSchema(xmlTextReaderPtr reader,
0302                          xmlRelaxNGPtr schema);
0303 XMLPUBFUN int
0304             xmlTextReaderSchemaValidate (xmlTextReaderPtr reader,
0305                          const char *xsd);
0306 XMLPUBFUN int
0307             xmlTextReaderSchemaValidateCtxt(xmlTextReaderPtr reader,
0308                          xmlSchemaValidCtxtPtr ctxt,
0309                          int options);
0310 XMLPUBFUN int
0311             xmlTextReaderSetSchema  (xmlTextReaderPtr reader,
0312                          xmlSchemaPtr schema);
0313 #endif
0314 XMLPUBFUN const xmlChar *
0315             xmlTextReaderConstXmlVersion(xmlTextReaderPtr reader);
0316 XMLPUBFUN int
0317             xmlTextReaderStandalone     (xmlTextReaderPtr reader);
0318 
0319 
0320 /*
0321  * Index lookup
0322  */
0323 XMLPUBFUN long
0324         xmlTextReaderByteConsumed   (xmlTextReaderPtr reader);
0325 
0326 /*
0327  * New more complete APIs for simpler creation and reuse of readers
0328  */
0329 XMLPUBFUN xmlTextReaderPtr
0330         xmlReaderWalker     (xmlDocPtr doc);
0331 XMLPUBFUN xmlTextReaderPtr
0332         xmlReaderForDoc     (const xmlChar * cur,
0333                      const char *URL,
0334                      const char *encoding,
0335                      int options);
0336 XMLPUBFUN xmlTextReaderPtr
0337         xmlReaderForFile    (const char *filename,
0338                      const char *encoding,
0339                      int options);
0340 XMLPUBFUN xmlTextReaderPtr
0341         xmlReaderForMemory  (const char *buffer,
0342                      int size,
0343                      const char *URL,
0344                      const char *encoding,
0345                      int options);
0346 XMLPUBFUN xmlTextReaderPtr
0347         xmlReaderForFd      (int fd,
0348                      const char *URL,
0349                      const char *encoding,
0350                      int options);
0351 XMLPUBFUN xmlTextReaderPtr
0352         xmlReaderForIO      (xmlInputReadCallback ioread,
0353                      xmlInputCloseCallback ioclose,
0354                      void *ioctx,
0355                      const char *URL,
0356                      const char *encoding,
0357                      int options);
0358 
0359 XMLPUBFUN int
0360         xmlReaderNewWalker  (xmlTextReaderPtr reader,
0361                      xmlDocPtr doc);
0362 XMLPUBFUN int
0363         xmlReaderNewDoc     (xmlTextReaderPtr reader,
0364                      const xmlChar * cur,
0365                      const char *URL,
0366                      const char *encoding,
0367                      int options);
0368 XMLPUBFUN int
0369         xmlReaderNewFile    (xmlTextReaderPtr reader,
0370                      const char *filename,
0371                      const char *encoding,
0372                      int options);
0373 XMLPUBFUN int
0374         xmlReaderNewMemory  (xmlTextReaderPtr reader,
0375                      const char *buffer,
0376                      int size,
0377                      const char *URL,
0378                      const char *encoding,
0379                      int options);
0380 XMLPUBFUN int
0381         xmlReaderNewFd      (xmlTextReaderPtr reader,
0382                      int fd,
0383                      const char *URL,
0384                      const char *encoding,
0385                      int options);
0386 XMLPUBFUN int
0387         xmlReaderNewIO      (xmlTextReaderPtr reader,
0388                      xmlInputReadCallback ioread,
0389                      xmlInputCloseCallback ioclose,
0390                      void *ioctx,
0391                      const char *URL,
0392                      const char *encoding,
0393                      int options);
0394 /*
0395  * Error handling extensions
0396  */
0397 typedef void *  xmlTextReaderLocatorPtr;
0398 
0399 /**
0400  * xmlTextReaderErrorFunc:
0401  * @arg: the user argument
0402  * @msg: the message
0403  * @severity: the severity of the error
0404  * @locator: a locator indicating where the error occurred
0405  *
0406  * Signature of an error callback from a reader parser
0407  */
0408 typedef void (*xmlTextReaderErrorFunc)(void *arg,
0409                            const char *msg,
0410                            xmlParserSeverities severity,
0411                            xmlTextReaderLocatorPtr locator);
0412 XMLPUBFUN int
0413         xmlTextReaderLocatorLineNumber(xmlTextReaderLocatorPtr locator);
0414 XMLPUBFUN xmlChar *
0415         xmlTextReaderLocatorBaseURI (xmlTextReaderLocatorPtr locator);
0416 XMLPUBFUN void
0417         xmlTextReaderSetErrorHandler(xmlTextReaderPtr reader,
0418                      xmlTextReaderErrorFunc f,
0419                      void *arg);
0420 XMLPUBFUN void
0421         xmlTextReaderSetStructuredErrorHandler(xmlTextReaderPtr reader,
0422                            xmlStructuredErrorFunc f,
0423                            void *arg);
0424 XMLPUBFUN void
0425         xmlTextReaderGetErrorHandler(xmlTextReaderPtr reader,
0426                      xmlTextReaderErrorFunc *f,
0427                      void **arg);
0428 
0429 #endif /* LIBXML_READER_ENABLED */
0430 
0431 #ifdef __cplusplus
0432 }
0433 #endif
0434 
0435 #endif /* __XML_XMLREADER_H__ */
0436