2 * parserInternals.h : internals routines exported by the parser.
4 * See Copyright for the status of this software.
10 #ifndef __XML_PARSER_INTERNALS_H__
11 #define __XML_PARSER_INTERNALS_H__
13 #include <libxml/parser.h>
14 #include <libxml/HTMLparser.h>
23 * Identifiers can be longer, but this will be more costly
26 #define XML_MAX_NAMELEN 100
31 * The parser tries to always have that amount of input ready.
32 * One of the point is providing context when reporting errors.
34 #define INPUT_CHUNK 250
36 /************************************************************************
38 * UNICODE version of the macros. *
40 ************************************************************************/
43 * @c: an UNICODE value (int)
45 * Macro to check the following production in the XML spec:
47 * [2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD]
48 * | [#x10000-#x10FFFF]
49 * any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.
52 ((((c) >= 0x20) && ((c) <= 0xD7FF)) || \
53 ((c) == 0x09) || ((c) == 0x0A) || ((c) == 0x0D) || \
54 (((c) >= 0xE000) && ((c) <= 0xFFFD)) || \
55 (((c) >= 0x10000) && ((c) <= 0x10FFFF)))
59 * @c: an UNICODE value (int)
61 * Macro to check the following production in the XML spec:
63 * [3] S ::= (#x20 | #x9 | #xD | #xA)+
65 #define IS_BLANK(c) (((c) == 0x20) || ((c) == 0x09) || ((c) == 0xA) || \
70 * @c: an UNICODE value (int)
72 * Macro to check the following production in the XML spec:
74 * [85] BaseChar ::= ... long list see REC ...
76 #define IS_BASECHAR(c) xmlIsBaseChar(c)
80 * @c: an UNICODE value (int)
82 * Macro to check the following production in the XML spec:
84 * [88] Digit ::= ... long list see REC ...
86 #define IS_DIGIT(c) xmlIsDigit(c)
90 * @c: an UNICODE value (int)
92 * Macro to check the following production in the XML spec:
94 * [87] CombiningChar ::= ... long list see REC ...
96 #define IS_COMBINING(c) xmlIsCombining(c)
100 * @c: an UNICODE value (int)
102 * Macro to check the following production in the XML spec:
105 * [89] Extender ::= #x00B7 | #x02D0 | #x02D1 | #x0387 | #x0640 |
106 * #x0E46 | #x0EC6 | #x3005 | [#x3031-#x3035] |
107 * [#x309D-#x309E] | [#x30FC-#x30FE]
109 #define IS_EXTENDER(c) xmlIsExtender(c)
113 * @c: an UNICODE value (int)
115 * Macro to check the following production in the XML spec:
118 * [86] Ideographic ::= [#x4E00-#x9FA5] | #x3007 | [#x3021-#x3029]
120 #define IS_IDEOGRAPHIC(c) xmlIsIdeographic(c)
124 * @c: an UNICODE value (int)
126 * Macro to check the following production in the XML spec:
129 * [84] Letter ::= BaseChar | Ideographic
131 #define IS_LETTER(c) (IS_BASECHAR(c) || IS_IDEOGRAPHIC(c))
136 * @c: an UNICODE value (int)
138 * Macro to check the following production in the XML spec:
141 * [13] PubidChar ::= #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%]
143 #define IS_PUBIDCHAR(c) xmlIsPubidChar(c)
147 * @p: and UTF8 string pointer
149 * Skips the end of line chars.
151 #define SKIP_EOL(p) \
152 if (*(p) == 0x13) { p++ ; if (*(p) == 0x10) p++; } \
153 if (*(p) == 0x10) { p++ ; if (*(p) == 0x13) p++; }
157 * @p: and UTF8 string pointer
159 * Skips to the next '>' char.
161 #define MOVETO_ENDTAG(p) \
162 while ((*p) && (*(p) != '>')) (p)++
166 * @p: and UTF8 string pointer
168 * Skips to the next '<' char.
170 #define MOVETO_STARTTAG(p) \
171 while ((*p) && (*(p) != '<')) (p)++
174 * Global variables used for predefined strings.
176 LIBXML_DLL_IMPORT extern const xmlChar xmlStringText[];
177 LIBXML_DLL_IMPORT extern const xmlChar xmlStringTextNoenc[];
178 LIBXML_DLL_IMPORT extern const xmlChar xmlStringComment[];
181 * Function to finish the work of the macros where needed.
183 int xmlIsBaseChar (int c);
184 int xmlIsBlank (int c);
185 int xmlIsPubidChar (int c);
186 int xmlIsLetter (int c);
187 int xmlIsDigit (int c);
188 int xmlIsIdeographic(int c);
189 int xmlIsExtender (int c);
190 int xmlIsCombining (int c);
191 int xmlIsChar (int c);
196 xmlParserCtxtPtr xmlCreateFileParserCtxt (const char *filename);
197 xmlParserCtxtPtr xmlCreateMemoryParserCtxt(const char *buffer,
199 xmlParserCtxtPtr xmlNewParserCtxt (void);
200 xmlParserCtxtPtr xmlCreateEntityParserCtxt(const xmlChar *URL,
202 const xmlChar *base);
203 int xmlSwitchEncoding (xmlParserCtxtPtr ctxt,
204 xmlCharEncoding enc);
205 int xmlSwitchToEncoding (xmlParserCtxtPtr ctxt,
206 xmlCharEncodingHandlerPtr handler);
211 void xmlHandleEntity (xmlParserCtxtPtr ctxt,
212 xmlEntityPtr entity);
217 xmlParserInputPtr xmlNewStringInputStream (xmlParserCtxtPtr ctxt,
218 const xmlChar *buffer);
219 xmlParserInputPtr xmlNewEntityInputStream (xmlParserCtxtPtr ctxt,
220 xmlEntityPtr entity);
221 void xmlPushInput (xmlParserCtxtPtr ctxt,
222 xmlParserInputPtr input);
223 xmlChar xmlPopInput (xmlParserCtxtPtr ctxt);
224 void xmlFreeInputStream (xmlParserInputPtr input);
225 xmlParserInputPtr xmlNewInputFromFile (xmlParserCtxtPtr ctxt,
226 const char *filename);
227 xmlParserInputPtr xmlNewInputStream (xmlParserCtxtPtr ctxt);
232 xmlChar * xmlSplitQName (xmlParserCtxtPtr ctxt,
235 xmlChar * xmlNamespaceParseNCName (xmlParserCtxtPtr ctxt);
236 xmlChar * xmlNamespaceParseQName (xmlParserCtxtPtr ctxt,
238 xmlChar * xmlNamespaceParseNSDef (xmlParserCtxtPtr ctxt);
239 xmlChar * xmlParseQuotedString (xmlParserCtxtPtr ctxt);
240 void xmlParseNamespace (xmlParserCtxtPtr ctxt);
243 * Generic production rules.
245 xmlChar * xmlScanName (xmlParserCtxtPtr ctxt);
246 xmlChar * xmlParseName (xmlParserCtxtPtr ctxt);
247 xmlChar * xmlParseNmtoken (xmlParserCtxtPtr ctxt);
248 xmlChar * xmlParseEntityValue (xmlParserCtxtPtr ctxt,
250 xmlChar * xmlParseAttValue (xmlParserCtxtPtr ctxt);
251 xmlChar * xmlParseSystemLiteral (xmlParserCtxtPtr ctxt);
252 xmlChar * xmlParsePubidLiteral (xmlParserCtxtPtr ctxt);
253 void xmlParseCharData (xmlParserCtxtPtr ctxt,
255 xmlChar * xmlParseExternalID (xmlParserCtxtPtr ctxt,
258 void xmlParseComment (xmlParserCtxtPtr ctxt);
259 xmlChar * xmlParsePITarget (xmlParserCtxtPtr ctxt);
260 void xmlParsePI (xmlParserCtxtPtr ctxt);
261 void xmlParseNotationDecl (xmlParserCtxtPtr ctxt);
262 void xmlParseEntityDecl (xmlParserCtxtPtr ctxt);
263 int xmlParseDefaultDecl (xmlParserCtxtPtr ctxt,
265 xmlEnumerationPtr xmlParseNotationType (xmlParserCtxtPtr ctxt);
266 xmlEnumerationPtr xmlParseEnumerationType (xmlParserCtxtPtr ctxt);
267 int xmlParseEnumeratedType (xmlParserCtxtPtr ctxt,
268 xmlEnumerationPtr *tree);
269 int xmlParseAttributeType (xmlParserCtxtPtr ctxt,
270 xmlEnumerationPtr *tree);
271 void xmlParseAttributeListDecl(xmlParserCtxtPtr ctxt);
272 xmlElementContentPtr xmlParseElementMixedContentDecl
273 (xmlParserCtxtPtr ctxt,
274 xmlParserInputPtr inputchk);
275 xmlElementContentPtr xmlParseElementChildrenContentDecl
276 (xmlParserCtxtPtr ctxt,
277 xmlParserInputPtr inputchk);
278 int xmlParseElementContentDecl(xmlParserCtxtPtr ctxt,
280 xmlElementContentPtr *result);
281 int xmlParseElementDecl (xmlParserCtxtPtr ctxt);
282 void xmlParseMarkupDecl (xmlParserCtxtPtr ctxt);
283 int xmlParseCharRef (xmlParserCtxtPtr ctxt);
284 xmlEntityPtr xmlParseEntityRef (xmlParserCtxtPtr ctxt);
285 void xmlParseReference (xmlParserCtxtPtr ctxt);
286 void xmlParsePEReference (xmlParserCtxtPtr ctxt);
287 void xmlParseDocTypeDecl (xmlParserCtxtPtr ctxt);
288 xmlChar * xmlParseAttribute (xmlParserCtxtPtr ctxt,
290 xmlChar * xmlParseStartTag (xmlParserCtxtPtr ctxt);
291 void xmlParseEndTag (xmlParserCtxtPtr ctxt);
292 void xmlParseCDSect (xmlParserCtxtPtr ctxt);
293 void xmlParseContent (xmlParserCtxtPtr ctxt);
294 void xmlParseElement (xmlParserCtxtPtr ctxt);
295 xmlChar * xmlParseVersionNum (xmlParserCtxtPtr ctxt);
296 xmlChar * xmlParseVersionInfo (xmlParserCtxtPtr ctxt);
297 xmlChar * xmlParseEncName (xmlParserCtxtPtr ctxt);
298 const xmlChar * xmlParseEncodingDecl (xmlParserCtxtPtr ctxt);
299 int xmlParseSDDecl (xmlParserCtxtPtr ctxt);
300 void xmlParseXMLDecl (xmlParserCtxtPtr ctxt);
301 void xmlParseTextDecl (xmlParserCtxtPtr ctxt);
302 void xmlParseMisc (xmlParserCtxtPtr ctxt);
303 void xmlParseExternalSubset (xmlParserCtxtPtr ctxt,
304 const xmlChar *ExternalID,
305 const xmlChar *SystemID);
307 * XML_SUBSTITUTE_NONE:
309 * If no entities need to be substituted.
311 #define XML_SUBSTITUTE_NONE 0
313 * XML_SUBSTITUTE_REF:
315 * Whether general entities need to be substituted.
317 #define XML_SUBSTITUTE_REF 1
319 * XML_SUBSTITUTE_PEREF:
321 * Whether parameter entities need to be substituted.
323 #define XML_SUBSTITUTE_PEREF 2
325 * XML_SUBSTITUTE_BOTH:
327 * Both general and parameter entities need to be substituted.
329 #define XML_SUBSTITUTE_BOTH 3
331 xmlChar * xmlDecodeEntities (xmlParserCtxtPtr ctxt,
337 xmlChar * xmlStringDecodeEntities (xmlParserCtxtPtr ctxt,
345 * Generated by MACROS on top of parser.c c.f. PUSH_AND_POP.
347 int nodePush (xmlParserCtxtPtr ctxt,
349 xmlNodePtr nodePop (xmlParserCtxtPtr ctxt);
350 int inputPush (xmlParserCtxtPtr ctxt,
351 xmlParserInputPtr value);
352 xmlParserInputPtr inputPop (xmlParserCtxtPtr ctxt);
353 xmlChar *namePop (xmlParserCtxtPtr ctxt);
354 int namePush (xmlParserCtxtPtr ctxt,
358 * other commodities shared between parser.c and parserInternals.
360 int xmlSkipBlankChars (xmlParserCtxtPtr ctxt);
361 int xmlStringCurrentChar (xmlParserCtxtPtr ctxt,
364 void xmlParserHandlePEReference(xmlParserCtxtPtr ctxt);
365 void xmlParserHandleReference(xmlParserCtxtPtr ctxt);
366 int xmlCheckLanguageID (const xmlChar *lang);
369 * Really core function shared with HTML parser.
371 int xmlCurrentChar (xmlParserCtxtPtr ctxt,
373 int xmlCopyCharMultiByte (xmlChar *out,
375 int xmlCopyChar (int len,
378 void xmlNextChar (xmlParserCtxtPtr ctxt);
379 void xmlParserInputShrink (xmlParserInputPtr in);
381 #ifdef LIBXML_HTML_ENABLED
383 * Actually comes from the HTML parser but launched from the init stuff.
385 void htmlInitAutoClose (void);
386 htmlParserCtxtPtr htmlCreateFileParserCtxt(const char *filename,
387 const char *encoding);
391 * Specific function to keep track of entities references
392 * and used by the XSLT debugger.
395 * xmlEntityReferenceFunc:
397 * @firstNode: the fist node in the chunk
398 * @lastNode: the last nod in the chunk
400 * Callback function used when one needs to be able to track back the
401 * provenance of a chunk of nodes inherited from an entity replacement.
403 typedef void (*xmlEntityReferenceFunc) (xmlEntityPtr ent,
404 xmlNodePtr firstNode,
405 xmlNodePtr lastNode);
407 void xmlSetEntityReferenceFunc (xmlEntityReferenceFunc func);
413 #endif /* __XML_PARSER_INTERNALS_H__ */