/*
* parser.c : an XML 1.0 parser, namespaces and validity support are mostly
* implemented on top of the SAX interfaces
*
* References:
* The XML specification:
* Original 1.0 version:
* XML second edition working draft
*
* Okay this is a big file, the parser core is around 7000 lines, then it
* is followed by the progressive parser top routines, then the various
* high level APIs to call the parser and a few miscellaneous functions.
* A number of helper functions and deprecated ones have been moved to
* parserInternals.c to reduce this file size.
* As much as possible the functions are associated with their relative
* production in the XML specification. A few productions defining the
* different ranges of character are actually implanted either in
* The DOM tree build is realized from the default SAX callbacks in
* the module SAX.c.
* The routines doing the validation checks are in valid.c and called either
* from the SAX callbacks or as standalone functions using a preparsed
* document.
*
* See Copyright for the status of this software.
*
* daniel@veillard.com
*/
#define IN_LIBXML
#include "libxml.h"
#if defined(WIN32) && !defined (__CYGWIN__)
#else
#endif
#include <stdlib.h>
#include <limits.h>
#include <string.h>
#include <stdarg.h>
#include <libxml/xmlmemory.h>
#include <libxml/parserInternals.h>
#include <libxml/entities.h>
#include <libxml/xmlerror.h>
#include <libxml/encoding.h>
#ifdef LIBXML_CATALOG_ENABLED
#endif
#ifdef LIBXML_SCHEMAS_ENABLED
#include <libxml/xmlschemastypes.h>
#endif
#ifdef HAVE_CTYPE_H
#include <ctype.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_SYS_STAT_H
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_ZLIB_H
#include <zlib.h>
#endif
static void
/************************************************************************
* *
* Arbitrary limits set in the parser. *
* *
************************************************************************/
/*
* XML_PARSER_NON_LINEAR is the threshold where the ratio of parsed entity
* replacement over the size in byte of the input indicates that you have
* and eponential behaviour. A value of 10 correspond to at least 3 entity
* replacement per byte of input.
*/
/*
* xmlParserEntityCheck
*
* Function to check non-linear entity expansion behaviour
* This is here to detect and stop exponential linear entity expansion
* This is not a limitation of the parser but a safety
* boundary feature.
*/
static int
{
return (0);
return (1);
if (replacement != 0) {
if (replacement < XML_MAX_TEXT_LENGTH)
return(0);
/*
* If the volume of entity copy reaches 10 times the
* amount of parsed data and over the large text threshold
* then that's very likely to be an abuse.
*/
}
return(0);
} else if (size != 0) {
/*
* Do the check based on the replacement size of the entity
*/
if (size < XML_PARSER_BIG_ENTITY)
return(0);
/*
* A limit on the amount of text data reasonably used
*/
}
return (0);
/*
* use the number of parsed entities in the replacement
*/
/*
* The amount of data parsed counting entities size only once
*/
}
/*
* Check the density of entities for the amount of data
* knowing an entity reference will take at least 3 bytes
*/
return (0);
} else {
/*
* strange we got no data for checking just return
*/
return (0);
}
return (1);
}
/**
* xmlParserMaxDepth:
*
* arbitrary depth limit for the XML documents that we allow to
* process. This is not a limitation of the parser but a safety
* boundary feature.
*/
/*
* List of XML prefixed PI allowed by W3C specs
*/
static const char *xmlW3CPIs[] = {
"xml-stylesheet",
};
/* DEPR void xmlParserHandleReference(xmlParserCtxtPtr ctxt); */
static xmlParserErrors
#ifdef LIBXML_LEGACY_ENABLED
static void
#endif /* LIBXML_LEGACY_ENABLED */
static xmlParserErrors
/************************************************************************
* *
* Some factorized error routines *
* *
************************************************************************/
/**
* xmlErrAttributeDup:
* @ctxt: an XML parser context
* @prefix: the attribute prefix
* @localname: the attribute localname
*
* Handle a redefinition of attribute error
*/
static void
{
return;
"Attribute %s redefined\n", localname);
else
ctxt->wellFormed = 0;
}
}
/**
* xmlFatalErr:
* @ctxt: an XML parser context
* @error: the error number
* @extra: extra information string
*
* Handle a fatal parser error, i.e. violating Well-Formedness constraints
*/
static void
{
const char *errmsg;
return;
switch (error) {
errmsg = "CharRef: invalid hexadecimal value\n";
break;
errmsg = "CharRef: invalid decimal value\n";
break;
case XML_ERR_INVALID_CHARREF:
errmsg = "CharRef: invalid value\n";
break;
case XML_ERR_INTERNAL_ERROR:
errmsg = "internal error";
break;
case XML_ERR_PEREF_AT_EOF:
errmsg = "PEReference at end of document\n";
break;
case XML_ERR_PEREF_IN_PROLOG:
errmsg = "PEReference in prolog\n";
break;
case XML_ERR_PEREF_IN_EPILOG:
errmsg = "PEReference in epilog\n";
break;
case XML_ERR_PEREF_NO_NAME:
errmsg = "PEReference: no name\n";
break;
errmsg = "PEReference: expecting ';'\n";
break;
case XML_ERR_ENTITY_LOOP:
errmsg = "Detected an entity reference loop\n";
break;
errmsg = "EntityValue: \" or ' expected\n";
break;
errmsg = "PEReferences forbidden in internal subset\n";
break;
errmsg = "EntityValue: \" or ' expected\n";
break;
errmsg = "AttValue: \" or ' expected\n";
break;
case XML_ERR_LT_IN_ATTRIBUTE:
errmsg = "Unescaped '<' not allowed in attributes values\n";
break;
errmsg = "SystemLiteral \" or ' expected\n";
break;
errmsg = "Unfinished System or Public ID \" or ' expected\n";
break;
errmsg = "Sequence ']]>' not allowed in content\n";
break;
case XML_ERR_URI_REQUIRED:
errmsg = "SYSTEM or PUBLIC, the URI is missing\n";
break;
case XML_ERR_PUBID_REQUIRED:
errmsg = "PUBLIC, the Public Identifier is missing\n";
break;
errmsg = "Comment must not contain '--' (double-hyphen)\n";
break;
case XML_ERR_PI_NOT_STARTED:
errmsg = "xmlParsePI : no target name\n";
break;
errmsg = "Invalid PI name\n";
break;
errmsg = "NOTATION: Name expected here\n";
break;
errmsg = "'>' required to close NOTATION declaration\n";
break;
case XML_ERR_VALUE_REQUIRED:
errmsg = "Entity value required\n";
break;
case XML_ERR_URI_FRAGMENT:
errmsg = "Fragment not allowed";
break;
errmsg = "'(' required to start ATTLIST enumeration\n";
break;
case XML_ERR_NMTOKEN_REQUIRED:
errmsg = "NmToken expected in ATTLIST enumeration\n";
break;
errmsg = "')' required to finish ATTLIST enumeration\n";
break;
errmsg = "MixedContentDecl : '|' or ')*' expected\n";
break;
case XML_ERR_PCDATA_REQUIRED:
errmsg = "MixedContentDecl : '#PCDATA' expected\n";
break;
errmsg = "ContentDecl : Name or '(' expected\n";
break;
errmsg = "ContentDecl : ',' '|' or ')' expected\n";
break;
errmsg =
"PEReference: forbidden within markup decl in internal subset\n";
break;
case XML_ERR_GT_REQUIRED:
errmsg = "expected '>'\n";
break;
case XML_ERR_CONDSEC_INVALID:
errmsg = "XML conditional section '[' expected\n";
break;
errmsg = "Content error in the external subset\n";
break;
errmsg =
"conditional section INCLUDE or IGNORE keyword expected\n";
break;
errmsg = "XML conditional section not closed\n";
break;
errmsg = "Text declaration '<?xml' required\n";
break;
errmsg = "parsing XML declaration: '?>' expected\n";
break;
errmsg = "external parsed entities cannot be standalone\n";
break;
errmsg = "EntityRef: expecting ';'\n";
break;
errmsg = "DOCTYPE improperly terminated\n";
break;
case XML_ERR_LTSLASH_REQUIRED:
errmsg = "EndTag: '</' not found\n";
break;
case XML_ERR_EQUAL_REQUIRED:
errmsg = "expected '='\n";
break;
errmsg = "String not closed expecting \" or '\n";
break;
errmsg = "String not started expecting ' or \"\n";
break;
case XML_ERR_ENCODING_NAME:
errmsg = "Invalid XML encoding name\n";
break;
case XML_ERR_STANDALONE_VALUE:
errmsg = "standalone accepts only 'yes' or 'no'\n";
break;
case XML_ERR_DOCUMENT_EMPTY:
errmsg = "Document is empty\n";
break;
case XML_ERR_DOCUMENT_END:
errmsg = "Extra content at the end of the document\n";
break;
errmsg = "chunk is not well balanced\n";
break;
case XML_ERR_EXTRA_CONTENT:
errmsg = "extra content at the end of well balanced chunk\n";
break;
case XML_ERR_VERSION_MISSING:
errmsg = "Malformed declaration expecting version\n";
break;
#if 0
case:
errmsg = "\n";
break;
#endif
default:
errmsg = "Unregistered error message\n";
}
info);
ctxt->wellFormed = 0;
}
}
/**
* xmlFatalErrMsg:
* @ctxt: an XML parser context
* @error: the error number
* @msg: the error message
*
* Handle a fatal parser error, i.e. violating Well-Formedness constraints
*/
static void
const char *msg)
{
return;
ctxt->wellFormed = 0;
}
}
/**
* xmlWarningMsg:
* @ctxt: an XML parser context
* @error: the error number
* @msg: the error message
* @str1: extra data
* @str2: extra data
*
* Handle a warning.
*/
static void
{
return;
}
/**
* xmlValidityError:
* @ctxt: an XML parser context
* @error: the error number
* @msg: the error message
* @str1: extra data
*
* Handle a validity error.
*/
static void
{
return;
}
}
}
/**
* xmlFatalErrMsgInt:
* @ctxt: an XML parser context
* @error: the error number
* @msg: the error message
* @val: an integer value
*
* Handle a fatal parser error, i.e. violating Well-Formedness constraints
*/
static void
{
return;
ctxt->wellFormed = 0;
}
}
/**
* xmlFatalErrMsgStrIntStr:
* @ctxt: an XML parser context
* @error: the error number
* @msg: the error message
* @str1: an string info
* @val: an integer value
* @str2: an string info
*
* Handle a fatal parser error, i.e. violating Well-Formedness constraints
*/
static void
{
return;
ctxt->wellFormed = 0;
}
}
/**
* xmlFatalErrMsgStr:
* @ctxt: an XML parser context
* @error: the error number
* @msg: the error message
* @val: a string value
*
* Handle a fatal parser error, i.e. violating Well-Formedness constraints
*/
static void
{
return;
val);
ctxt->wellFormed = 0;
}
}
/**
* xmlErrMsgStr:
* @ctxt: an XML parser context
* @error: the error number
* @msg: the error message
* @val: a string value
*
* Handle a non fatal parser error
*/
static void
{
return;
val);
}
/**
* xmlNsErr:
* @ctxt: an XML parser context
* @error: the error number
* @msg: the message
* @info1: extra information string
* @info2: extra information string
*
* Handle a fatal parser error, i.e. violating Well-Formedness constraints
*/
static void
const char *msg,
{
return;
ctxt->nsWellFormed = 0;
}
/************************************************************************
* *
* Library wide options *
* *
************************************************************************/
/**
* xmlHasFeature:
* @feature: the feature to be examined
*
* Examines if the library has been compiled with a given feature.
*
* Returns a non-zero value if the feature exist, otherwise zero.
* Returns zero (0) if the feature does not exist or an unknown
* unknown feature is requested, non-zero otherwise.
*/
int
{
switch (feature) {
case XML_WITH_THREAD:
#ifdef LIBXML_THREAD_ENABLED
return(1);
#else
return(0);
#endif
case XML_WITH_TREE:
#ifdef LIBXML_TREE_ENABLED
return(1);
#else
return(0);
#endif
case XML_WITH_OUTPUT:
#ifdef LIBXML_OUTPUT_ENABLED
return(1);
#else
return(0);
#endif
case XML_WITH_PUSH:
#ifdef LIBXML_PUSH_ENABLED
return(1);
#else
return(0);
#endif
case XML_WITH_READER:
#ifdef LIBXML_READER_ENABLED
return(1);
#else
return(0);
#endif
case XML_WITH_PATTERN:
#ifdef LIBXML_PATTERN_ENABLED
return(1);
#else
return(0);
#endif
case XML_WITH_WRITER:
#ifdef LIBXML_WRITER_ENABLED
return(1);
#else
return(0);
#endif
case XML_WITH_SAX1:
#ifdef LIBXML_SAX1_ENABLED
return(1);
#else
return(0);
#endif
case XML_WITH_FTP:
#ifdef LIBXML_FTP_ENABLED
return(1);
#else
return(0);
#endif
case XML_WITH_HTTP:
#ifdef LIBXML_HTTP_ENABLED
return(1);
#else
return(0);
#endif
case XML_WITH_VALID:
#ifdef LIBXML_VALID_ENABLED
return(1);
#else
return(0);
#endif
case XML_WITH_HTML:
#ifdef LIBXML_HTML_ENABLED
return(1);
#else
return(0);
#endif
case XML_WITH_LEGACY:
#ifdef LIBXML_LEGACY_ENABLED
return(1);
#else
return(0);
#endif
case XML_WITH_C14N:
#ifdef LIBXML_C14N_ENABLED
return(1);
#else
return(0);
#endif
case XML_WITH_CATALOG:
#ifdef LIBXML_CATALOG_ENABLED
return(1);
#else
return(0);
#endif
case XML_WITH_XPATH:
#ifdef LIBXML_XPATH_ENABLED
return(1);
#else
return(0);
#endif
case XML_WITH_XPTR:
#ifdef LIBXML_XPTR_ENABLED
return(1);
#else
return(0);
#endif
case XML_WITH_XINCLUDE:
#ifdef LIBXML_XINCLUDE_ENABLED
return(1);
#else
return(0);
#endif
case XML_WITH_ICONV:
#ifdef LIBXML_ICONV_ENABLED
return(1);
#else
return(0);
#endif
case XML_WITH_ISO8859X:
#ifdef LIBXML_ISO8859X_ENABLED
return(1);
#else
return(0);
#endif
case XML_WITH_UNICODE:
#ifdef LIBXML_UNICODE_ENABLED
return(1);
#else
return(0);
#endif
case XML_WITH_REGEXP:
#ifdef LIBXML_REGEXP_ENABLED
return(1);
#else
return(0);
#endif
case XML_WITH_AUTOMATA:
#ifdef LIBXML_AUTOMATA_ENABLED
return(1);
#else
return(0);
#endif
case XML_WITH_EXPR:
#ifdef LIBXML_EXPR_ENABLED
return(1);
#else
return(0);
#endif
case XML_WITH_SCHEMAS:
#ifdef LIBXML_SCHEMAS_ENABLED
return(1);
#else
return(0);
#endif
case XML_WITH_SCHEMATRON:
#ifdef LIBXML_SCHEMATRON_ENABLED
return(1);
#else
return(0);
#endif
case XML_WITH_MODULES:
#ifdef LIBXML_MODULES_ENABLED
return(1);
#else
return(0);
#endif
case XML_WITH_DEBUG:
#ifdef LIBXML_DEBUG_ENABLED
return(1);
#else
return(0);
#endif
case XML_WITH_DEBUG_MEM:
#ifdef DEBUG_MEMORY_LOCATION
return(1);
#else
return(0);
#endif
case XML_WITH_DEBUG_RUN:
#ifdef LIBXML_DEBUG_RUNTIME
return(1);
#else
return(0);
#endif
case XML_WITH_ZLIB:
#ifdef LIBXML_ZLIB_ENABLED
return(1);
#else
return(0);
#endif
default:
break;
}
return(0);
}
/************************************************************************
* *
* SAX2 defaulted attributes handling *
* *
************************************************************************/
/**
* xmlDetectSAX2:
* @ctxt: an XML parser context
*
* Do the SAX2 detection and specific intialization
*/
static void
#ifdef LIBXML_SAX1_ENABLED
#else
#endif /* LIBXML_SAX1_ENABLED */
}
}
struct _xmlDefAttrs {
};
/**
* xmlAddDefAttrs:
* @ctxt: an XML parser context
* @fullname: the element fullname
* @fullattr: the attribute fullname
* @value: the attribute value
*
* Add a defaulted attribute for an element
*/
static void
int len;
goto mem_error;
}
/*
* split the element name into prefix:localname , the string found
* are within the DTD and then not associated to namespace names.
*/
} else {
}
/*
* make sure there is some storage
*/
goto mem_error;
goto mem_error;
}
/*
* Split the element name into prefix:localname , the string found
* are within the DTD and hen not associated to namespace names.
*/
} else {
}
/* intern the string and precompute the end */
return;
return;
}
/**
* xmlAddSpecialAttr:
* @ctxt: an XML parser context
* @fullname: the element fullname
* @fullattr: the attribute fullname
* @type: the attribute type
*
* Register this attribute type
*/
static void
int type)
{
goto mem_error;
}
return;
(void *) (long) type);
return;
return;
}
/**
* xmlCleanSpecialAttrCallback:
*
* Removes CDATA attributes from the special attribute table
*/
static void
if (((long) payload) == XML_ATTRIBUTE_CDATA) {
}
}
/**
* xmlCleanSpecialAttr:
* @ctxt: an XML parser context
*
* Trim the list of attributes defined to remove all those of type
* CDATA as they are not special. This call should be done when finishing
* to parse the DTD and before starting to parse the document root.
*/
static void
{
return;
}
return;
}
/**
* xmlCheckLanguageID:
* @lang: pointer to the string value
*
* Checks that the value conforms to the LanguageID production:
*
* NOTE: this is somewhat deprecated, those productions were removed from
* the XML Second edition.
*
* [33] LanguageID ::= Langcode ('-' Subcode)*
* [34] Langcode ::= ISO639Code | IanaCode | UserCode
* [35] ISO639Code ::= ([a-z] | [A-Z]) ([a-z] | [A-Z])
* [36] IanaCode ::= ('i' | 'I') '-' ([a-z] | [A-Z])+
* [37] UserCode ::= ('x' | 'X') '-' ([a-z] | [A-Z])+
* [38] Subcode ::= ([a-z] | [A-Z])+
*
* Returns 1 if correct 0 otherwise
**/
int
{
return (0);
/*
* IANA code
*/
cur += 2;
cur++;
/*
* User code
*/
cur += 2;
cur++;
/*
* ISO639
*/
cur++;
cur++;
else
return (0);
} else
return (0);
while (cur[0] != 0) { /* non input consuming */
if (cur[0] != '-')
return (0);
cur++;
cur++;
else
return (0);
cur++;
}
return (1);
}
/************************************************************************
* *
* Parser stacks related functions and macros *
* *
************************************************************************/
#ifdef SAX2
/**
* nsPush:
* @ctxt: an XML parser context
* @prefix: the namespace prefix or NULL
* @URL: the namespace name
*
* Pushes a new parser namespace on top of the ns stack
*
* Returns -1 in case of error, -2 if the namespace should be discarded
* and the index in the stack otherwise.
*/
static int
{
int i;
/* in scope */
return(-2);
/* out of scope keep it */
break;
}
}
}
return (-1);
}
return (-1);
}
}
}
/**
* nsPop:
* @ctxt: an XML parser context
* @nr: the number to pop
*
*
* Returns the number of namespaces removed
*/
static int
{
int i;
}
return (0);
for (i = 0;i < nr;i++) {
}
return(nr);
}
#endif
static int
int *attallocs;
int maxatts;
(maxatts / 5) * sizeof(int));
}
return(-1);
}
/**
* inputPush:
* @ctxt: an XML parser context
* @value: the parser input
*
* Pushes a new parser input on top of the input stack
*
* Returns 0 in case of error, the index in the stack otherwise
*/
int
{
return(0);
return (0);
}
}
}
/**
* inputPop:
* @ctxt: an XML parser context
*
* Pops the top parser input from the input stack
*
* Returns the input just removed
*/
{
return(NULL);
return (NULL);
else
return (ret);
}
/**
* nodePush:
* @ctxt: an XML parser context
* @value: the element node
*
* Pushes a new element node on top of the node stack
*
* Returns 0 in case of error, the index in the stack otherwise
*/
int
{
return (0);
}
}
"Excessive depth in document: change xmlParserMaxDepth = %d\n",
return(0);
}
}
/**
* nodePop:
* @ctxt: an XML parser context
*
* Pops the top element node from the node stack
*
* Returns the node just removed
*/
{
return (NULL);
else
return (ret);
}
#ifdef LIBXML_PUSH_ENABLED
/**
* nameNsPush:
* @ctxt: an XML parser context
* @value: the element name
* @prefix: the element prefix
* @URI: the element namespace name
*
*
* Returns -1 in case of error, the index in the stack otherwise
*/
static int
{
void **tmp2;
goto mem_error;
}
goto mem_error;
}
}
return (-1);
}
/**
* nameNsPop:
* @ctxt: an XML parser context
*
*
* Returns the name just removed
*/
static const xmlChar *
{
return (NULL);
else
return (ret);
}
#endif /* LIBXML_PUSH_ENABLED */
/**
* namePush:
* @ctxt: an XML parser context
* @value: the element name
*
* Pushes a new element name on top of the name stack
*
* Returns -1 in case of error, the index in the stack otherwise
*/
int
{
goto mem_error;
}
}
return (-1);
}
/**
* namePop:
* @ctxt: an XML parser context
*
* Pops the top element name from the name stack
*
* Returns the name just removed
*/
const xmlChar *
{
return (NULL);
else
return (ret);
}
return(0);
}
}
}
int ret;
else
return(ret);
}
/*
* Macros for accessing the content. Those should be used only by the parser,
* and not exported.
*
* Dirty macros, i.e. one often need to make assumption on the context to
* use them
*
* CUR_PTR return the current pointer to the xmlChar to be parsed.
* To be used with extreme caution since operations consuming
* characters may move the input buffer to a different location !
* CUR returns the current xmlChar value, i.e. a 8 bit value if compiled
* This should be used internally by the parser
* only to compare to ASCII values otherwise it would break when
* running with UTF-8 encoding.
* RAW same as CUR but in the input buffer, bypass any token
* extraction that may have been done
* NXT(n) returns the n'th next xmlChar. Same as CUR is should be used only
* to compare on ASCII based substring.
* SKIP(n) Skip n xmlChar, and must also be used only to skip ASCII defined
* strings without newlines within the parser.
* NEXT1(l) Skip 1 xmlChar, and must also be used only to skip 1 non-newline ASCII
* defined char within the parser.
* Clean macros, not dependent of an ASCII context, expect UTF-8 encoding
*
* NEXT Skip to the next character, this does the proper decoding
* in UTF-8 mode. It also pop-up unfinished entities on the fly.
* NEXTL(l) Skip the current unicode character of l xmlChars long.
* CUR_CHAR(l) returns the current unicode character (int), set l
* to the number of xmlChars used for the encoding [0-5].
* CUR_SCHAR same but operate on a string instead of the context
* COPY_BUF copy the current unicode char to the target buffer, increment
* the index
* GROW, SHRINK handling of input buffers
*/
((unsigned char *) s)[ 8 ] == c9 )
((unsigned char *) s)[ 9 ] == c10 )
xmlPopInput(ctxt); \
} while (0)
int skipl; \
} \
xmlPopInput(ctxt); \
} while (0)
}
}
#define NEXT1 { \
}
#define NEXTL(l) do { \
} while (0)
#define COPY_BUF(l,b,i,v) \
if (l == 1) b[i++] = (xmlChar) v; \
else i += xmlCopyCharMultiByte(&b[i],v)
/**
* xmlSkipBlankChars:
* @ctxt: the XML parser context
*
* skip all blanks character found at that point in the input streams.
* It pops up finished entities in the process if allowable at that point.
*
* Returns the number of space chars skipped
*/
int
int res = 0;
/*
* the ASCII range.
*/
/*
* if we are in the document content, go really fast
*/
while (IS_BLANK_CH(*cur)) {
if (*cur == '\n') {
}
cur++;
res++;
if (*cur == 0) {
}
}
} else {
int cur;
do {
NEXT;
res++;
}
}
/*
* Need to handle support of entities branching here
*/
}
return(res);
}
/************************************************************************
* *
* Commodity functions to handle entities *
* *
************************************************************************/
/**
* xmlPopInput:
* @ctxt: an XML parser context
*
* xmlPopInput: the current input pointed by ctxt->input came to an end
* pop it and return the next char.
*
* Returns the current xmlChar in the parser context
*/
return(xmlPopInput(ctxt));
return(CUR);
}
/**
* xmlPushInput:
* @ctxt: an XML parser context
* @input: an XML parser input fragment (entity, XML fragment ...).
*
* xmlPushInput: switch to a new input stream which is stacked on top
* of the previous one(s).
*/
void
if (xmlParserDebugEntities) {
}
GROW;
}
/**
* xmlParseCharRef:
* @ctxt: an XML parser context
*
* parse Reference declarations
*
* [66] CharRef ::= '&#' [0-9]+ ';' |
* '&#x' [0-9a-fA-F]+ ';'
*
* [ WFC: Legal Character ]
* Characters referred to using character references must match the
* production for Char.
*
* Returns the value parsed (as an int), 0 in case of error
*/
int
unsigned int val = 0;
int count = 0;
unsigned int outofrange = 0;
/*
*/
SKIP(3);
GROW;
if (count++ > 20) {
count = 0;
GROW;
}
else {
val = 0;
break;
}
if (val > 0x10FFFF)
outofrange = val;
NEXT;
count++;
}
if (RAW == ';') {
/* on purpose to avoid reentrancy problems with NEXT and SKIP */
}
SKIP(2);
GROW;
if (count++ > 20) {
count = 0;
GROW;
}
else {
val = 0;
break;
}
if (val > 0x10FFFF)
outofrange = val;
NEXT;
count++;
}
if (RAW == ';') {
/* on purpose to avoid reentrancy problems with NEXT and SKIP */
}
} else {
}
/*
* [ WFC: Legal Character ]
* Characters referred to using character references must match the
* production for Char.
*/
return(val);
} else {
"xmlParseCharRef: invalid xmlChar value %d\n",
val);
}
return(0);
}
/**
* xmlParseStringCharRef:
* @ctxt: an XML parser context
* @str: a pointer to an index in the string
*
* parse Reference declarations, variant parsing from a string rather
* than an an input flow.
*
* [66] CharRef ::= '&#' [0-9]+ ';' |
* '&#x' [0-9a-fA-F]+ ';'
*
* [ WFC: Legal Character ]
* Characters referred to using character references must match the
* production for Char.
*
* Returns the value parsed (as an int), 0 in case of error, str will be
* updated to the current value of the index
*/
static int
unsigned int val = 0;
unsigned int outofrange = 0;
ptr += 3;
else {
val = 0;
break;
}
if (val > 0x10FFFF)
outofrange = val;
ptr++;
}
if (cur == ';')
ptr++;
ptr += 2;
else {
val = 0;
break;
}
if (val > 0x10FFFF)
outofrange = val;
ptr++;
}
if (cur == ';')
ptr++;
} else {
return(0);
}
/*
* [ WFC: Legal Character ]
* Characters referred to using character references must match the
* production for Char.
*/
return(val);
} else {
"xmlParseStringCharRef: invalid xmlChar value %d\n",
val);
}
return(0);
}
/**
* xmlNewBlanksWrapperInputStream:
* @ctxt: an XML parser context
* @entity: an Entity pointer
*
* Create a new input stream for wrapping
* blanks around a PEReference
*
* Returns the new input stream or NULL
*/
static xmlParserInputPtr
"xmlNewBlanksWrapperInputStream entity\n");
return(NULL);
}
return(NULL);
}
return(NULL);
}
buffer [0] = ' ';
return(input);
}
/**
* xmlParserHandlePEReference:
* @ctxt: the parser context
*
* [69] PEReference ::= '%' Name ';'
*
* [ WFC: No Recursion ]
* A parsed entity must not contain a recursive
* reference to itself, either directly or indirectly.
*
* [ WFC: Entity Declared ]
* In a document without any DTD, a document with only an internal DTD
* subset which contains no parameter entity references, or a document
* with "standalone='yes'", ... ... The declaration of a parameter
* entity must precede any reference to it...
*
* [ VC: Entity Declared ]
* In a document with an external subset or external parameter entities
* with "standalone='no'", ... ... The declaration of a parameter entity
* must precede any reference to it...
*
* [ WFC: In DTD ]
* Parameter-entity references may only appear in the DTD.
* NOTE: misleading but this is handled.
*
* A PEReference may have been detected in the current input stream
* the handling is done accordingly to
* http://www.w3.org/TR/REC-xml#entproc
* i.e.
* - Included in literal in entity values
* - Included as Parameter Entity reference within DTDs
*/
void
if (RAW != '%') return;
case XML_PARSER_CDATA_SECTION:
return;
case XML_PARSER_COMMENT:
return;
case XML_PARSER_START_TAG:
return;
case XML_PARSER_END_TAG:
return;
case XML_PARSER_EOF:
return;
case XML_PARSER_PROLOG:
case XML_PARSER_START:
case XML_PARSER_MISC:
return;
case XML_PARSER_ENTITY_DECL:
case XML_PARSER_CONTENT:
case XML_PARSER_PI:
/* we just ignore it there */
return;
case XML_PARSER_EPILOG:
return;
case XML_PARSER_ENTITY_VALUE:
/*
* NOTE: in the case of entity values, we don't do the
* substitution here since we need the literal
* entity value to be able to save the internal
* subset of the document.
* This will be handled by xmlStringDecodeEntities
*/
return;
case XML_PARSER_DTD:
/*
* [WFC: Well-Formedness Constraint: PEs in Internal Subset]
* In the internal DTD subset, parameter-entity references
* can occur only where markup declarations can occur, not
* within markup declarations.
* In that case this is handled in xmlParseMarkupDecl
*/
return;
return;
break;
case XML_PARSER_IGNORE:
return;
}
NEXT;
"PEReference: %s\n", name);
} else {
if (RAW == ';') {
NEXT;
/*
* [ WFC: Entity Declared ]
* In a document without any DTD, a document with only an
* internal DTD subset which contains no parameter entity
* references, or a document with "standalone='yes'", ...
* ... The declaration of a parameter entity must precede
* any reference to it...
*/
((ctxt->hasExternalSubset == 0) &&
"PEReference: %%%s; not found\n", name);
} else {
/*
* [ VC: Entity Declared ]
* In a document with an external subset or external
* parameter entities with "standalone='no'", ...
* ... The declaration of a parameter entity must precede
* any reference to it...
*/
"PEReference: %%%s; not found\n",
name);
} else
"PEReference: %%%s; not found\n",
}
} else {
/*
* handle the extra spaces added before and after
* c.f. http://www.w3.org/TR/REC-xml#as-PE
* this is done independently.
*/
/*
* Get the 4 first bytes and decode the charset
* if enc != XML_CHAR_ENCODING_NONE
* plug some encoding conversion routines.
* Note that, since we may have some non-UTF8
* encoding (like UTF16, bug 135229), the 'length'
* is not known, but we can calculate based upon
* the amount of data in the buffer.
*/
if (enc != XML_CHAR_ENCODING_NONE) {
}
}
}
} else {
"PEReference: %s is not a parameter entity\n",
name);
}
}
} else {
}
}
}
/*
* Macro used to grow the current buffer.
*/
}
/**
* xmlStringLenDecodeEntities:
* @ctxt: the parser context
* @str: the input string
* @len: the string length
* @what: combination of XML_SUBSTITUTE_REF and XML_SUBSTITUTE_PEREF
* @end: an end marker xmlChar, 0 if none
* @end2: an end marker xmlChar, 0 if none
* @end3: an end marker xmlChar, 0 if none
*
* Takes a entity string content and process to do the adequate substitutions.
*
* [67] Reference ::= EntityRef | CharRef
*
* [69] PEReference ::= '%' Name ';'
*
* Returns A newly allocated string with the substitution done. The caller
* must deallocate it !
*/
xmlChar *
int c,l;
return(NULL);
return(NULL);
}
/*
* allocate a translation buffer.
*/
/*
* OK loop until we reach one of the ending char or a size limit.
* we are operating on already parsed values.
*/
else
c = 0;
while ((c != 0) && (c != end) && /* non input consuming loop */
if (c == 0) break;
if (val != 0) {
}
}
"String decoding Entity Reference: %.30s\n",
str);
goto int_error;
}
} else {
"predefined entity has no content\n");
}
0, 0, 0);
while (*current != 0) { /* non input consuming loop */
goto int_error;
}
}
}
}
}
for (;i > 0;i--)
}
"String decoding PE Reference: %.30s\n", str);
goto int_error;
0, 0, 0);
while (*current != 0) { /* non input consuming loop */
goto int_error;
}
}
}
}
}
} else {
str += l;
}
}
else
c = 0;
}
return(buffer);
return(NULL);
}
/**
* xmlStringDecodeEntities:
* @ctxt: the parser context
* @str: the input string
* @what: combination of XML_SUBSTITUTE_REF and XML_SUBSTITUTE_PEREF
* @end: an end marker xmlChar, 0 if none
* @end2: an end marker xmlChar, 0 if none
* @end3: an end marker xmlChar, 0 if none
*
* Takes a entity string content and process to do the adequate substitutions.
*
* [67] Reference ::= EntityRef | CharRef
*
* [69] PEReference ::= '%' Name ';'
*
* Returns A newly allocated string with the substitution done. The caller
* must deallocate it !
*/
xmlChar *
}
/************************************************************************
* *
* Commodity functions, cleanup needed ? *
* *
************************************************************************/
/**
* areBlanks:
* @ctxt: an XML parser context
* @str: a xmlChar *
* @len: the size of @str
* @blank_chars: we know the chars are blanks
*
* Is this a sequence of blank chars that one can ignore ?
*
* Returns 1 if ignorable 0 otherwise.
*/
int blank_chars) {
int i, ret;
/*
* Don't spend time trying to differentiate them, the same callback is
* used !
*/
return(0);
/*
* Check for xml:space value.
*/
return(0);
/*
* Check that the string is made of blanks
*/
if (blank_chars == 0) {
for (i = 0;i < len;i++)
if (!(IS_BLANK_CH(str[i]))) return(0);
}
/*
* Look if the element is mixed content in the DTD if available
*/
if (ret == 0) return(1);
if (ret == 1) return(0);
}
/*
* Otherwise, heuristic :-\
*/
} else if (xmlNodeIsText(lastChild))
return(0);
return(0);
return(1);
}
/************************************************************************
* *
* Extra stuff for namespace support *
* Relates to http://www.w3.org/TR/WD-xml-names *
* *
************************************************************************/
/**
* xmlSplitQName:
* @ctxt: an XML parser context
* @name: an XML parser context
* @prefix: a xmlChar **
*
* parse an UTF8 encoded XML qualified name string
*
* [NS 5] QName ::= (Prefix ':')? LocalPart
*
* [NS 6] Prefix ::= NCName
*
* [NS 7] LocalPart ::= NCName
*
* Returns the local part, and prefix is updated
* to get the Prefix if any.
*/
xmlChar *
int len = 0;
int c;
#ifndef XML_XML_NAMESPACE
/* xml: prefix is not really a namespace */
#endif
/* nasty but well=formed */
if (cur[0] == ':')
c = *cur++;
c = *cur++;
}
/*
* Okay someone managed to make a huge name, so he's ready to pay
* for the processing speed.
*/
return(NULL);
}
while ((c != 0) && (c != ':')) { /* tested bigname.xml */
max *= 2;
return(NULL);
}
}
c = *cur++;
}
}
if ((c == ':') && (*cur == 0)) {
}
else {
}
if (c == ':') {
c = *cur;
if (c == 0) {
}
len = 0;
/*
* Check that the first character is proper to start
* a new name
*/
if (!(((c >= 0x61) && (c <= 0x7A)) ||
((c >= 0x41) && (c <= 0x5A)) ||
(c == '_') || (c == ':'))) {
int l;
"Name %s is not XML Namespace compliant\n",
name);
}
}
cur++;
c = *cur++;
}
/*
* Okay someone managed to make a huge name, so he's ready to pay
* for the processing speed.
*/
return(NULL);
}
while (c != 0) { /* tested bigname2.xml */
max *= 2;
return(NULL);
}
}
c = *cur++;
}
}
else {
}
}
return(ret);
}
/************************************************************************
* *
* The parser itself *
* Relates to http://www.w3.org/TR/REC-xml *
* *
************************************************************************/
/**
* xmlParseName:
* @ctxt: an XML parser context
*
* parse an XML name.
*
* [4] NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' |
* CombiningChar | Extender
*
* [5] Name ::= (Letter | '_' | ':') (NameChar)*
*
* [6] Names ::= Name (#x20 Name)*
*
* Returns the Name parsed or NULL
*/
const xmlChar *
int count = 0;
GROW;
/*
* Accelerator for simple ASCII names
*/
in++;
in++;
return(ret);
}
}
return(xmlParseNameComplex(ctxt));
}
/**
* xmlParseNameAndCompare:
* @ctxt: an XML parser context
*
* parse an XML name and compares for match
* (specialized for endtag parsing)
*
* Returns NULL for an illegal name, (xmlChar*) 1 for success
* and the name for mismatch
*/
static const xmlChar *
GROW;
++in;
++cmp;
}
/* success */
return (const xmlChar*) 1;
}
/* failure (or end of input buffer), check with full function */
/* strings coming from the dictionnary direct compare possible */
return (const xmlChar*) 1;
}
return ret;
}
static const xmlChar *
int len = 0, l;
int c;
int count = 0;
/*
* Handler for more complex cases
*/
GROW;
c = CUR_CHAR(l);
if ((c == ' ') || (c == '>') || (c == '/') || /* accelerators */
(!IS_LETTER(c) && (c != '_') &&
(c != ':'))) {
return(NULL);
}
(c == '.') || (c == '-') ||
(c == '_') || (c == ':') ||
(IS_COMBINING(c)) ||
(IS_EXTENDER(c)))) {
if (count++ > 100) {
count = 0;
GROW;
}
len += l;
NEXTL(l);
c = CUR_CHAR(l);
}
}
/**
* xmlParseStringName:
* @ctxt: an XML parser context
*
* parse an XML name.
*
* [4] NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' |
* CombiningChar | Extender
*
* [5] Name ::= (Letter | '_' | ':') (NameChar)*
*
* [6] Names ::= Name (#x20 Name)*
*
* Returns the Name parsed or NULL. The @str pointer
* is updated to the current location in the string.
*/
static xmlChar *
int len = 0, l;
int c;
if (!IS_LETTER(c) && (c != '_') &&
(c != ':')) {
return(NULL);
}
(c == '.') || (c == '-') ||
(c == '_') || (c == ':') ||
(IS_COMBINING(c)) ||
(IS_EXTENDER(c))) {
cur += l;
/*
* Okay someone managed to make a huge name, so he's ready to pay
* for the processing speed.
*/
return(NULL);
}
/* test bigentname.xml */
(c == '.') || (c == '-') ||
(c == '_') || (c == ':') ||
(IS_COMBINING(c)) ||
(IS_EXTENDER(c))) {
max *= 2;
return(NULL);
}
}
cur += l;
}
return(buffer);
}
}
}
/**
* xmlParseNmtoken:
* @ctxt: an XML parser context
*
* parse an XML Nmtoken.
*
* [7] Nmtoken ::= (NameChar)+
*
* [8] Nmtokens ::= Nmtoken (#x20 Nmtoken)*
*
* Returns the Nmtoken parsed or NULL
*/
xmlChar *
int len = 0, l;
int c;
int count = 0;
GROW;
c = CUR_CHAR(l);
(c == '.') || (c == '-') ||
(c == '_') || (c == ':') ||
(IS_COMBINING(c)) ||
(IS_EXTENDER(c))) {
if (count++ > 100) {
count = 0;
GROW;
}
NEXTL(l);
c = CUR_CHAR(l);
if (len >= XML_MAX_NAMELEN) {
/*
* Okay someone managed to make a huge token, so he's ready to pay
* for the processing speed.
*/
return(NULL);
}
(c == '.') || (c == '-') ||
(c == '_') || (c == ':') ||
(IS_COMBINING(c)) ||
(IS_EXTENDER(c))) {
if (count++ > 100) {
count = 0;
GROW;
}
max *= 2;
return(NULL);
}
}
NEXTL(l);
c = CUR_CHAR(l);
}
return(buffer);
}
}
if (len == 0)
return(NULL);
}
/**
* xmlParseEntityValue:
* @ctxt: an XML parser context
* @orig: if non-NULL store a copy of the original entity value
*
* parse a value for ENTITY declarations
*
* [9] EntityValue ::= '"' ([^%&"] | PEReference | Reference)* '"' |
* "'" ([^%&'] | PEReference | Reference)* "'"
*
* Returns the EntityValue parsed with reference substituted or NULL
*/
xmlChar *
int len = 0;
int c, l;
else {
return(NULL);
}
return(NULL);
}
/*
* The content of the entity definition is copied in a buffer.
*/
GROW;
NEXT;
c = CUR_CHAR(l);
/*
* NOTE: 4.4.5 Included in Literal
* When a parameter entity reference appears in a literal entity
* value, ... a single or double quote character in the replacement
* text is always treated as a normal data character and will not
* terminate the literal.
* In practice it means we stop the loop only when back at parsing
* the initial entity and the quote is found
*/
size *= 2;
return(NULL);
}
}
NEXTL(l);
/*
* Pop-up of finished entities.
*/
GROW;
c = CUR_CHAR(l);
if (c == 0) {
GROW;
c = CUR_CHAR(l);
}
}
/*
* Raise problem w.r.t. '&' and '%' being used in non-entities
* reference constructs. Note Charref will be handled in
* xmlStringDecodeEntities()
*/
while (*cur != 0) { /* non input consuming */
cur++;
"EntityValue: '%c' forbidden except for entities references\n",
tmp);
}
}
if (*cur == 0)
break;
}
cur++;
}
/*
* Then PEReference entities are substituted.
*/
if (c != stop) {
} else {
NEXT;
/*
* NOTE: 4.4.7 Bypassed
* When a general entity reference appears in the EntityValue in
* an entity declaration, it is bypassed and left as is.
* so XML_SUBSTITUTE_REF is not set here.
*/
0, 0, 0);
else
}
return(ret);
}
/**
* xmlParseAttValueComplex:
* @ctxt: an XML parser context
* @len: the resulting attribute len
* @normalize: wether to apply the inner normalization
*
* parse a value for an attribute, this is the fallback function
* of xmlParseAttValue() when the attribute parsing requires handling
* of non-ASCII characters, or normalization compaction.
*
* Returns the AttValue parsed or NULL. The value has to be freed by the caller.
*/
static xmlChar *
int c, l, in_space = 0;
if (NXT(0) == '"') {
limit = '"';
NEXT;
} else if (NXT(0) == '\'') {
limit = '\'';
NEXT;
} else {
return(NULL);
}
/*
* allocate a translation buffer.
*/
/*
* OK loop until we reach one of the ending char or a size limit.
*/
c = CUR_CHAR(l);
(IS_CHAR(c)) && (c != '<')) {
if (c == 0) break;
if (c == '&') {
in_space = 0;
if (val == '&') {
if (ctxt->replaceEntities) {
}
} else {
/*
* The reparsing will be done in xmlStringGetNodeList()
* called by the attribute() function in SAX.c
*/
}
}
} else {
}
}
} else {
ctxt->nbentities++;
}
if ((ctxt->replaceEntities == 0) &&
} else {
}
(ctxt->replaceEntities != 0)) {
0, 0, 0);
while (*current != 0) { /* non input consuming */
}
}
}
} else {
}
}
/*
* This may look absurd but is needed to detect
* entities problems
*/
XML_SUBSTITUTE_REF, 0, 0, 0);
}
/*
* Just output the reference
*/
}
for (;i > 0;i--)
}
}
} else {
if ((c == 0x20) || (c == 0xD) || (c == 0xA) || (c == 0x9)) {
}
}
in_space = 1;
}
} else {
in_space = 0;
}
}
NEXTL(l);
}
GROW;
c = CUR_CHAR(l);
}
}
if (RAW == '<') {
if ((c != 0) && (!IS_CHAR(c))) {
"invalid character in attribute value\n");
} else {
"AttValue: ' expected\n");
}
} else
NEXT;
/*
* There we potentially risk an overflow, don't allow attribute value of
* lenght more than INT_MAX it is a very reasonnable assumption !
*/
"AttValue lenght too long\n");
goto mem_error;
}
return(buf);
return(NULL);
}
/**
* xmlParseAttValue:
* @ctxt: an XML parser context
*
* parse a value for an attribute
* Note: the parser won't do substitution of entities here, this
* will be handled later in xmlStringGetNodeList
*
* [10] AttValue ::= '"' ([^<&"] | Reference)* '"' |
* "'" ([^<&'] | Reference)* "'"
*
* 3.3.3 Attribute-Value Normalization:
* Before the value of an attribute is passed to the application or
* checked for validity, the XML processor must normalize it as follows:
* - a character reference is processed by appending the referenced
* character to the attribute value
* - an entity reference is processed by recursively processing the
* replacement text of the entity
* - a whitespace character (#x20, #xD, #xA, #x9) is processed by
* appending #x20 to the normalized value, except that only a single
* #x20 is appended for a "#xD#xA" sequence that is part of an external
* parsed entity or the literal entity value of an internal parsed entity
* - other characters are processed by appending them to the normalized value
* If the declared value is not CDATA, then the XML processor must further
* process the normalized attribute value by discarding any leading and
* trailing space (#x20) characters, and by replacing sequences of space
* (#x20) characters by a single space (#x20) character.
* All attributes for which no declaration has been read should be treated
* by a non-validating parser as if declared CDATA.
*
* Returns the AttValue parsed or NULL. The value has to be freed by the caller.
*/
xmlChar *
}
/**
* xmlParseSystemLiteral:
* @ctxt: an XML parser context
*
* parse an XML Literal
*
* [11] SystemLiteral ::= ('"' [^"]* '"') | ("'" [^']* "'")
*
* Returns the SystemLiteral parsed or NULL
*/
xmlChar *
int len = 0;
int cur, l;
int count = 0;
if (RAW == '"') {
NEXT;
stop = '"';
} else if (RAW == '\'') {
NEXT;
stop = '\'';
} else {
return(NULL);
}
return(NULL);
}
size *= 2;
return(NULL);
}
}
count++;
if (count > 50) {
GROW;
count = 0;
}
NEXTL(l);
if (cur == 0) {
GROW;
}
}
} else {
NEXT;
}
return(buf);
}
/**
* xmlParsePubidLiteral:
* @ctxt: an XML parser context
*
* parse an XML public literal
*
* [12] PubidLiteral ::= '"' PubidChar* '"' | "'" (PubidChar - "'")* "'"
*
* Returns the PubidLiteral parsed or NULL.
*/
xmlChar *
int len = 0;
int count = 0;
if (RAW == '"') {
NEXT;
stop = '"';
} else if (RAW == '\'') {
NEXT;
stop = '\'';
} else {
return(NULL);
}
return(NULL);
}
size *= 2;
return(NULL);
}
}
count++;
if (count > 50) {
GROW;
count = 0;
}
NEXT;
if (cur == 0) {
GROW;
}
}
} else {
NEXT;
}
return(buf);
}
/*
* used for the test in the inner loop of the char data testing
*/
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x00, 0x27, /* & */
0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x3A, 0x3B, 0x00, 0x3D, 0x3E, 0x3F, /* < */
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x00, 0x5E, 0x5F, /* ] */
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* non-ascii */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
/**
* xmlParseCharData:
* @ctxt: an XML parser context
* @cdata: int indicating whether we are within a CDATA section
*
* parse a CharData section.
* if we are within a CDATA section ']]>' marks an end of section.
*
* The right angle bracket (>) may be represented using the string ">",
* and must, for compatibility, be escaped using ">" or a character
* reference when it appears in the string "]]>" in content, when that
* string is not marking the end of a CDATA section.
*
* [14] CharData ::= [^<&]* - ([^<&]* ']]>' [^<&]*)
*/
void
int nbchar = 0;
int ccol;
GROW;
/*
* Accelerated common case where input don't need to be
* modified before passing it to the handler.
*/
if (!cdata) {
do {
if (*in == 0xA) {
do {
in++;
} while (*in == 0xA);
goto get_more_space;
}
if (*in == '<') {
if (nbchar > 0) {
} else {
}
}
}
return;
}
while (test_char_data[*in]) {
in++;
ccol++;
}
if (*in == 0xA) {
do {
in++;
} while (*in == 0xA);
goto get_more;
}
if (*in == ']') {
return;
}
in++;
goto get_more;
}
if (nbchar > 0) {
} else {
}
}
}
if (*in == 0xD) {
in++;
if (*in == 0xA) {
in++;
continue; /* while */
}
in--;
}
if (*in == '<') {
return;
}
if (*in == '&') {
return;
}
GROW;
nbchar = 0;
}
}
/**
* xmlParseCharDataComplex:
* @ctxt: an XML parser context
* @cdata: int indicating whether we are within a CDATA section
*
* parse a CharData section.this is the fallback function
* of xmlParseCharData() when the parsing requires handling
* of non-ASCII characters.
*/
void
int nbchar = 0;
int cur, l;
int count = 0;
GROW;
(cur != '&') &&
if (cdata) break;
else {
}
}
if (nbchar >= XML_PARSER_BIG_BUFFER_SIZE) {
/*
* OK the segment is to be consumed as chars.
*/
} else {
}
}
nbchar = 0;
}
count++;
if (count > 50) {
GROW;
count = 0;
}
NEXTL(l);
}
if (nbchar != 0) {
/*
* OK the segment is to be consumed as chars.
*/
} else {
}
}
}
/* Generate the error and skip the offending character */
"PCDATA invalid Char value %d\n",
cur);
NEXTL(l);
}
}
/**
* xmlParseExternalID:
* @ctxt: an XML parser context
* @publicID: a xmlChar** receiving PubidLiteral
* @strict: indicate whether we should restrict parsing to only
* production [75], see NOTE below
*
* Parse an External ID or a Public ID
*
* NOTE: Productions [75] and [83] interact badly since [75] can generate
* 'PUBLIC' S PubidLiteral S SystemLiteral
*
* [75] ExternalID ::= 'SYSTEM' S SystemLiteral
* | 'PUBLIC' S PubidLiteral S SystemLiteral
*
* [83] PublicID ::= 'PUBLIC' S PubidLiteral
*
* Returns the function returns SystemLiteral and in the second
* case publicID receives PubidLiteral, is strict is off
* it is possible to return NULL and have publicID set.
*/
xmlChar *
SKIP(6);
if (!IS_BLANK_CH(CUR)) {
"Space required after 'SYSTEM'\n");
}
}
SKIP(6);
if (!IS_BLANK_CH(CUR)) {
"Space required after 'PUBLIC'\n");
}
}
if (strict) {
/*
* We don't handle [83] so "S SystemLiteral" is required.
*/
if (!IS_BLANK_CH(CUR)) {
"Space required after the Public Identifier\n");
}
} else {
/*
* We handle [83] so we return immediately, if
* "S SystemLiteral" is not detected. From a purely parsing
* point of view that's a nice mess.
*/
GROW;
}
}
}
return(URI);
}
/**
* xmlParseCommentComplex:
* @ctxt: an XML parser context
* @buf: the already parsed part of the buffer
* @len: number of bytes filles in the buffer
* @size: allocated size of the buffer
*
* Skip an XML (SGML) comment <!-- .... -->
* The spec says that "For compatibility, the string "--" (double-hyphen)
* must not occur within comments. "
* This is the slow routine in case the accelerator for ascii didn't work
*
* [15] Comment ::= '<!--' ((Char - '-') | ('-' (Char - '-')))* '-->'
*/
static void
int q, ql;
int r, rl;
int cur, l;
int count = 0;
len = 0;
return;
}
}
GROW; /* Assure there's enough input data */
if (q == 0)
goto not_terminated;
if (!IS_CHAR(q)) {
"xmlParseComment: invalid xmlChar value %d\n",
q);
return;
}
if (r == 0)
goto not_terminated;
if (!IS_CHAR(r)) {
"xmlParseComment: invalid xmlChar value %d\n",
q);
return;
}
if (cur == 0)
goto not_terminated;
((cur != '>') ||
(r != '-') || (q != '-'))) {
if ((r == '-') && (q == '-')) {
}
size *= 2;
return;
}
}
q = r;
r = cur;
rl = l;
count++;
if (count > 50) {
GROW;
count = 0;
}
NEXTL(l);
if (cur == 0) {
GROW;
}
}
if (cur == 0) {
"Comment not terminated \n<!--%.50s\n", buf);
"xmlParseComment: invalid xmlChar value %d\n",
cur);
} else {
"Comment doesn't start and stop in the same entity\n");
}
NEXT;
(!ctxt->disableSAX))
}
return;
"Comment not terminated\n", NULL);
return;
}
/**
* xmlParseComment:
* @ctxt: an XML parser context
*
* Skip an XML (SGML) comment <!-- .... -->
* The spec says that "For compatibility, the string "--" (double-hyphen)
* must not occur within comments. "
*
* [15] Comment ::= '<!--' ((Char - '-') | ('-' (Char - '-')))* '-->'
*/
void
int len = 0;
/*
* Check that there is a comment right here.
*/
SKIP(4);
GROW;
/*
* Accelerated common case where input don't need to be
* modified before passing it to the handler.
*/
do {
if (*in == 0xA) {
do {
in++;
} while (*in == 0xA);
}
(*in == 0x09)) {
in++;
ccol++;
}
if (*in == 0xA) {
do {
in++;
} while (*in == 0xA);
goto get_more;
}
/*
* save current set of data
*/
if (nbchar > 0) {
else
return;
}
len = 0;
return;
}
}
}
}
if (*in == 0xA) {
in++;
}
if (*in == 0xD) {
in++;
if (*in == 0xA) {
in++;
continue; /* while */
}
in--;
}
GROW;
if (*in == '-') {
SKIP(3);
(!ctxt->disableSAX)) {
else
}
return;
}
"Comment not terminated \n<!--%.50s\n",
buf);
else
"Comment not terminated \n", NULL);
in++;
}
in++;
goto get_more;
}
return;
}
/**
* xmlParsePITarget:
* @ctxt: an XML parser context
*
* parse the name of a PI
*
* [17] PITarget ::= Name - (('X' | 'x') ('M' | 'm') ('L' | 'l'))
*
* Returns the PITarget name or NULL
*/
const xmlChar *
int i;
"XML declaration allowed only at the start of the document\n");
return(name);
} else if (name[3] == 0) {
return(name);
}
for (i = 0;;i++) {
return(name);
}
"xmlParsePITarget: invalid name prefix 'xml'\n",
}
return(name);
}
#ifdef LIBXML_CATALOG_ENABLED
/**
* xmlParseCatalogPI:
* @ctxt: an XML parser context
* @catalog: the PI value string
*
* parse an XML Catalog Processing Instruction.
*
* <?oasis-xml-catalog catalog="http://example.com/catalog.xml"?>
*
* Occurs only if allowed by the user and if happening in the Misc
* part of the document before any doctype informations
* This will add the given catalog to the parsing context in order
* to be used if there is a resolution need further down in the document
*/
static void
goto error;
tmp += 7;
if (*tmp != '=') {
return;
}
tmp++;
goto error;
tmp++;
if (*tmp == 0)
goto error;
tmp++;
if (*tmp != 0)
goto error;
}
return;
"Catalog PI syntax error: %s\n",
}
#endif
/**
* xmlParsePI:
* @ctxt: an XML parser context
*
* parse an XML Processing Instruction.
*
* [16] PI ::= '<?' PITarget (S (Char* - (Char* '?>' Char*)))? '?>'
*
* The processing is transfered to SAX once parsed.
*/
void
int len = 0;
int cur, l;
int count = 0;
/*
* this is a Processing Instruction.
*/
SKIP(2);
/*
* Parse the target name and check for special support like
* namespace.
*/
"PI declaration doesn't start and stop in the same entity\n");
}
SKIP(2);
/*
* SAX: PI detected.
*/
return;
}
return;
}
"ParsePI: PI %s space expected\n", target);
}
size *= 2;
return;
}
}
count++;
if (count > 50) {
GROW;
count = 0;
}
NEXTL(l);
if (cur == 0) {
GROW;
}
}
if (cur != '?') {
"ParsePI: PI %s never end ...\n", target);
} else {
"PI declaration doesn't start and stop in the same entity\n");
}
SKIP(2);
#ifdef LIBXML_CATALOG_ENABLED
if (((state == XML_PARSER_MISC) ||
(state == XML_PARSER_START)) &&
if ((allow == XML_CATA_ALLOW_DOCUMENT) ||
(allow == XML_CATA_ALLOW_ALL))
}
#endif
/*
* SAX: PI detected.
*/
}
} else {
}
}
}
/**
* xmlParseNotationDecl:
* @ctxt: an XML parser context
*
* parse a notation declaration
*
* [82] NotationDecl ::= '<!NOTATION' S Name S (ExternalID | PublicID) S? '>'
*
* Hence there is actually 3 choices:
* 'PUBLIC' S PubidLiteral
* 'PUBLIC' S PubidLiteral S SystemLiteral
* and 'SYSTEM' S SystemLiteral
*
* See the NOTE on xmlParseExternalID().
*/
void
SKIP(10);
if (!IS_BLANK_CH(CUR)) {
"Space required after '<!NOTATION'\n");
return;
}
return;
}
if (!IS_BLANK_CH(CUR)) {
"Space required after the NOTATION name'\n");
return;
}
/*
* Parse the IDs.
*/
if (RAW == '>') {
"Notation declaration doesn't start and stop in the same entity\n");
}
NEXT;
} else {
}
}
}
/**
* xmlParseEntityDecl:
* @ctxt: an XML parser context
*
* parse <!ENTITY declarations
*
* [70] EntityDecl ::= GEDecl | PEDecl
*
* [71] GEDecl ::= '<!ENTITY' S Name S EntityDef S? '>'
*
* [72] PEDecl ::= '<!ENTITY' S '%' S Name S PEDef S? '>'
*
* [73] EntityDef ::= EntityValue | (ExternalID NDataDecl?)
*
* [74] PEDef ::= EntityValue | ExternalID
*
* [76] NDataDecl ::= S 'NDATA' S Name
*
* [ VC: Notation Declared ]
* The Name must match the declared name of a notation.
*/
void
int isParameter = 0;
int skipped;
/* GROW; done in the caller */
SKIP(8);
if (skipped == 0) {
"Space required after '<!ENTITY'\n");
}
if (RAW == '%') {
NEXT;
if (skipped == 0) {
"Space required after '%'\n");
}
isParameter = 1;
}
"xmlParseEntityDecl: no name\n");
return;
}
if (skipped == 0) {
"Space required after the entity name\n");
}
/*
* handle the various case of definitions...
*/
if (isParameter) {
if (value) {
}
} else {
}
if (URI) {
"Invalid URI: %s\n", URI);
/*
* This really ought to be a well formedness error
* but the XML Core WG decided otherwise c.f. issue
* E26 of the XML erratas.
*/
} else {
/*
* Okay this is foolish to block those but not
* invalid URIs.
*/
} else {
(!ctxt->disableSAX) &&
}
}
}
}
} else {
/*
* For expat compatibility in SAX mode.
*/
}
}
} else {
}
if (URI) {
"Invalid URI: %s\n", URI);
/*
* This really ought to be a well formedness error
* but the XML Core WG decided otherwise c.f. issue
* E26 of the XML erratas.
*/
} else {
/*
* Okay this is foolish to block those but not
* invalid URIs.
*/
}
}
}
"Space required before 'NDATA'\n");
}
SKIP(5);
if (!IS_BLANK_CH(CUR)) {
"Space required after 'NDATA'\n");
}
} else {
/*
* For expat compatibility in SAX mode.
* assuming the entity repalcement was asked for
*/
if ((ctxt->replaceEntities != 0) &&
}
}
}
}
}
if (RAW != '>') {
"xmlParseEntityDecl: entity %s not terminated\n", name);
} else {
"Entity declaration doesn't start and stop in the same entity\n");
}
NEXT;
}
/*
* Ugly mechanism to save the raw entity value.
*/
if (isParameter) {
} else {
}
}
}
else
} else
}
}
}
/**
* xmlParseDefaultDecl:
* @ctxt: an XML parser context
* @value: Receive a possible fixed default value for the attribute
*
* Parse an attribute default declaration
*
* [60] DefaultDecl ::= '#REQUIRED' | '#IMPLIED' | (('#FIXED' S)? AttValue)
*
* [ VC: Required Attribute ]
* if the default declaration is the keyword #REQUIRED, then the
* attribute must be specified for all elements of the type in the
* attribute-list declaration.
*
* [ VC: Attribute Default Legal ]
* The declared default value must meet the lexical constraints of
* the declared attribute type c.f. xmlValidateAttributeDecl()
*
* [ VC: Fixed Attribute Default ]
* if an attribute has a default value declared with the #FIXED
* keyword, instances of that attribute must match the default value.
*
* [ WFC: No < in Attribute Values ]
* handled in xmlParseAttValue()
*
* returns: XML_ATTRIBUTE_NONE, XML_ATTRIBUTE_REQUIRED, XML_ATTRIBUTE_IMPLIED
* or XML_ATTRIBUTE_FIXED.
*/
int
int val;
SKIP(9);
return(XML_ATTRIBUTE_REQUIRED);
}
SKIP(8);
return(XML_ATTRIBUTE_IMPLIED);
}
SKIP(6);
if (!IS_BLANK_CH(CUR)) {
"Space required after '#FIXED'\n");
}
}
"Attribute default value declaration error\n");
} else
return(val);
}
/**
* xmlParseNotationType:
* @ctxt: an XML parser context
*
* parse an Notation attribute type.
*
* Note: the leading 'NOTATION' S part has already being parsed...
*
* [58] NotationType ::= 'NOTATION' S '(' S? Name (S? '|' S? Name)* S? ')'
*
* [ VC: Notation Attributes ]
* Values of this type must match one of the notation names included
* in the declaration; all notation names in the declaration must be declared.
*
* Returns: the notation attribute tree built while parsing
*/
if (RAW != '(') {
return(NULL);
}
do {
NEXT;
"Name expected in NOTATION declaration\n");
return(NULL);
}
return(NULL);
}
else {
}
} while (RAW == '|');
if (RAW != ')') {
return(NULL);
}
NEXT;
return(ret);
}
/**
* xmlParseEnumerationType:
* @ctxt: an XML parser context
*
* parse an Enumeration attribute type.
*
* [59] Enumeration ::= '(' S? Nmtoken (S? '|' S? Nmtoken)* S? ')'
*
* [ VC: Enumeration ]
* Values of this type must match one of the Nmtoken tokens in
* the declaration
*
* Returns: the enumeration attribute tree built while parsing
*/
if (RAW != '(') {
return(NULL);
}
do {
NEXT;
return(ret);
}
return(NULL);
}
else {
}
} while (RAW == '|');
if (RAW != ')') {
return(ret);
}
NEXT;
return(ret);
}
/**
* xmlParseEnumeratedType:
* @ctxt: an XML parser context
* @tree: the enumeration tree built while parsing
*
* parse an Enumerated attribute type.
*
* [57] EnumeratedType ::= NotationType | Enumeration
*
* [58] NotationType ::= 'NOTATION' S '(' S? Name (S? '|' S? Name)* S? ')'
*
*
* Returns: XML_ATTRIBUTE_ENUMERATION or XML_ATTRIBUTE_NOTATION
*/
int
SKIP(8);
if (!IS_BLANK_CH(CUR)) {
"Space required after 'NOTATION'\n");
return(0);
}
return(XML_ATTRIBUTE_NOTATION);
}
return(XML_ATTRIBUTE_ENUMERATION);
}
/**
* xmlParseAttributeType:
* @ctxt: an XML parser context
* @tree: the enumeration tree built while parsing
*
* parse the Attribute list def for an element
*
* [54] AttType ::= StringType | TokenizedType | EnumeratedType
*
* [55] StringType ::= 'CDATA'
*
* [56] TokenizedType ::= 'ID' | 'IDREF' | 'IDREFS' | 'ENTITY' |
* 'ENTITIES' | 'NMTOKEN' | 'NMTOKENS'
*
* Validity constraints for attribute values syntax are checked in
* xmlValidateAttributeValue()
*
* [ VC: ID ]
* Values of type ID must match the Name production. A name must not
* appear more than once in an XML document as a value of this type;
* i.e., ID values must uniquely identify the elements which bear them.
*
* [ VC: One ID per Element Type ]
* No element type may have more than one ID attribute specified.
*
* [ VC: ID Attribute Default ]
* An ID attribute must have a declared default of #IMPLIED or #REQUIRED.
*
* [ VC: IDREF ]
* Values of type IDREF must match the Name production, and values
* of type IDREFS must match Names; each IDREF Name must match the value
* of an ID attribute on some element in the XML document; i.e. IDREF
* values must match the value of some ID attribute.
*
* [ VC: Entity Name ]
* Values of type ENTITY must match the Name production, values
* of type ENTITIES must match Names; each Entity Name must match the
* name of an unparsed entity declared in the DTD.
*
* [ VC: Name Token ]
* Values of type NMTOKEN must match the Nmtoken production; values
* of type NMTOKENS must match Nmtokens.
*
* Returns the attribute type
*/
int
SKIP(5);
return(XML_ATTRIBUTE_CDATA);
SKIP(6);
return(XML_ATTRIBUTE_IDREFS);
SKIP(5);
return(XML_ATTRIBUTE_IDREF);
SKIP(2);
return(XML_ATTRIBUTE_ID);
SKIP(6);
return(XML_ATTRIBUTE_ENTITY);
SKIP(8);
return(XML_ATTRIBUTE_ENTITIES);
SKIP(8);
return(XML_ATTRIBUTE_NMTOKENS);
SKIP(7);
return(XML_ATTRIBUTE_NMTOKEN);
}
}
/**
* xmlParseAttributeListDecl:
* @ctxt: an XML parser context
*
* : parse the Attribute list def for an element
*
* [52] AttlistDecl ::= '<!ATTLIST' S Name AttDef* S? '>'
*
* [53] AttDef ::= S Name S AttType S DefaultDecl
*
*/
void
SKIP(9);
if (!IS_BLANK_CH(CUR)) {
"Space required after '<!ATTLIST'\n");
}
"ATTLIST: no name for Element\n");
return;
}
GROW;
while (RAW != '>') {
int type;
int def;
GROW;
"ATTLIST: no name for Attribute\n");
break;
}
GROW;
if (!IS_BLANK_CH(CUR)) {
"Space required after the attribute name\n");
break;
}
if (type <= 0) {
break;
}
GROW;
if (!IS_BLANK_CH(CUR)) {
"Space required after the attribute type\n");
break;
}
if (def <= 0) {
if (defaultValue != NULL)
break;
}
GROW;
if (RAW != '>') {
if (!IS_BLANK_CH(CUR)) {
"Space required after the attribute default value\n");
if (defaultValue != NULL)
break;
}
}
"in xmlParseAttributeListDecl\n");
if (defaultValue != NULL)
break;
}
(def != XML_ATTRIBUTE_IMPLIED) &&
(def != XML_ATTRIBUTE_REQUIRED)) {
}
}
if (defaultValue != NULL)
GROW;
}
if (RAW == '>') {
"Attribute list declaration doesn't start and stop in the same entity\n");
}
NEXT;
}
}
}
/**
* xmlParseElementMixedContentDecl:
* @ctxt: an XML parser context
* @inputchk: the input used for the current entity, needed for boundary checks
*
* parse the declaration for a Mixed Element content
* The leading '(' and spaces have been skipped in xmlParseElementContentDecl
*
* [51] Mixed ::= '(' S? '#PCDATA' (S? '|' S? Name)* S? ')*' |
* '(' S? '#PCDATA' S? ')'
*
*
* [ VC: No Duplicate Types ]
* The same name must not appear more than once in a single
* mixed-content declaration.
*
* returns: the list of the xmlElementContentPtr describing the element choices
*/
GROW;
SKIP(7);
if (RAW == ')') {
"Element content declaration doesn't start and stop in the same entity\n",
NULL);
}
NEXT;
if (RAW == '*') {
NEXT;
}
return(ret);
}
}
while (RAW == '|') {
NEXT;
} else {
if (n != NULL)
cur = n;
}
"xmlParseElementMixedContentDecl : Name expected\n");
return(NULL);
}
GROW;
}
}
"Element content declaration doesn't start and stop in the same entity\n",
NULL);
}
SKIP(2);
} else {
return(NULL);
}
} else {
}
return(ret);
}
/**
* xmlParseElementChildrenContentDecl:
* @ctxt: an XML parser context
* @inputchk: the input used for the current entity, needed for boundary checks
*
* parse the declaration for a Mixed Element content
* The leading '(' and spaces have been skipped in xmlParseElementContentDecl
*
*
* [47] children ::= (choice | seq) ('?' | '*' | '+')?
*
* [48] cp ::= (Name | choice | seq) ('?' | '*' | '+')?
*
* [49] choice ::= '(' S? cp ( S? '|' S? cp )* S? ')'
*
* [50] seq ::= '(' S? cp ( S? ',' S? cp )* S? ')'
*
* TODO Parameter-entity replacement text must be properly nested
* with parenthesized groups. That is to say, if either of the
* opening or closing parentheses in a choice, seq, or Mixed
* construct is contained in the replacement text for a parameter
* entity, both must be contained in the same replacement text. For
* interoperability, if a parameter-entity reference appears in a
* choice, seq, or Mixed construct, its replacement text should not
* be empty, and neither the first nor last non-blank character of
* the replacement text should be a connector (| or ,).
*
* Returns the tree of xmlElementContentPtr describing the element
* hierarchy.
*/
"xmlParseElementChildrenContentDecl : depth %d too deep\n",
return(NULL);
}
GROW;
if (RAW == '(') {
/* Recurse on first child */
NEXT;
GROW;
} else {
return(NULL);
}
return(NULL);
}
GROW;
if (RAW == '?') {
NEXT;
} else if (RAW == '*') {
NEXT;
} else if (RAW == '+') {
NEXT;
} else {
}
GROW;
}
while (RAW != ')') {
/*
* Each loop we parse one separator and one element.
*/
if (RAW == ',') {
/*
* Detect "Name | Name , Name" error
*/
"xmlParseElementChildrenContentDecl : '%c' expected\n",
type);
return(NULL);
}
NEXT;
return(NULL);
}
} else {
}
} else if (RAW == '|') {
/*
* Detect "Name , Name | Name" error
*/
"xmlParseElementChildrenContentDecl : '%c' expected\n",
type);
return(NULL);
}
NEXT;
return(NULL);
}
} else {
}
} else {
return(NULL);
}
GROW;
GROW;
if (RAW == '(') {
/* Recurse on second child */
NEXT;
} else {
return(NULL);
}
if (RAW == '?') {
NEXT;
} else if (RAW == '*') {
NEXT;
} else if (RAW == '+') {
NEXT;
} else {
}
}
GROW;
}
}
"Element content declaration doesn't start and stop in the same entity\n",
NULL);
}
NEXT;
if (RAW == '?') {
else
}
NEXT;
} else if (RAW == '*') {
/*
* Some normalization:
* (a | b* | c?)* == (a | b | c)*
*/
}
}
NEXT;
} else if (RAW == '+') {
int found = 0;
else
/*
* Some normalization:
* (a | b*)+ == (a | b)*
* (a | b?)+ == (a | b)*
*/
found = 1;
}
found = 1;
}
}
if (found)
}
NEXT;
}
return(ret);
}
/**
* xmlParseElementContentDecl:
* @ctxt: an XML parser context
* @name: the name of the element being defined.
* @result: the Element Content pointer will be stored here if any
*
* parse the declaration for an Element content either Mixed or Children,
* the cases EMPTY and ANY are handled directly in xmlParseElementDecl
*
* [46] contentspec ::= 'EMPTY' | 'ANY' | Mixed | children
*
* returns: the type of element content XML_ELEMENT_TYPE_xxx
*/
int
int res;
if (RAW != '(') {
"xmlParseElementContentDecl : %s '(' expected\n", name);
return(-1);
}
NEXT;
GROW;
} else {
}
return(res);
}
/**
* xmlParseElementDecl:
* @ctxt: an XML parser context
*
* parse an Element declaration.
*
* [45] elementdecl ::= '<!ELEMENT' S Name S contentspec S? '>'
*
* [ VC: Unique Element Type Declaration ]
* No element type may be declared more than once
*
* Returns the type of the element, or -1 in case of error
*/
int
/* GROW; done in the caller */
SKIP(9);
if (!IS_BLANK_CH(CUR)) {
"Space required after 'ELEMENT'\n");
}
"xmlParseElementDecl: no name for Element\n");
return(-1);
}
if (!IS_BLANK_CH(CUR)) {
"Space required after the element name\n");
}
SKIP(5);
/*
* Element must always be empty.
*/
SKIP(3);
/*
* Element is a generic container.
*/
} else if (RAW == '(') {
} else {
/*
* [ WFC: PEs in Internal Subset ] error handling.
*/
"PEReference: forbidden within markup decl in internal subset\n");
} else {
"xmlParseElementDecl: 'EMPTY', 'ANY' or '(' expected\n");
}
return(-1);
}
/*
* Pop-up of finished entities.
*/
if (RAW != '>') {
}
} else {
"Element declaration doesn't start and stop in the same entity\n");
}
NEXT;
content);
/*
* this is a trick: if xmlAddElementDecl is called,
* instead of copying the full tree it is plugged directly
* if called from the parser. Avoid duplicating the
*/
}
}
}
}
return(ret);
}
/**
* xmlParseConditionalSections
* @ctxt: an XML parser context
*
* [61] conditionalSect ::= includeSect | ignoreSect
* [62] includeSect ::= '<![' S? 'INCLUDE' S? '[' extSubsetDecl ']]>'
* [63] ignoreSect ::= '<![' S? 'IGNORE' S? '[' ignoreSectContents* ']]>'
* [64] ignoreSectContents ::= Ignore ('<![' ignoreSectContents ']]>' Ignore)*
* [65] Ignore ::= Char* - (Char* ('<![' | ']]>') Char*)
*/
static void
SKIP(3);
SKIP(7);
if (RAW != '[') {
} else {
NEXT;
}
if (xmlParserDebugEntities) {
"Entering INCLUDE Conditional Section\n");
}
} else if (IS_BLANK_CH(CUR)) {
NEXT;
} else if (RAW == '%') {
} else
/*
* Pop-up of finished entities.
*/
break;
}
}
if (xmlParserDebugEntities) {
"Leaving INCLUDE Conditional Section\n");
}
int state;
int depth = 0;
SKIP(6);
if (RAW != '[') {
} else {
NEXT;
}
if (xmlParserDebugEntities) {
"Entering IGNORE Conditional Section\n");
}
/*
* Parse up to the end of the conditional section
* But disable SAX event generating DTD building in the meantime
*/
depth++;
SKIP(3);
continue;
}
continue;
}
NEXT;
continue;
}
if (xmlParserDebugEntities) {
"Leaving IGNORE Conditional Section\n");
}
} else {
}
if (RAW == 0)
if (RAW == 0) {
} else {
SKIP(3);
}
}
/**
* xmlParseMarkupDecl:
* @ctxt: an XML parser context
*
* parse Markup declarations
*
* [29] markupdecl ::= elementdecl | AttlistDecl | EntityDecl |
* NotationDecl | PI | Comment
*
* [ VC: Proper Declaration/PE Nesting ]
* Parameter-entity replacement text must be properly nested with
* markup declarations. That is to say, if either the first character
* or the last character of a markup declaration (markupdecl above) is
* contained in the replacement text for a parameter-entity reference,
* both must be contained in the same replacement text.
*
* [ WFC: PEs in Internal Subset ]
* In the internal DTD subset, parameter-entity references can occur
* only where markup declarations can occur, not within markup declarations.
* (This does not apply to references that occur in external parameter
* entities or to the external subset.)
*/
void
GROW;
if (CUR == '<') {
switch (NXT(2)) {
case 'E':
break;
case 'A':
break;
case 'N':
break;
case '-':
break;
default:
/* there is an error but it will be detected later */
break;
}
}
}
/*
* This is only for internal subset. On external entities,
* the replacement is done before parsing stage
*/
/*
* Conditional sections are allowed from entities included
* by PE References in the internal subset.
*/
}
}
}
/**
* xmlParseTextDecl:
* @ctxt: an XML parser context
*
* parse an XML declaration header for external entities
*
* [77] TextDecl ::= '<?xml' VersionInfo? EncodingDecl S? '?>'
*
* Question: Seems that EncodingDecl is mandatory ? Is that a typo ?
*/
void
/*
* We know that '<?xml' is here.
*/
SKIP(5);
} else {
return;
}
if (!IS_BLANK_CH(CUR)) {
"Space needed after '<?xml'\n");
}
/*
* We may have the VersionInfo here.
*/
else {
if (!IS_BLANK_CH(CUR)) {
"Space needed here\n");
}
}
/*
* We must have the encoding declaration
*/
/*
* The XML REC instructs us to stop parsing right here
*/
return;
}
"Missing encoding in text declaration\n");
}
SKIP(2);
} else if (RAW == '>') {
/* Deprecated old WD ... */
NEXT;
} else {
NEXT;
}
}
/**
* xmlParseExternalSubset:
* @ctxt: an XML parser context
* @ExternalID: the external identifier
* @SystemID: the system identifier (or URL)
*
* parse Markup declarations from an external subset
*
* [30] extSubset ::= textDecl? extSubsetDecl
*
* [31] extSubsetDecl ::= (markupdecl | conditionalSect | PEReference | S) *
*/
void
GROW;
/*
* The XML REC instructs us to stop parsing right here
*/
return;
}
}
}
GROW;
} else if (IS_BLANK_CH(CUR)) {
NEXT;
} else if (RAW == '%') {
} else
/*
* Pop-up of finished entities.
*/
break;
}
}
if (RAW != 0) {
}
}
/**
* xmlParseReference:
* @ctxt: an XML parser context
*
* parse and handle entity references in content, depending on the SAX
* interface, this may end-up in a call to character() if this is a
* CharRef, a predefined entity, if there is no reference() callback.
* or if the parser was asked to switch to that mode.
*
* [67] Reference ::= EntityRef | CharRef
*/
void
if (RAW != '&') return;
int i = 0;
/*
* So we are using non-UTF-8 buffers
* Check that the char fit on 8bits, if not
* generate a CharRef.
*/
if (value <= 0xFF) {
out[1] = 0;
(!ctxt->disableSAX))
} else {
else
(!ctxt->disableSAX))
}
} else {
/*
* Just encode the value in UTF-8
*/
out[i] = 0;
(!ctxt->disableSAX))
}
} else {
int was_checked;
if (!ctxt->wellFormed)
return;
/*
* The first reference to the entity trigger a parsing phase
* where the ent->children is filled with the result from
* the parsing.
*/
/*
* Check that this entity is well formed
*/
/*
* DONE: get definite answer on this !!!
* Lots of entity decls are used to declare a single
* char
* <!ENTITY lt "<">
* Which seems to be valid since
* 2.4: The ampersand character (&) and the left angle
* bracket (<) may appear in their literal form only
* when used ... They are also legal within the literal
* entity value of an internal entity declaration;i
* see "4.3.2 Well-Formed Parsed Entities".
* IMHO 2.4 and 4.3.2 are directly in contradiction.
* Looking at the OASIS test suite and James Clark
* tests, this is broken. However the XML REC uses
* it. Is the XML REC not well-formed ????
* This is a hack to avoid this problem
*
* ANSWER: since lt gt amp .. are already defined,
* this is a redefinition and hence the fact that the
* content is not well balanced is not a Wf error, this
* is lousy but acceptable.
*/
} else {
}
}
} else {
/*
* 4.3.2: An internal general parsed entity is well-formed
* if its replacement text matches the production labeled
* content.
*/
void *user_data;
/*
* This is a bit hackish but this seems the best
* way to make sure both SAX and DOM entity support
* behaves okay.
*/
else
} else {
"invalid entity type found\n", NULL);
}
/*
* Store the number of entities needing parsing for entity
* content and do checkings
*/
}
if (ret == XML_ERR_ENTITY_LOOP) {
return;
}
return;
}
if (ret == XML_ERR_ENTITY_LOOP) {
return;
if (ctxt->replaceEntities) {
/*
* Prune it directly in the generated document
* except for single text nodes.
*/
} else {
}
#ifdef LIBXML_LEGACY_ENABLED
#endif /* LIBXML_LEGACY_ENABLED */
}
} else {
}
}
} else {
}
} else if ((ret != XML_ERR_OK) &&
(ret != XML_WAR_UNDECLARED_ENTITY)) {
}
}
}
/*
* Probably running in SAX mode and the callbacks don't
* build the entity content. So unless we already went
* though parsing for first checking go though the entity
* content to generate callbacks associated to the entity
*/
if (was_checked == 1) {
void *user_data;
/*
* This is a bit hackish but this seems the best
* way to make sure both SAX and DOM entity support
* behaves okay.
*/
else
} else {
"invalid entity type found\n", NULL);
}
if (ret == XML_ERR_ENTITY_LOOP) {
return;
}
}
/*
* Entity reference callback comes second, it's somewhat
* superfluous but a compatibility to historical behaviour
*/
}
return;
}
/*
* Create a node.
*/
return;
}
/*
* There is a problem on the handling of _private for entities
* (bug 155816): Should we copy the content of the field from
* the entity (possibly overwriting some value set by the user
* when a copy is created), should we leave it alone, or should
* we try to take care of different situations? The problem
* is exacerbated by the usage of this field by the xmlReader.
* To fix this bug, we look at _private on the created node
* and, if it's NULL, we copy in whatever was in the entity.
* If it's not NULL we leave it alone. This is somewhat of a
* hack - maybe we should have further tests to determine
* what to do.
*/
/*
* Seems we are generating the DOM content, do
* a simple tree copy for all references except the first
* In the first occurrence list contains the replacement.
* progressive == 2 means we are operating on the Reader
* and since nodes are discarded we must copy all the time.
*/
/*
* We are copying here, make sure there is no abuse
*/
return;
/*
* when operating on a reader, the entities definitions
* are always owning the entities subtree.
if (ctxt->parseMode == XML_PARSE_READER)
ent->owner = 1;
*/
if (firstChild == NULL){
firstChild = nw;
}
}
/*
* needed to detect some strange empty
* node cases in the reader tests
*/
break;
}
}
#ifdef LIBXML_LEGACY_ENABLED
#endif /* LIBXML_LEGACY_ENABLED */
/*
* We are copying here, make sure there is no abuse
*/
return;
/*
* Copy the entity child list and make it the new
* entity child list. The goal is to make sure any
* ID or REF referenced will be the one from the
* document content and not the entity copy.
*/
if (firstChild == NULL){
firstChild = cur;
}
}
break;
}
#ifdef LIBXML_LEGACY_ENABLED
#endif /* LIBXML_LEGACY_ENABLED */
} else {
/*
* the name change is to avoid coalescing of the
* node with a possible previous text one which
* would make ent->children a dangling pointer
*/
-1);
}
/*
* This is to avoid a nasty side effect, see
* characters() in SAX.c
*/
return;
}
}
} else {
/*
* inline the entity.
*/
(!ctxt->disableSAX))
}
}
}
/**
* xmlParseEntityRef:
* @ctxt: an XML parser context
*
* parse ENTITY references declarations
*
* [68] EntityRef ::= '&' Name ';'
*
* [ WFC: Entity Declared ]
* In a document without any DTD, a document with only an internal DTD
* subset which contains no parameter entity references, or a document
* with "standalone='yes'", the Name given in the entity reference
* must match that in an entity declaration, except that well-formed
* documents need not declare any of the following entities: amp, lt,
* gt, apos, quot. The declaration of a parameter entity must precede
* any reference to it. Similarly, the declaration of a general entity
* must precede any reference to it which appears in a default value in an
* attribute-list declaration. Note that if entities are declared in the
* external subset or in external parameter entities, a non-validating
* processor is not obligated to read and process their declarations;
* for such documents, the rule that an entity must be declared is a
* well-formedness constraint only if standalone='yes'.
*
* [ WFC: Parsed Entity ]
* An entity reference must not contain the name of an unparsed entity
*
* Returns the xmlEntityPtr if found, or NULL otherwise.
*/
GROW;
if (RAW == '&') {
NEXT;
"xmlParseEntityRef: no name\n");
} else {
if (RAW == ';') {
NEXT;
/*
* Increase the number of entity references parsed
*/
ctxt->nbentities++;
/*
* Ask first SAX for entity resolution, otherwise try the
* predefined set.
*/
}
}
/*
* [ WFC: Entity Declared ]
* In a document without any DTD, a document with only an
* internal DTD subset which contains no parameter entity
* references, or a document with "standalone='yes'", the
* Name given in the entity reference must match that in an
* entity declaration, except that well-formed documents
* need not declare any of the following entities: amp, lt,
* gt, apos, quot.
* The declaration of a parameter entity must precede any
* reference to it.
* Similarly, the declaration of a general entity must
* precede any reference to it which appears in a default
* value in an attribute-list declaration. Note that if
* entities are declared in the external subset or in
* external parameter entities, a non-validating processor
* is not obligated to read and process their declarations;
* for such documents, the rule that an entity must be
* declared is a well-formedness constraint only if
* standalone='yes'.
*/
((ctxt->hasExternalSubset == 0) &&
"Entity '%s' not defined\n", name);
} else {
"Entity '%s' not defined\n", name);
}
}
}
/*
* [ WFC: Parsed Entity ]
* An entity reference must not contain the name of an
* unparsed entity
*/
"Entity reference to unparsed entity %s\n", name);
}
/*
* [ WFC: No External Entity References ]
* Attribute values cannot contain direct or indirect
* entity references to external entities.
*/
"Attribute references external entity '%s'\n", name);
}
/*
* [ WFC: No < in Attribute Values ]
* The replacement text of any entity referred to directly or
* indirectly in an attribute value (other than "<") must
* not contain a <.
*/
"'<' in entity '%s' is not allowed in attributes values\n", name);
}
/*
* Internal check, no parameter entities here ...
*/
else {
"Attempt to reference the parameter entity '%s'\n",
name);
break;
default:
break;
}
}
/*
* [ WFC: No Recursion ]
* A parsed entity must not contain a recursive reference
* to itself, either directly or indirectly.
* Done somewhere else
*/
} else {
}
}
}
return(ent);
}
/**
* xmlParseStringEntityRef:
* @ctxt: an XML parser context
* @str: a pointer to an index in the string
*
* parse ENTITY references declarations, but this version parses it from
* a string value.
*
* [68] EntityRef ::= '&' Name ';'
*
* [ WFC: Entity Declared ]
* In a document without any DTD, a document with only an internal DTD
* subset which contains no parameter entity references, or a document
* with "standalone='yes'", the Name given in the entity reference
* must match that in an entity declaration, except that well-formed
* documents need not declare any of the following entities: amp, lt,
* gt, apos, quot. The declaration of a parameter entity must precede
* any reference to it. Similarly, the declaration of a general entity
* must precede any reference to it which appears in a default value in an
* attribute-list declaration. Note that if entities are declared in the
* external subset or in external parameter entities, a non-validating
* processor is not obligated to read and process their declarations;
* for such documents, the rule that an entity must be declared is a
* well-formedness constraint only if standalone='yes'.
*
* [ WFC: Parsed Entity ]
* An entity reference must not contain the name of an unparsed entity
*
* Returns the xmlEntityPtr if found, or NULL otherwise. The str pointer
* is updated to the current location in the string.
*/
return(NULL);
if (cur == '&') {
ptr++;
"xmlParseStringEntityRef: no name\n");
} else {
if (*ptr == ';') {
ptr++;
/*
* Increase the number of entity references parsed
*/
ctxt->nbentities++;
/*
* Ask first SAX for entity resolution, otherwise try the
* predefined set.
*/
}
}
/*
* [ WFC: Entity Declared ]
* In a document without any DTD, a document with only an
* internal DTD subset which contains no parameter entity
* references, or a document with "standalone='yes'", the
* Name given in the entity reference must match that in an
* entity declaration, except that well-formed documents
* need not declare any of the following entities: amp, lt,
* gt, apos, quot.
* The declaration of a parameter entity must precede any
* reference to it.
* Similarly, the declaration of a general entity must
* precede any reference to it which appears in a default
* value in an attribute-list declaration. Note that if
* entities are declared in the external subset or in
* external parameter entities, a non-validating processor
* is not obligated to read and process their declarations;
* for such documents, the rule that an entity must be
* declared is a well-formedness constraint only if
* standalone='yes'.
*/
((ctxt->hasExternalSubset == 0) &&
"Entity '%s' not defined\n", name);
} else {
"Entity '%s' not defined\n",
name);
}
/* TODO ? check regressions ctxt->valid = 0; */
}
/*
* [ WFC: Parsed Entity ]
* An entity reference must not contain the name of an
* unparsed entity
*/
"Entity reference to unparsed entity %s\n", name);
}
/*
* [ WFC: No External Entity References ]
* Attribute values cannot contain direct or indirect
* entity references to external entities.
*/
"Attribute references external entity '%s'\n", name);
}
/*
* [ WFC: No < in Attribute Values ]
* The replacement text of any entity referred to directly or
* indirectly in an attribute value (other than "<") must
* not contain a <.
*/
"'<' in entity '%s' is not allowed in attributes values\n",
name);
}
/*
* Internal check, no parameter entities here ...
*/
else {
"Attempt to reference the parameter entity '%s'\n",
name);
break;
default:
break;
}
}
/*
* [ WFC: No Recursion ]
* A parsed entity must not contain a recursive reference
* to itself, either directly or indirectly.
* Done somewhere else
*/
} else {
}
}
}
return(ent);
}
/**
* xmlParsePEReference:
* @ctxt: an XML parser context
*
* parse PEReference declarations
* The entity content is handled directly by pushing it's content as
* a new input stream.
*
* [69] PEReference ::= '%' Name ';'
*
* [ WFC: No Recursion ]
* A parsed entity must not contain a recursive
* reference to itself, either directly or indirectly.
*
* [ WFC: Entity Declared ]
* In a document without any DTD, a document with only an internal DTD
* subset which contains no parameter entity references, or a document
* with "standalone='yes'", ... ... The declaration of a parameter
* entity must precede any reference to it...
*
* [ VC: Entity Declared ]
* In a document with an external subset or external parameter entities
* with "standalone='no'", ... ... The declaration of a parameter entity
* must precede any reference to it...
*
* [ WFC: In DTD ]
* Parameter-entity references may only appear in the DTD.
* NOTE: misleading but this is handled.
*/
void
{
if (RAW == '%') {
NEXT;
"xmlParsePEReference: no name\n");
} else {
if (RAW == ';') {
NEXT;
/*
* Increase the number of entity references parsed
*/
ctxt->nbentities++;
name);
/*
* [ WFC: Entity Declared ]
* In a document without any DTD, a document with only an
* internal DTD subset which contains no parameter entity
* references, or a document with "standalone='yes'", ...
* ... The declaration of a parameter entity must precede
* any reference to it...
*/
((ctxt->hasExternalSubset == 0) &&
"PEReference: %%%s; not found\n",
name);
} else {
/*
* [ VC: Entity Declared ]
* In a document with an external subset or external
* parameter entities with "standalone='no'", ...
* ... The declaration of a parameter entity must
* precede any reference to it...
*/
"PEReference: %%%s; not found\n",
}
} else {
/*
* Internal checking in case the entity quest barfed
*/
"Internal: %%%s; is not a parameter entity\n",
input =
} else {
/*
* TODO !!!
* handle the extra spaces added before and after
* c.f. http://www.w3.org/TR/REC-xml#as-PE
*/
/*
* The XML REC instructs us to stop parsing
* right here
*/
return;
}
}
}
}
} else {
}
}
}
}
/**
* xmlParseStringPEReference:
* @ctxt: an XML parser context
* @str: a pointer to an index in the string
*
* parse PEReference declarations
*
* [69] PEReference ::= '%' Name ';'
*
* [ WFC: No Recursion ]
* A parsed entity must not contain a recursive
* reference to itself, either directly or indirectly.
*
* [ WFC: Entity Declared ]
* In a document without any DTD, a document with only an internal DTD
* subset which contains no parameter entity references, or a document
* with "standalone='yes'", ... ... The declaration of a parameter
* entity must precede any reference to it...
*
* [ VC: Entity Declared ]
* In a document with an external subset or external parameter entities
* with "standalone='no'", ... ... The declaration of a parameter entity
* must precede any reference to it...
*
* [ WFC: In DTD ]
* Parameter-entity references may only appear in the DTD.
* NOTE: misleading but this is handled.
*
* Returns the string of the entity content.
* str is updated to the current value of the index
*/
if (cur == '%') {
ptr++;
"xmlParseStringPEReference: no name\n");
} else {
if (cur == ';') {
ptr++;
/*
* Increase the number of entity references parsed
*/
ctxt->nbentities++;
name);
/*
* [ WFC: Entity Declared ]
* In a document without any DTD, a document with only an
* internal DTD subset which contains no parameter entity
* references, or a document with "standalone='yes'", ...
* ... The declaration of a parameter entity must precede
* any reference to it...
*/
((ctxt->hasExternalSubset == 0) &&
"PEReference: %%%s; not found\n", name);
} else {
/*
* [ VC: Entity Declared ]
* In a document with an external subset or external
* parameter entities with "standalone='no'", ...
* ... The declaration of a parameter entity must
* precede any reference to it...
*/
"PEReference: %%%s; not found\n",
}
} else {
/*
* Internal checking in case the entity quest barfed
*/
"%%%s; is not a parameter entity\n",
}
}
} else {
}
}
}
return(entity);
}
/**
* xmlParseDocTypeDecl:
* @ctxt: an XML parser context
*
* parse a DOCTYPE declaration
*
* [28] doctypedecl ::= '<!DOCTYPE' S Name (S ExternalID)? S?
* ('[' (markupdecl | PEReference | S)* ']' S?)? '>'
*
* [ VC: Root Element Type ]
* The Name in the document type declaration must match the element
* type of the root element.
*/
void
/*
* We know that '<!DOCTYPE' has been detected.
*/
SKIP(9);
/*
* Parse the DOCTYPE name.
*/
"xmlParseDocTypeDecl : no DOCTYPE name !\n");
}
/*
* Check for SystemID and ExternalID
*/
}
/*
* Create and update the internal subset.
*/
(!ctxt->disableSAX))
/*
* Is there any internal subset declarations ?
* they are handled separately in xmlParseInternalSubset()
*/
if (RAW == '[')
return;
/*
* We should be at the end of the DOCTYPE declaration.
*/
if (RAW != '>') {
}
NEXT;
}
/**
* xmlParseInternalSubset:
* @ctxt: an XML parser context
*
* parse the internal subset declaration
*
* [28 end] ('[' (markupdecl | PEReference | S)* ']' S?)? '>'
*/
static void
/*
* Is there any DTD definition ?
*/
if (RAW == '[') {
NEXT;
/*
* Parse the succession of Markup declarations and
* PEReferences.
* Subsequence (markupdecl | PEReference | S)*
*/
while (RAW != ']') {
/*
* Pop-up of finished entities.
*/
"xmlParseInternalSubset: error detected in Markup declaration\n");
break;
}
}
if (RAW == ']') {
NEXT;
}
}
/*
* We should be at the end of the DOCTYPE declaration.
*/
if (RAW != '>') {
}
NEXT;
}
#ifdef LIBXML_SAX1_ENABLED
/**
* xmlParseAttribute:
* @ctxt: an XML parser context
* @value: a xmlChar ** used to store the value of the attribute
*
* parse an attribute
*
* [41] Attribute ::= Name Eq AttValue
*
* [ WFC: No External Entity References ]
* Attribute values cannot contain direct or indirect entity references
* to external entities.
*
* [ WFC: No < in Attribute Values ]
* The replacement text of any entity referred to directly or indirectly in
* an attribute value (other than "<") must not contain a <.
*
* [ VC: Attribute Value Type ]
* The attribute must have been declared; the value must be of the type
* declared for it.
*
* [25] Eq ::= S? '=' S?
*
* With namespace:
*
* [NS 11] Attribute ::= QName Eq AttValue
*
* Also the case QName == xmlns:??? is handled independently as a namespace
* definition.
*
* Returns the attribute name, and the value in *value.
*/
const xmlChar *
GROW;
"error parsing attribute name\n");
return(NULL);
}
/*
* read the value
*/
if (RAW == '=') {
NEXT;
} else {
"Specification mandate value for attribute %s\n", name);
return(NULL);
}
/*
* Check that xml:lang conforms to the specification
* No more registered as an error, just generate a warning now
* since this was deprecated in XML second edition
*/
if (!xmlCheckLanguageID(val)) {
"Malformed value for xml:lang : %s\n",
}
}
/*
* Check that xml:space conforms to the specification
*/
else {
"Invalid value \"%s\" for xml:space : \"default\" or \"preserve\" expected\n",
}
}
return(name);
}
/**
* xmlParseStartTag:
* @ctxt: an XML parser context
*
* parse a start of tag either for rule element or
* EmptyElement. In both case we don't parse the tag closing chars.
*
* [40] STag ::= '<' Name (S Attribute)* S? '>'
*
* [ WFC: Unique Att Spec ]
* No attribute name may appear more than once in the same start-tag or
* empty-element tag.
*
* [44] EmptyElemTag ::= '<' Name (S Attribute)* S? '/>'
*
* [ WFC: Unique Att Spec ]
* No attribute name may appear more than once in the same start-tag or
* empty-element tag.
*
* With namespace:
*
* [NS 8] STag ::= '<' QName (S Attribute)* S? '>'
*
* [NS 10] EmptyElement ::= '<' QName (S Attribute)* S? '/>'
*
* Returns the element name parsed
*/
const xmlChar *
int nbatts = 0;
int i;
"xmlParseStartTag: invalid element name\n");
return(NULL);
}
/*
* Now parse the attributes, it ends up with the ending
*
* (S Attribute)* S?
*/
GROW;
while ((RAW != '>') &&
(IS_BYTE_CHAR(RAW))) {
/*
* [ WFC: Unique Att Spec ]
* No attribute name may appear more than once in the same
* start-tag or empty-element tag.
*/
for (i = 0; i < nbatts;i += 2) {
goto failed;
}
}
/*
* Add the pair to atts
*/
goto failed;
}
const xmlChar **n;
maxatts *= 2;
if (n == NULL) {
goto failed;
}
atts = n;
}
} else {
}
break;
if (!IS_BLANK_CH(RAW)) {
"attributes construct error\n");
}
"xmlParseStartTag: problem parsing attributes\n");
break;
}
GROW;
}
/*
* SAX: Start of Element !
*/
(!ctxt->disableSAX)) {
if (nbatts > 0)
else
}
/* Free only the content strings */
}
return(name);
}
/**
* xmlParseEndTag1:
* @ctxt: an XML parser context
* @line: line of the start tag
* @nsNr: number of namespaces on the start tag
*
* parse an end of tag
*
* [42] ETag ::= '</' Name S? '>'
*
* With namespace
*
* [NS 9] ETag ::= '</' QName S? '>'
*/
static void
GROW;
"xmlParseEndTag: '</' not found\n");
return;
}
SKIP(2);
/*
* We should definitely be at the ending "S? '>'" part
*/
GROW;
} else
/*
* [ WFC: Element Type Match ]
* The Name in an element's end-tag must match the element type in the
* start-tag.
*
*/
"Opening and ending tag mismatch: %s line %d and %s\n",
}
/*
* SAX: End of Tag
*/
(!ctxt->disableSAX))
return;
}
/**
* xmlParseEndTag:
* @ctxt: an XML parser context
*
* parse an end of tag
*
* [42] ETag ::= '</' Name S? '>'
*
* With namespace
*
* [NS 9] ETag ::= '</' QName S? '>'
*/
void
xmlParseEndTag1(ctxt, 0);
}
#endif /* LIBXML_SAX1_ENABLED */
/************************************************************************
* *
* SAX 2 specific operations *
* *
************************************************************************/
static const xmlChar *
int len = 0, l;
int c;
int count = 0;
/*
* Handler for more complex cases
*/
GROW;
c = CUR_CHAR(l);
if ((c == ' ') || (c == '>') || (c == '/') || /* accelerators */
(!IS_LETTER(c) && (c != '_'))) {
return(NULL);
}
(c == '.') || (c == '-') || (c == '_') ||
(IS_COMBINING(c)) ||
(IS_EXTENDER(c)))) {
if (count++ > 100) {
count = 0;
GROW;
}
len += l;
NEXTL(l);
c = CUR_CHAR(l);
}
}
/*
* xmlGetNamespace:
* @ctxt: an XML parser context
* @prefix: the prefix to lookup
*
* Lookup the namespace name for the @prefix (which ca be NULL)
* The prefix must come from the @ctxt->dict dictionnary
*
* Returns the namespace name or NULL if not bound
*/
static const xmlChar *
int i;
return(NULL);
}
return(NULL);
}
/**
* xmlParseNCName:
* @ctxt: an XML parser context
* @len: lenght of the string parsed
*
* parse an XML name.
*
* [4NS] NCNameChar ::= Letter | Digit | '.' | '-' | '_' |
* CombiningChar | Extender
*
* [5NS] NCName ::= (Letter | '_') (NCNameChar)*
*
* Returns the Name parsed or NULL
*/
static const xmlChar *
int count = 0;
/*
* Accelerator for simple ASCII names
*/
(*in == '_')) {
in++;
(*in == '.'))
in++;
}
return(ret);
}
}
return(xmlParseNCNameComplex(ctxt));
}
/**
* xmlParseQName:
* @ctxt: an XML parser context
* @prefix: pointer to store the prefix part
*
* parse an XML Namespace QName
*
* [6] QName ::= (Prefix ':')? LocalPart
* [7] Prefix ::= NCName
* [8] LocalPart ::= NCName
*
* Returns the Name parsed or NULL
*/
static const xmlChar *
const xmlChar *l, *p;
GROW;
l = xmlParseNCName(ctxt);
if (l == NULL) {
if (CUR == ':') {
l = xmlParseName(ctxt);
if (l != NULL) {
return(l);
}
}
return(NULL);
}
if (CUR == ':') {
NEXT;
p = l;
l = xmlParseNCName(ctxt);
if (l == NULL) {
return(p);
}
if (CUR == ':') {
"Failed to parse QName '%s:%s:'\n", p, l, NULL);
NEXT;
*prefix = p;
return(l);
}
*prefix = p;
return(l);
}
*prefix = p;
} else
return(l);
}
/**
* xmlParseQNameAndCompare:
* @ctxt: an XML parser context
* @name: the localname
* @prefix: the prefix, if any.
*
* parse an XML name and compares for match
* (specialized for endtag parsing)
*
* Returns NULL for an illegal name, (xmlChar*) 1 for success
* and the name for mismatch
*/
static const xmlChar *
GROW;
++in;
++cmp;
}
in++;
++in;
++cmp;
}
/* success */
return((const xmlChar*) 1);
}
}
/*
* all strings coms from the dictionary, equality can be done directly
*/
return((const xmlChar*) 1);
return ret;
}
/**
* xmlParseAttValueInternal:
* @ctxt: an XML parser context
* @len: attribute len result
* @alloc: whether the attribute was reallocated as a new string
* @normalize: if 1 then further non-CDATA normalization must be done
*
* parse a value for an attribute.
* NOTE: if no normalization is needed, the routine will return pointers
* directly from the data buffer.
*
* 3.3.3 Attribute-Value Normalization:
* Before the value of an attribute is passed to the application or
* checked for validity, the XML processor must normalize it as follows:
* - a character reference is processed by appending the referenced
* character to the attribute value
* - an entity reference is processed by recursively processing the
* replacement text of the entity
* - a whitespace character (#x20, #xD, #xA, #x9) is processed by
* appending #x20 to the normalized value, except that only a single
* #x20 is appended for a "#xD#xA" sequence that is part of an external
* parsed entity or the literal entity value of an internal parsed entity
* - other characters are processed by appending them to the normalized value
* If the declared value is not CDATA, then the XML processor must further
* process the normalized attribute value by discarding any leading and
* trailing space (#x20) characters, and by replacing sequences of space
* (#x20) characters by a single space (#x20) character.
* All attributes for which no declaration has been read should be treated
* by a non-validating parser as if declared CDATA.
*
* Returns the AttValue parsed or NULL. The value has to be freed by the
* caller if it was copied, this can be detected by val[*len] == 0.
*/
static xmlChar *
int normalize)
{
GROW;
return (NULL);
}
/*
* try to handle in this routine the most common case where no
* allocation of a new string is required and where content is
* pure ASCII.
*/
GROW;
}
}
if (normalize) {
/*
* Skip any leading spaces
*/
in++;
GROW;
}
}
}
GROW;
}
}
}
/*
* skip the trailing blanks
*/
in++;
GROW;
}
}
}
} else {
in++;
GROW;
}
}
}
}
in++;
} else {
}
return ret;
}
/**
* xmlParseAttribute2:
* @ctxt: an XML parser context
* @pref: the element prefix
* @elem: the element name
* @prefix: a xmlChar ** used to store the value of the attribute prefix
* @value: a xmlChar ** used to store the value of the attribute
* @len: an int * to save the length of the attribute
* @alloc: an int * to indicate if the attribute was allocated
*
* parse an attribute in the new SAX2 framework.
*
* Returns the attribute name, and the value in *value, .
*/
static const xmlChar *
int normalize = 0;
GROW;
"error parsing attribute name\n");
return(NULL);
}
/*
* get the type if needed
*/
int type;
}
/*
* read the value
*/
if (RAW == '=') {
NEXT;
} else {
"Specification mandate value for attribute %s\n", name);
return(NULL);
}
/*
* Check that xml:lang conforms to the specification
* No more registered as an error, just generate a warning now
* since this was deprecated in XML second edition
*/
if (!xmlCheckLanguageID(internal_val)) {
"Malformed value for xml:lang : %s\n",
internal_val, NULL);
}
}
/*
* Check that xml:space conforms to the specification
*/
else {
"Invalid value \"%s\" for xml:space : \"default\" or \"preserve\" expected\n",
internal_val, NULL);
}
}
if (internal_val) {
}
}
return(name);
}
/**
* xmlParseStartTag2:
* @ctxt: an XML parser context
*
* parse a start of tag either for rule element or
* EmptyElement. In both case we don't parse the tag closing chars.
* This routine is called when running SAX2 parsing
*
* [40] STag ::= '<' Name (S Attribute)* S? '>'
*
* [ WFC: Unique Att Spec ]
* No attribute name may appear more than once in the same start-tag or
* empty-element tag.
*
* [44] EmptyElemTag ::= '<' Name (S Attribute)* S? '/>'
*
* [ WFC: Unique Att Spec ]
* No attribute name may appear more than once in the same start-tag or
* empty-element tag.
*
* With namespace:
*
* [NS 8] STag ::= '<' QName (S Attribute)* S? '>'
*
* [NS 10] EmptyElement ::= '<' QName (S Attribute)* S? '/>'
*
* Returns the element name parsed
*/
static const xmlChar *
unsigned long cur;
/*
* NOTE: it is crucial with the SAX2 API to never call SHRINK beyond that
* point since the attribute values may be stored as pointers to
* the buffer and calling SHRINK would destroy them !
* The Shrinking is only possible once the full set of attribute
* callbacks have been done.
*/
nbatts = 0;
nratts = 0;
nbdef = 0;
nbNs = 0;
attval = 0;
/* Forget any namespaces added during an earlier parse of this element. */
"StartTag: invalid element name\n");
return(NULL);
}
/*
* Now parse the attributes, it ends up with the ending
*
* (S Attribute)* S?
*/
GROW;
while ((RAW != '>') &&
(IS_BYTE_CHAR(RAW))) {
goto base_changed;
}
if (*URL != 0) {
"xmlns: %s not a valid URI\n",
} else {
"xmlns: URI %s is not absolute\n",
}
}
}
/*
* check that it's not a defined namespace
*/
for (j = 1;j <= nbNs;j++)
break;
if (j <= nbNs)
else
continue;
}
"xml namespace prefix mapped to wrong URI\n",
}
/*
* Do not keep a namespace definition node
*/
continue;
}
"xmlns:%s: '%s' is not a valid URI\n",
} else {
"xmlns:%s: URI %s is not absolute\n",
}
}
/*
* check that it's not a defined namespace
*/
for (j = 1;j <= nbNs;j++)
break;
if (j <= nbNs)
else
continue;
}
/*
* Add the pair to atts
*/
goto failed;
}
}
/*
* tag if some deallocation is needed
*/
} else {
}
break;
if (!IS_BLANK_CH(RAW)) {
"attributes construct error\n");
break;
}
"xmlParseStartTag: problem parsing attributes\n");
break;
}
GROW;
}
/*
* The attributes defaulting
*/
/*
* special work for namespaces defaulted defs
*/
/*
* check that it's not a defined namespace
*/
for (j = 1;j <= nbNs;j++)
break;
if (j <= nbNs) continue;
nbNs++;
}
/*
* check that it's not a defined namespace
*/
for (j = 1;j <= nbNs;j++)
break;
if (j <= nbNs) continue;
nbNs++;
}
} else {
/*
* check that it's not a defined attribute
*/
for (j = 0;j < nbatts;j+=5) {
break;
}
if (j < nbatts) continue;
return(NULL);
}
}
else
nbdef++;
}
}
}
}
/*
* The attributes checkings
*/
for (i = 0; i < nbatts;i += 5) {
/*
* The default namespace does not apply to attribute names.
*/
"Namespace prefix %s for %s on %s is not defined\n",
}
} else
/*
* [ WFC: Unique Att Spec ]
* No attribute name may appear more than once in the same
* start-tag or empty-element tag.
* As extended by the Namespace in XML REC.
*/
for (j = 0; j < i;j += 5) {
break;
}
"Namespaced Attribute %s in '%s' redefined\n",
break;
}
}
}
}
"Namespace prefix %s on %s is not defined\n",
}
/*
* SAX: Start of Element !
*/
(!ctxt->disableSAX)) {
if (nbNs > 0)
else
}
/*
* Free up attribute allocated strings if needed
*/
if (attval != 0) {
}
return(localname);
/*
* the attribute strings are valid iif the base didn't changed
*/
if (attval != 0) {
}
goto reparse;
}
return(NULL);
}
/**
* xmlParseEndTag2:
* @ctxt: an XML parser context
* @line: line of the start tag
* @nsNr: number of namespaces on the start tag
*
* parse an end of tag
*
* [42] ETag ::= '</' Name S? '>'
*
* With namespace
*
* [NS 9] ETag ::= '</' QName S? '>'
*/
static void
GROW;
return;
}
SKIP(2);
goto done;
}
} else {
else
}
/*
* We should definitely be at the ending "S? '>'" part
*/
GROW;
} else
/*
* [ WFC: Element Type Match ]
* The Name in an element's end-tag must match the element type in the
* start-tag.
*
*/
"Opening and ending tag mismatch: %s line %d and %s\n",
}
/*
* SAX: End of Tag
*/
done:
(!ctxt->disableSAX))
if (nsNr != 0)
return;
}
/**
* xmlParseCDSect:
* @ctxt: an XML parser context
*
* Parse escaped pure raw content.
*
* [18] CDSect ::= CDStart CData CDEnd
*
* [19] CDStart ::= '<![CDATA['
*
* [20] Data ::= (Char* - (Char* ']]>' Char*))
*
* [21] CDEnd ::= ']]>'
*/
void
int len = 0;
int r, rl;
int s, sl;
int cur, l;
int count = 0;
/* Check 2.6.0 was NXT(0) not RAW */
SKIP(9);
} else
return;
if (!IS_CHAR(r)) {
return;
}
if (!IS_CHAR(s)) {
return;
}
return;
}
size *= 2;
return;
}
}
r = s;
s = cur;
sl = l;
count++;
if (count > 50) {
GROW;
count = 0;
}
NEXTL(l);
}
if (cur != '>') {
"CData section not finished\n%.50s\n", buf);
return;
}
NEXTL(l);
/*
* OK the buffer is to be consumed as cdata.
*/
}
}
/**
* xmlParseContent:
* @ctxt: an XML parser context
*
* Parse a content:
*
* [43] content ::= (element | CharData | Reference | CDSect | PI | Comment)*
*/
void
GROW;
while ((RAW != 0) &&
/*
* First case : a Processing Instruction.
*/
}
/*
* Second case : a CDSection
*/
/* 2.6.0 test was *cur not RAW */
}
/*
* Third case : a comment
*/
}
/*
* Fourth case : a sub-element.
*/
else if (*cur == '<') {
}
/*
* Fifth case : a reference. If if has not been resolved,
* parsing returns it's Name, create the node
*/
else if (*cur == '&') {
}
/*
* Last case, text. Note that References are handled directly.
*/
else {
xmlParseCharData(ctxt, 0);
}
GROW;
/*
* Pop-up of finished entities.
*/
"detected an error in element content\n");
break;
}
}
}
/**
* xmlParseElement:
* @ctxt: an XML parser context
*
* parse an XML element, this is highly recursive
*
* [39] element ::= EmptyElemTag | STag content ETag
*
* [ WFC: Element Type Match ]
* The Name in an element's end-tag must match the element type in the
* start-tag.
*
*/
void
"Excessive depth in document: change xmlParserMaxDepth = %d\n",
return;
}
/* Capture start position */
if (ctxt->record_info) {
}
else
#ifdef LIBXML_SAX1_ENABLED
#endif /* LIBXML_SAX1_ENABLED */
#ifdef LIBXML_SAX1_ENABLED
else
#endif /* LIBXML_SAX1_ENABLED */
return;
return;
}
#ifdef LIBXML_VALID_ENABLED
/*
* [ VC: Root Element Type ]
* The Name in the document type declaration must match the element
* type of the root element.
*/
#endif /* LIBXML_VALID_ENABLED */
/*
* Check for an Empty Element.
*/
SKIP(2);
(!ctxt->disableSAX))
#ifdef LIBXML_SAX1_ENABLED
} else {
(!ctxt->disableSAX))
#endif /* LIBXML_SAX1_ENABLED */
}
}
return;
}
if (RAW == '>') {
} else {
"Couldn't find end of Start Tag %s line %d\n",
/*
* end of parsing of this node.
*/
/*
* Capture end position and add node
*/
}
return;
}
/*
* Parse the content of the element:
*/
if (!IS_BYTE_CHAR(RAW)) {
"Premature end of data in tag %s line %d\n",
/*
* end of parsing of this node.
*/
return;
}
/*
* parse the end of tag: '</' should be here.
*/
}
#ifdef LIBXML_SAX1_ENABLED
else
#endif /* LIBXML_SAX1_ENABLED */
/*
* Capture end position and add node
*/
}
}
/**
* xmlParseVersionNum:
* @ctxt: an XML parser context
*
* parse the XML version value.
*
* [26] VersionNum ::= ([a-zA-Z0-9_.:] | '-')+
*
* Returns the string giving the XML version number, or NULL
*/
xmlChar *
int len = 0;
return(NULL);
}
size *= 2;
return(NULL);
}
}
NEXT;
}
return(buf);
}
/**
* xmlParseVersionInfo:
* @ctxt: an XML parser context
*
* parse the XML version.
*
* [24] VersionInfo ::= S 'version' Eq (' VersionNum ' | " VersionNum ")
*
* [25] Eq ::= S? '=' S?
*
* Returns the version string, e.g. "1.0"
*/
xmlChar *
SKIP(7);
if (RAW != '=') {
return(NULL);
}
NEXT;
if (RAW == '"') {
NEXT;
if (RAW != '"') {
} else
NEXT;
} else if (RAW == '\''){
NEXT;
if (RAW != '\'') {
} else
NEXT;
} else {
}
}
return(version);
}
/**
* xmlParseEncName:
* @ctxt: an XML parser context
*
* parse the XML encoding name
*
* [81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')*
*
* Returns the encoding name value or NULL
*/
xmlChar *
int len = 0;
return(NULL);
}
NEXT;
(cur == '-')) {
size *= 2;
return(NULL);
}
}
NEXT;
if (cur == 0) {
GROW;
}
}
} else {
}
return(buf);
}
/**
* xmlParseEncodingDecl:
* @ctxt: an XML parser context
*
* parse the XML encoding declaration
*
* [80] EncodingDecl ::= S 'encoding' Eq ('"' EncName '"' | "'" EncName "'")
*
* this setups the conversion filters.
*
* Returns the encoding value or NULL
*/
const xmlChar *
SKIP(8);
if (RAW != '=') {
return(NULL);
}
NEXT;
if (RAW == '"') {
NEXT;
if (RAW != '"') {
} else
NEXT;
} else if (RAW == '\''){
NEXT;
if (RAW != '\'') {
} else
NEXT;
} else {
}
/*
* UTF-16 encoding stwich has already taken place at this stage,
* more over the little-endian/big-endian selection is already done
*/
}
/*
* UTF-8 encoding is handled natively
*/
}
} else {
"Unsupported encoding %s\n", encoding);
return(NULL);
}
}
}
return(encoding);
}
/**
* xmlParseSDDecl:
* @ctxt: an XML parser context
*
* parse the XML standalone declaration
*
* [32] SDDecl ::= S 'standalone' Eq
* (("'" ('yes' | 'no') "'") | ('"' ('yes' | 'no')'"'))
*
* [ VC: Standalone Document Declaration ]
* TODO The standalone document declaration must have the value "no"
* if any external markup declarations contain declarations of:
* - attributes with default values, if elements to which these
* attributes apply appear in the document without specifications
* of values for these attributes, or
* - entities (other than amp, lt, gt, apos, quot), if references
* to those entities appear in the document, or
* - attributes with values subject to normalization, where the
* attribute appears in the document with a value which will change
* as a result of normalization, or
* - element types with element content, if white space occurs directly
* within any instance of those types.
*
* Returns:
* 1 if standalone="yes"
* 0 if standalone="no"
* -2 if standalone attribute is missing or invalid
* (A standalone value of -2 means that the XML declaration was found,
* but no value was specified for the standalone attribute).
*/
int
SKIP(10);
if (RAW != '=') {
return(standalone);
}
NEXT;
if (RAW == '\''){
NEXT;
standalone = 0;
SKIP(2);
standalone = 1;
SKIP(3);
} else {
}
if (RAW != '\'') {
} else
NEXT;
} else if (RAW == '"'){
NEXT;
standalone = 0;
SKIP(2);
standalone = 1;
SKIP(3);
} else {
}
if (RAW != '"') {
} else
NEXT;
} else {
}
}
return(standalone);
}
/**
* xmlParseXMLDecl:
* @ctxt: an XML parser context
*
* parse an XML declaration header
*
* [23] XMLDecl ::= '<?xml' VersionInfo EncodingDecl? SDDecl? S? '?>'
*/
void
/*
* This value for standalone indicates that the document has an
* XML declaration but it does not have a standalone attribute.
* It will be overwritten later if a standalone attribute is found.
*/
/*
* We know that '<?xml' is here.
*/
SKIP(5);
if (!IS_BLANK_CH(RAW)) {
"Blank needed after '<?xml'\n");
}
/*
* We must have the VersionInfo here.
*/
} else {
/*
* TODO: Blueberry should be detected here
*/
"Unsupported version '%s'\n",
}
}
/*
* We may have the encoding declaration
*/
if (!IS_BLANK_CH(RAW)) {
SKIP(2);
return;
}
}
/*
* The XML REC instructs us to stop parsing right here
*/
return;
}
/*
* We may have the standalone status.
*/
SKIP(2);
return;
}
}
SKIP(2);
} else if (RAW == '>') {
/* Deprecated old WD ... */
NEXT;
} else {
NEXT;
}
}
/**
* xmlParseMisc:
* @ctxt: an XML parser context
*
* parse an XML Misc* optional field.
*
* [27] Misc ::= Comment | PI | S
*/
void
IS_BLANK_CH(CUR)) {
} else if (IS_BLANK_CH(CUR)) {
NEXT;
} else
}
}
/**
* xmlParseDocument:
* @ctxt: an XML parser context
*
* parse an XML document (and build a tree if using the standard SAX
* interface).
*
* [1] document ::= prolog element Misc*
*
* [22] prolog ::= XMLDecl? Misc* (doctypedecl Misc*)?
*
* Returns 0, -1 in case of error. the parser context is augmented
* as a result of the parsing.
*/
int
return(-1);
GROW;
/*
* SAX: detecting the level.
*/
/*
* SAX: beginning of the document processing.
*/
/*
* Get the 4 first bytes and decode the charset
* if enc != XML_CHAR_ENCODING_NONE
* plug some encoding conversion routines.
*/
if (enc != XML_CHAR_ENCODING_NONE) {
}
}
if (CUR == 0) {
}
/*
* Check for the XMLDecl in the Prolog.
*/
GROW;
/*
* Note that we will switch encoding on the fly.
*/
/*
* The XML REC instructs us to stop parsing right here
*/
return(-1);
}
} else {
}
/*
* The Misc part of the Prolog
*/
GROW;
/*
* Then possibly doc type declaration(s) and more Misc
* (doctypedecl Misc*)?
*/
GROW;
if (RAW == '[') {
}
/*
* Create and update the external subset.
*/
(!ctxt->disableSAX))
}
/*
* Time to start parsing the tree itself
*/
GROW;
if (RAW != '<') {
"Start tag expected, '<' not found\n");
} else {
/*
* The Misc part at the end
*/
if (RAW != 0) {
}
}
/*
* SAX: end of the document processing.
*/
/*
* Remove locally kept entity definitions if the tree was not built
*/
}
if (! ctxt->wellFormed) {
return(-1);
}
return(0);
}
/**
* xmlParseExtParsedEnt:
* @ctxt: an XML parser context
*
* parse a general parsed entity
* An external general parsed entity is well-formed if it matches the
* production labeled extParsedEnt.
*
* [78] extParsedEnt ::= TextDecl? content
*
* Returns 0, -1 in case of error. the parser context is augmented
* as a result of the parsing.
*/
int
return(-1);
GROW;
/*
* SAX: beginning of the document processing.
*/
/*
* Get the 4 first bytes and decode the charset
* if enc != XML_CHAR_ENCODING_NONE
* plug some encoding conversion routines.
*/
if (enc != XML_CHAR_ENCODING_NONE) {
}
}
if (CUR == 0) {
}
/*
* Check for the XMLDecl in the Prolog.
*/
GROW;
/*
* Note that we will switch encoding on the fly.
*/
/*
* The XML REC instructs us to stop parsing right here
*/
return(-1);
}
} else {
}
/*
* Doing validity checking on chunk doesn't make sense
*/
ctxt->loadsubset = 0;
} else if (RAW != 0) {
}
/*
* SAX: end of the document processing.
*/
return(0);
}
#ifdef LIBXML_PUSH_ENABLED
/************************************************************************
* *
* Progressive parsing interfaces *
* *
************************************************************************/
/**
* xmlParseLookupSequence:
* @ctxt: an XML parser context
* @first: the first char to lookup
* @next: the next char to lookup or zero
* @third: the next char to lookup or zero
*
* Try to find if a sequence (first, next, third) or just (first next) or
* (first) is available in the input stream.
* This function has a side effect of (possibly) incrementing ctxt->checkIndex
* to avoid rescanning sequences of bytes, it DOES change the state of the
* parser, do not use liberally.
*
* Returns the index to the current parsing point if the full sequence
* is available, -1 otherwise.
*/
static int
if (base < 0) return(-1);
} else {
}
/* take into account the sequence length */
if (third != 0) {
} else if (next != 0) {
}
ctxt->checkIndex = 0;
#ifdef DEBUG_PUSH
if (next == 0)
"PP: lookup '%c' found at %d\n",
else if (third == 0)
"PP: lookup '%c%c' found at %d\n",
else
"PP: lookup '%c%c%c' found at %d\n",
#endif
}
}
#ifdef DEBUG_PUSH
if (next == 0)
"PP: lookup '%c' failed\n", first);
else if (third == 0)
else
#endif
return(-1);
}
/**
* xmlParseGetLasts:
* @ctxt: an XML parser context
* @lastlt: pointer to store the last '<' from the input
* @lastgt: pointer to store the last '>' from the input
*
* Lookup the last < and > in the current chunk
*/
static void
"Internal error: xmlParseGetLasts\n");
return;
}
tmp--;
} else {
tmp++;
if (*tmp == '\'') {
tmp++;
} else if (*tmp == '"') {
tmp++;
} else
tmp++;
}
else {
tmp--;
else
}
}
} else {
}
}
/**
* xmlCheckCdataPush:
* @cur: pointer to the bock of characters
* @len: length of the block in bytes
*
* Check that the block of characters is okay as SCdata content [20]
*
* Returns the number of bytes to pass if okay, a negative index where an
* UTF-8 error occured otherwise
*/
static int
int ix;
unsigned char c;
int codepoint;
return(0);
if ((c & 0x80) == 0x00) { /* 1-byte code, starts with 10 */
if (c >= 0x20)
ix++;
else if ((c == 0xA) || (c == 0xD) || (c == 0x9))
ix++;
else
return(-ix);
} else if ((c & 0xe0) == 0xc0) {/* 2-byte code, starts with 110 */
return(-ix);
if (!xmlIsCharQ(codepoint))
return(-ix);
ix += 2;
} else if ((c & 0xf0) == 0xe0) {/* 3-byte code, starts with 1110 */
return(-ix);
if (!xmlIsCharQ(codepoint))
return(-ix);
ix += 3;
} else if ((c & 0xf8) == 0xf0) {/* 4-byte code, starts with 11110 */
return(-ix);
if (!xmlIsCharQ(codepoint))
return(-ix);
ix += 4;
} else /* unknown encoding */
return(-ix);
}
return(ix);
}
/**
* xmlParseTryOrFinish:
* @ctxt: an XML parser context
* @terminate: last chunk indicator
*
* Try to progress on parsing
*
* Returns zero if no parsing was possible
*/
static int
int ret = 0;
return(0);
#ifdef DEBUG_PUSH
case XML_PARSER_EOF:
"PP: try EOF\n"); break;
case XML_PARSER_START:
"PP: try START\n"); break;
case XML_PARSER_MISC:
"PP: try MISC\n");break;
case XML_PARSER_COMMENT:
"PP: try COMMENT\n");break;
case XML_PARSER_PROLOG:
"PP: try PROLOG\n");break;
case XML_PARSER_START_TAG:
"PP: try START_TAG\n");break;
case XML_PARSER_CONTENT:
"PP: try CONTENT\n");break;
case XML_PARSER_CDATA_SECTION:
"PP: try CDATA_SECTION\n");break;
case XML_PARSER_END_TAG:
"PP: try END_TAG\n");break;
case XML_PARSER_ENTITY_DECL:
"PP: try ENTITY_DECL\n");break;
case XML_PARSER_ENTITY_VALUE:
"PP: try ENTITY_VALUE\n");break;
"PP: try ATTRIBUTE_VALUE\n");break;
case XML_PARSER_DTD:
"PP: try DTD\n");break;
case XML_PARSER_EPILOG:
"PP: try EPILOG\n");break;
case XML_PARSER_PI:
"PP: try PI\n");break;
case XML_PARSER_IGNORE:
"PP: try IGNORE\n");break;
}
#endif
ctxt->checkIndex = 0;
}
while (1) {
return(0);
/*
* Pop-up of finished entities.
*/
else {
/*
* If we are operating on converted input, try to flush
* remainng chars to avoid them stalling in the non-converted
* buffer.
*/
}
}
if (avail < 1)
goto done;
case XML_PARSER_EOF:
/*
* Document parsing is done !
*/
goto done;
case XML_PARSER_START:
/*
* Very first chars read from the document flow.
*/
if (avail < 4)
goto done;
/*
* Get the 4 first bytes and decode the charset
* if enc != XML_CHAR_ENCODING_NONE
* plug some encoding conversion routines,
* else xmlSwitchEncoding will set to (default)
* UTF8.
*/
break;
}
if (avail < 2)
goto done;
if (cur == 0) {
#ifdef DEBUG_PUSH
"PP: entering EOF\n");
#endif
goto done;
}
/* PI or XML decl */
if ((!terminate) &&
return(ret);
ret += 5;
#ifdef DEBUG_PUSH
"PP: Parsing XML Decl\n");
#endif
/*
* The XML REC instructs us to stop parsing right
* here
*/
return(0);
}
(!ctxt->disableSAX))
#ifdef DEBUG_PUSH
"PP: entering MISC\n");
#endif
} else {
(!ctxt->disableSAX))
#ifdef DEBUG_PUSH
"PP: entering MISC\n");
#endif
}
} else {
break;
}
(!ctxt->disableSAX))
#ifdef DEBUG_PUSH
"PP: entering MISC\n");
#endif
}
break;
case XML_PARSER_START_TAG: {
goto done;
if (cur != '<') {
goto done;
}
if (!terminate) {
if (ctxt->progressive) {
/* > can be found unescaped in attribute values */
goto done;
goto done;
}
}
else
#ifdef LIBXML_SAX1_ENABLED
#endif /* LIBXML_SAX1_ENABLED */
#ifdef LIBXML_SAX1_ENABLED
else
#endif /* LIBXML_SAX1_ENABLED */
goto done;
goto done;
}
#ifdef LIBXML_VALID_ENABLED
/*
* [ VC: Root Element Type ]
* The Name in the document type declaration must match
* the element type of the root element.
*/
#endif /* LIBXML_VALID_ENABLED */
/*
* Check for an Empty Element.
*/
SKIP(2);
(!ctxt->disableSAX))
#ifdef LIBXML_SAX1_ENABLED
} else {
(!ctxt->disableSAX))
#endif /* LIBXML_SAX1_ENABLED */
}
} else {
}
break;
}
if (RAW == '>') {
NEXT;
} else {
"Couldn't find end of Start Tag %s\n",
name);
}
#ifdef LIBXML_SAX1_ENABLED
else
#endif /* LIBXML_SAX1_ENABLED */
break;
}
case XML_PARSER_CONTENT: {
unsigned int cons;
goto done;
break;
if ((!terminate) &&
goto done;
break;
int term;
if (avail < 4)
goto done;
goto done;
SKIP(9);
break;
(avail < 9)) {
goto done;
} else if (cur == '&') {
if ((!terminate) &&
goto done;
} else {
/* TODO Avoid the extra copy, handle directly !!! */
/*
* Goal of the following test is:
* - minimize calls to the SAX 'character' callback
* when they are mergeable
* - handle an problem for isBlank when we only parse
* a sequence of blank chars and the next one is
* not available to check against '<' presence.
* - tries to homogenize the differences in SAX
* callbacks between the push and pull versions
* of the parser.
*/
(avail < XML_PARSER_BIG_BUFFER_SIZE)) {
if (!terminate) {
if (ctxt->progressive) {
goto done;
} else if (xmlParseLookupSequence(ctxt,
'<', 0, 0) < 0) {
goto done;
}
}
}
ctxt->checkIndex = 0;
xmlParseCharData(ctxt, 0);
}
/*
* Pop-up of finished entities.
*/
"detected an error in element content\n");
break;
}
break;
}
case XML_PARSER_END_TAG:
if (avail < 2)
goto done;
if (!terminate) {
if (ctxt->progressive) {
/* > can be found unescaped in attribute values */
goto done;
goto done;
}
}
}
#ifdef LIBXML_SAX1_ENABLED
else
xmlParseEndTag1(ctxt, 0);
#endif /* LIBXML_SAX1_ENABLED */
/* Nothing */
} else {
}
break;
case XML_PARSER_CDATA_SECTION: {
/*
* The Push mode need to have the SAX callback for
* cdataBlock merge back contiguous callbacks.
*/
int base;
if (base < 0) {
int tmp;
if (tmp < 0) {
goto encoding_error;
}
}
ctxt->checkIndex = 0;
}
goto done;
} else {
int tmp;
goto encoding_error;
}
(!ctxt->disableSAX)) {
}
ctxt->checkIndex = 0;
#ifdef DEBUG_PUSH
"PP: entering CONTENT\n");
#endif
}
break;
}
case XML_PARSER_MISC:
else
if (avail < 2)
goto done;
if ((!terminate) &&
goto done;
#ifdef DEBUG_PUSH
"PP: Parsing PI\n");
#endif
ctxt->checkIndex = 0;
if ((!terminate) &&
goto done;
#ifdef DEBUG_PUSH
"PP: Parsing Comment\n");
#endif
ctxt->checkIndex = 0;
if ((!terminate) &&
goto done;
#ifdef DEBUG_PUSH
"PP: Parsing internal subset\n");
#endif
if (RAW == '[') {
#ifdef DEBUG_PUSH
"PP: entering DTD\n");
#endif
} else {
/*
* Create and update the external subset.
*/
#ifdef DEBUG_PUSH
"PP: entering PROLOG\n");
#endif
}
(avail < 9)) {
goto done;
} else {
#ifdef DEBUG_PUSH
"PP: entering START_TAG\n");
#endif
}
break;
case XML_PARSER_PROLOG:
else
if (avail < 2)
goto done;
if ((!terminate) &&
goto done;
#ifdef DEBUG_PUSH
"PP: Parsing PI\n");
#endif
if ((!terminate) &&
goto done;
#ifdef DEBUG_PUSH
"PP: Parsing Comment\n");
#endif
(avail < 4)) {
goto done;
} else {
if (ctxt->progressive == 0)
#ifdef DEBUG_PUSH
"PP: entering START_TAG\n");
#endif
}
break;
case XML_PARSER_EPILOG:
else
if (avail < 2)
goto done;
if ((!terminate) &&
goto done;
#ifdef DEBUG_PUSH
"PP: Parsing PI\n");
#endif
if ((!terminate) &&
goto done;
#ifdef DEBUG_PUSH
"PP: Parsing Comment\n");
#endif
(avail < 4)) {
goto done;
} else {
#ifdef DEBUG_PUSH
"PP: entering EOF\n");
#endif
goto done;
}
break;
case XML_PARSER_DTD: {
/*
* Sorry but progressive parsing of the internal subset
* is not expected to be supported. We first check that
* the full content of the internal subset is available and
* the parsing is launched only at that point.
* Internal subset ends up with "']' S? '>'" in an unescaped
* section and not in a ']]>' sequence which are conditional
* sections (whoever argued to keep that crap in XML deserve
* a place in hell !).
*/
int base, i;
if (base < 0) return(0);
base++) {
if (quote != 0) {
quote = 0;
continue;
}
int found = 0;
/* special handling of comments */
if (((unsigned int) base + 4 <
for (;(unsigned int) base + 3 <
found = 1;
base += 2;
break;
}
}
if (!found) {
#if 0
#endif
break; /* for */
}
continue;
}
}
quote = '"';
continue;
}
quote = '\'';
continue;
}
#if 0
#endif
if ((unsigned int) base +1 >=
break;
/* conditional crap, skip both ']' ! */
base++;
continue;
}
for (i = 1;
i++) {
#if 0
#endif
goto found_end_int_subset;
}
#if 0
#endif
goto not_end_of_int_subset;
}
}
#if 0
#endif
break;
}
continue; /* for */
}
/*
* We didn't found the end of the Internal subset
*/
#ifdef DEBUG_PUSH
if (next == 0)
"PP: lookup of int subset end filed\n");
#endif
goto done;
ctxt->checkIndex = 0;
#ifdef DEBUG_PUSH
"PP: entering PROLOG\n");
#endif
break;
}
case XML_PARSER_COMMENT:
"PP: internal error, state == COMMENT\n");
#ifdef DEBUG_PUSH
"PP: entering CONTENT\n");
#endif
break;
case XML_PARSER_IGNORE:
"PP: internal error, state == IGNORE");
#ifdef DEBUG_PUSH
"PP: entering DTD\n");
#endif
break;
case XML_PARSER_PI:
"PP: internal error, state == PI\n");
#ifdef DEBUG_PUSH
"PP: entering CONTENT\n");
#endif
break;
case XML_PARSER_ENTITY_DECL:
"PP: internal error, state == ENTITY_DECL\n");
#ifdef DEBUG_PUSH
"PP: entering DTD\n");
#endif
break;
case XML_PARSER_ENTITY_VALUE:
"PP: internal error, state == ENTITY_VALUE\n");
#ifdef DEBUG_PUSH
"PP: entering DTD\n");
#endif
break;
"PP: internal error, state == ATTRIBUTE_VALUE\n");
#ifdef DEBUG_PUSH
"PP: entering START_TAG\n");
#endif
break;
"PP: internal error, state == SYSTEM_LITERAL\n");
#ifdef DEBUG_PUSH
"PP: entering START_TAG\n");
#endif
break;
"PP: internal error, state == PUBLIC_LITERAL\n");
#ifdef DEBUG_PUSH
"PP: entering START_TAG\n");
#endif
break;
}
}
done:
#ifdef DEBUG_PUSH
#endif
return(ret);
{
"Input is not proper UTF-8, indicate encoding !\n%s",
}
return(0);
}
/**
* xmlParseChunk:
* @ctxt: an XML parser context
* @chunk: an char array
* @size: the size in byte of the chunk
* @terminate: last chunk indicator
*
* Parse a Chunk of memory
*
* Returns zero if no error, the xmlParserErrors otherwise.
*/
int
int terminate) {
int end_in_lf = 0;
return(XML_ERR_INTERNAL_ERROR);
end_in_lf = 1;
size--;
}
int res;
if (res < 0) {
return (XML_PARSER_EOF);
}
#ifdef DEBUG_PUSH
#endif
int nbchars;
if (nbchars < 0) {
/* TODO 2.6.0 */
"xmlParseChunk: encoder error\n");
return(XML_ERR_INVALID_ENCODING);
}
}
}
}
}
if (terminate) {
/*
* Check for termination
*/
int avail = 0;
else
}
}
}
}
}
}
/************************************************************************
* *
* I/O front end functions to the parser *
* *
************************************************************************/
/**
* xmlCreatePushParserCtxt:
* @sax: a SAX handler
* @user_data: The user data returned on SAX callbacks
* @chunk: a pointer to an array of chars
* @size: number of chars in the array
* @filename: an optional file name or URI
*
* Create a parser context for using the XML parser in push mode.
* If @buffer and @size are non-NULL, the data is used to detect
* the encoding. The remaining characters will be parsed so they
* don't need to be fed in again through xmlParseChunk.
* To allow content encoding detection, @size should be >= 4
* The value of @filename is used for fetching external entities
*
* Returns the new parser context or NULL
*/
/*
* plug some encoding conversion routines
*/
ctxt = xmlNewParserCtxt();
return(NULL);
}
return(NULL);
}
#ifdef LIBXML_SAX1_ENABLED
#endif /* LIBXML_SAX1_ENABLED */
return(NULL);
}
else
}
} else {
}
if (inputStream == NULL) {
return(NULL);
}
else {
inputStream->filename = (char *)
return(NULL);
}
}
inputStream->end =
/*
* If the caller didn't provide an initial 'chunk' for determining
* the encoding, we set the context to XML_CHAR_ENCODING_NONE so
* that it can be automatically determined later
*/
#ifdef DEBUG_PUSH
#endif
}
if (enc != XML_CHAR_ENCODING_NONE) {
}
return(ctxt);
}
#endif /* LIBXML_PUSH_ENABLED */
/**
* xmlStopParser:
* @ctxt: an XML parser context
*
* Blocks further parser processing
*/
void
return;
}
}
/**
* xmlCreateIOParserCtxt:
* @sax: a SAX handler
* @user_data: The user data returned on SAX callbacks
* @ioread: an I/O read function
* @ioclose: an I/O close function
* @ioctx: an I/O handler
* @enc: the charset encoding if known
*
* Create a parser context for using the XML parser with an existing
* I/O stream
*
* Returns the new parser context or NULL
*/
ctxt = xmlNewParserCtxt();
return(NULL);
}
#ifdef LIBXML_SAX1_ENABLED
#endif /* LIBXML_SAX1_ENABLED */
return(NULL);
}
else
}
if (inputStream == NULL) {
return(NULL);
}
return(ctxt);
}
#ifdef LIBXML_VALID_ENABLED
/************************************************************************
* *
* Front ends when parsing a DTD *
* *
************************************************************************/
/**
* xmlIOParseDTD:
* @sax: the SAX handler block or NULL
* @input: an Input Buffer
* @enc: the charset encoding if known
*
* Load and parse a DTD
*
* Returns the resulting xmlDtdPtr or NULL in case of error.
* @input will be freed by the function in any case.
*/
return(NULL);
ctxt = xmlNewParserCtxt();
return(NULL);
}
/*
* Set-up the SAX context
*/
}
/*
* generate a parser input from the I/O handler
*/
return(NULL);
}
/*
* plug some encoding conversion routines here.
*/
if (enc != XML_CHAR_ENCODING_NONE) {
}
/*
* let's parse that entity knowing it's an external subset.
*/
if ((enc == XML_CHAR_ENCODING_NONE) &&
/*
* Get the 4 first bytes and decode the charset
* if enc != XML_CHAR_ENCODING_NONE
* plug some encoding conversion routines.
*/
if (enc != XML_CHAR_ENCODING_NONE) {
}
}
if (ctxt->wellFormed) {
}
}
} else {
}
}
return(ret);
}
/**
* xmlSAXParseDTD:
* @sax: the SAX handler block
* @ExternalID: a NAME* containing the External ID of the DTD
* @SystemID: a NAME* containing the URL to the DTD
*
* Load and parse an external subset.
*
* Returns the resulting xmlDtdPtr or NULL in case of error.
*/
ctxt = xmlNewParserCtxt();
return(NULL);
}
/*
* Set-up the SAX context
*/
}
/*
* Canonicalise the system ID
*/
return(NULL);
}
/*
* Ask the Entity resolver to load the damn thing
*/
if (systemIdCanonic != NULL)
return(NULL);
}
/*
* plug some encoding conversion routines here.
*/
}
else
/*
* let's parse that entity knowing it's an external subset.
*/
if (ctxt->wellFormed) {
}
}
} else {
}
}
return(ret);
}
/**
* xmlParseDTD:
* @ExternalID: a NAME* containing the External ID of the DTD
* @SystemID: a NAME* containing the URL to the DTD
*
* Load and parse an external subset.
*
* Returns the resulting xmlDtdPtr or NULL in case of error.
*/
}
#endif /* LIBXML_VALID_ENABLED */
/************************************************************************
* *
* Front ends when parsing an Entity *
* *
************************************************************************/
/**
* xmlParseCtxtExternalEntity:
* @ctx: the existing parsing context
* @URL: the URL for the entity to load
* @ID: the System ID for the entity to load
* @lst: the return value for the set of parsed nodes
*
* Parse an external general entity within an existing parsing context
* An external general parsed entity is well-formed if it matches the
* production labeled extParsedEnt.
*
* [78] extParsedEnt ::= TextDecl? content
*
* Returns 0 if the entity is well formed, -1 in case of args problem and
* the parser error code otherwise
*/
int
int ret = 0;
return(XML_ERR_ENTITY_LOOP);
}
return(-1);
return(-1);
ctxt = xmlNewParserCtxt();
return(-1);
}
if (inputStream == NULL) {
return(-1);
}
return(-1);
}
}
}
}
return(-1);
}
} else {
}
/*
* Get the 4 first bytes and decode the charset
* if enc != XML_CHAR_ENCODING_NONE
* plug some encoding conversion routines.
*/
if (enc != XML_CHAR_ENCODING_NONE) {
}
}
/*
* Parse a possible text declaration first
*/
}
/*
* Doing validity checking on chunk doesn't make sense
*/
} else {
}
} else if (RAW != 0) {
}
}
if (!ctxt->wellFormed) {
ret = 1;
else
} else {
/*
* Return the newly created nodeset after unlinking it from
* they pseudo parent.
*/
}
}
ret = 0;
}
return(ret);
}
/**
* xmlParseExternalEntityPrivate:
* @doc: the document the chunk pertains to
* @oldctxt: the previous parser context if available
* @sax: the SAX handler bloc (possibly NULL)
* @user_data: The user data returned on SAX callbacks (possibly NULL)
* @depth: Used for loop detection, use 0
* @URL: the URL for the entity to load
* @ID: the System ID for the entity to load
* @list: the return value for the set of parsed nodes
*
* Private version of xmlParseExternalEntity()
*
* Returns 0 if the entity is well formed, -1 in case of args problem and
* the parser error code otherwise
*/
static xmlParserErrors
if (depth > 40) {
return(XML_ERR_ENTITY_LOOP);
}
return(XML_ERR_INTERNAL_ERROR);
return(XML_ERR_INTERNAL_ERROR);
} else {
/*
* Doing validity checking on chunk without context
* doesn't make sense
*/
ctxt->loadsubset = 0;
}
}
return(XML_ERR_INTERNAL_ERROR);
}
}
return(XML_ERR_INTERNAL_ERROR);
}
/*
* Get the 4 first bytes and decode the charset
* if enc != XML_CHAR_ENCODING_NONE
* plug some encoding conversion routines.
*/
GROW;
if (enc != XML_CHAR_ENCODING_NONE) {
}
}
/*
* Parse a possible text declaration first
*/
}
} else if (RAW != 0) {
}
}
if (!ctxt->wellFormed) {
else
} else {
/*
* Return the newly created nodeset after unlinking it from
* they pseudo parent.
*/
}
}
ret = XML_ERR_OK;
}
/*
* Record in the parent context the number of entities replacement
* done when parsing that reference.
*/
/*
* Also record the size of the entity parsed
*/
}
/*
* And record the last error if any
*/
return(ret);
}
#ifdef LIBXML_SAX1_ENABLED
/**
* xmlParseExternalEntity:
* @doc: the document the chunk pertains to
* @sax: the SAX handler bloc (possibly NULL)
* @user_data: The user data returned on SAX callbacks (possibly NULL)
* @depth: Used for loop detection, use 0
* @URL: the URL for the entity to load
* @ID: the System ID for the entity to load
* @lst: the return value for the set of parsed nodes
*
* Parse an external general entity
* An external general parsed entity is well-formed if it matches the
* production labeled extParsedEnt.
*
* [78] extParsedEnt ::= TextDecl? content
*
* Returns 0 if the entity is well formed, -1 in case of args problem and
* the parser error code otherwise
*/
int
}
/**
* xmlParseBalancedChunkMemory:
* @doc: the document the chunk pertains to
* @sax: the SAX handler bloc (possibly NULL)
* @user_data: The user data returned on SAX callbacks (possibly NULL)
* @depth: Used for loop detection, use 0
* @string: the input string in UTF8 or ISO-Latin (zero terminated)
* @lst: the return value for the set of parsed nodes
*
* Parse a well-balanced chunk of an XML document
* called by the parser
* The allowed sequence for the Well Balanced Chunk is the one defined by
* the content production in the XML grammar:
*
* [43] content ::= (element | CharData | Reference | CDSect | PI | Comment)*
*
* Returns 0 if the chunk is well balanced, -1 in case of args problem and
* the parser error code otherwise
*/
int
}
#endif /* LIBXML_SAX1_ENABLED */
/**
* xmlParseBalancedChunkMemoryInternal:
* @oldctxt: the existing parsing context
* @string: the input string in UTF8 or ISO-Latin (zero terminated)
* @user_data: the user data field for the parser context
* @lst: the return value for the set of parsed nodes
*
*
* Parse a well-balanced chunk of an XML document
* called by the parser
* The allowed sequence for the Well Balanced Chunk is the one defined by
* the content production in the XML grammar:
*
* [43] content ::= (element | CharData | Reference | CDSect | PI | Comment)*
*
* Returns XML_ERR_OK if the chunk is well balanced, and the parser
* error code otherwise
*
* In case recover is set to 1, the nodelist will not be empty even if
* the parsed chunk is not well balanced.
*/
static xmlParserErrors
int size;
return(XML_ERR_ENTITY_LOOP);
}
return(XML_ERR_INTERNAL_ERROR);
else
return(XML_ERR_INTERNAL_ERROR);
}
} else {
}
}
return(XML_ERR_INTERNAL_ERROR);
}
/*
*/
}
} else if (RAW != 0) {
}
}
if (!ctxt->wellFormed) {
else
} else {
ret = XML_ERR_OK;
}
/*
* Return the newly created nodeset after unlinking it from
* they pseudo parent.
*/
#ifdef LIBXML_VALID_ENABLED
}
#endif /* LIBXML_VALID_ENABLED */
}
}
}
/*
* Record in the parent context the number of entities replacement
* done when parsing that reference.
*/
/*
* Also record the last error if any
*/
}
return(ret);
}
/**
* xmlParseInNodeContext:
* @node: the context node
* @data: the input string
* @datalen: the input string length in bytes
* @options: a combination of xmlParserOption
* @lst: the return value for the set of parsed nodes
*
* Parse a well-balanced chunk of an XML document
* within the context (DTD, namespaces, etc ...) of the given node.
*
* The allowed sequence for the data is a Well Balanced Chunk defined by
* the content production in the XML grammar:
*
* [43] content ::= (element | CharData | Reference | CDSect | PI | Comment)*
*
* Returns XML_ERR_OK if the chunk is well balanced, and the parser
* error code otherwise
*/
#ifdef SAX2
int nsnr = 0;
/*
* check all input parameters, grab the document
*/
return(XML_ERR_INTERNAL_ERROR);
case XML_ELEMENT_NODE:
case XML_ATTRIBUTE_NODE:
case XML_TEXT_NODE:
case XML_CDATA_SECTION_NODE:
case XML_ENTITY_REF_NODE:
case XML_PI_NODE:
case XML_COMMENT_NODE:
case XML_DOCUMENT_NODE:
case XML_HTML_DOCUMENT_NODE:
break;
default:
return(XML_ERR_INTERNAL_ERROR);
}
return(XML_ERR_INTERNAL_ERROR);
else
return(XML_ERR_INTERNAL_ERROR);
/*
* allocate a context and set-up everything not related to the
* node position in the tree
*/
#ifdef LIBXML_HTML_ENABLED
#endif
else
return(XML_ERR_INTERNAL_ERROR);
return(XML_ERR_NO_MEMORY);
return(XML_ERR_NO_MEMORY);
}
/*
* Use input doc's dict if present, else assure XML_PARSE_NODICT is set.
* We need a dictionary for xmlDetectSAX2, so if there's no doc dict
* we must wait until the last moment to free the original one.
*/
} else
/*
* initialize the SAX2 namespaces stack
*/
} else {
}
nsnr++;
}
}
}
}
/*
*/
}
#ifdef LIBXML_HTML_ENABLED
else
#endif
} else if (RAW != 0) {
}
ctxt->wellFormed = 0;
}
if (!ctxt->wellFormed) {
else
} else {
ret = XML_ERR_OK;
}
/*
* Return the newly created nodeset after unlinking it from
* the pseudo sibling.
*/
}
}
if (ret != XML_ERR_OK) {
}
return(ret);
#else /* !SAX2 */
return(XML_ERR_INTERNAL_ERROR);
#endif
}
#ifdef LIBXML_SAX1_ENABLED
/**
* xmlParseBalancedChunkMemoryRecover:
* @doc: the document the chunk pertains to
* @sax: the SAX handler bloc (possibly NULL)
* @user_data: The user data returned on SAX callbacks (possibly NULL)
* @depth: Used for loop detection, use 0
* @string: the input string in UTF8 or ISO-Latin (zero terminated)
* @lst: the return value for the set of parsed nodes
* @recover: return nodes even if the data is broken (use 0)
*
*
* Parse a well-balanced chunk of an XML document
* called by the parser
* The allowed sequence for the Well Balanced Chunk is the one defined by
* the content production in the XML grammar:
*
* [43] content ::= (element | CharData | Reference | CDSect | PI | Comment)*
*
* Returns 0 if the chunk is well balanced, -1 in case of args problem and
* the parser error code otherwise
*
* In case recover is set to 1, the nodelist will not be empty even if
* the parsed chunk is not well balanced.
*/
int
int recover) {
int size;
int ret = 0;
if (depth > 40) {
return(XML_ERR_ENTITY_LOOP);
}
return(-1);
}
return(-1);
}
} else {
}
}
return(-1);
}
} else {
/* Ensure that doc has XML spec namespace */
}
/*
* Doing validity checking on chunk doesn't make sense
*/
ctxt->loadsubset = 0;
}
else {
}
} else if (RAW != 0) {
}
}
if (!ctxt->wellFormed) {
ret = 1;
else
} else {
ret = 0;
}
/*
* Return the newly created nodeset after unlinking it from
* they pseudo parent.
*/
}
}
return(ret);
}
/**
* xmlSAXParseEntity:
* @sax: the SAX handler block
* @filename: the filename
*
* parse an XML external entity out of context and build a tree.
* It use the given SAX function block to handle the parsing callback.
* If sax is NULL, fallback to the default DOM tree building routines.
*
* [78] extParsedEnt ::= TextDecl? content
*
* This correspond to a "Well Balanced" chunk
*
* Returns the resulting document tree
*/
return(NULL);
}
}
if (ctxt->wellFormed)
else {
}
return(ret);
}
/**
* xmlParseEntity:
* @filename: the filename
*
* parse an XML external entity out of context and build a tree.
*
* [78] extParsedEnt ::= TextDecl? content
*
* This correspond to a "Well Balanced" chunk
*
* Returns the resulting document tree
*/
}
#endif /* LIBXML_SAX1_ENABLED */
/**
* xmlCreateEntityParserCtxt:
* @URL: the entity URL
* @ID: the entity PUBLIC ID
* @base: a possible base for the target URI
*
* Create a parser context for an external entity
* by default if found at compile-time.
*
* Returns the new parser context or NULL
*/
ctxt = xmlNewParserCtxt();
return(NULL);
}
if (inputStream == NULL) {
return(NULL);
}
} else {
if (inputStream == NULL) {
return(NULL);
}
}
return(ctxt);
}
/************************************************************************
* *
* Front ends when parsing from a file *
* *
************************************************************************/
/**
* xmlCreateURLParserCtxt:
* @filename: the filename or URL
* @options: a combination of xmlParserOption
*
* Create a parser context for a file or URL content.
* by default if found at compile-time and for file accesses
*
* Returns the new parser context or NULL
*/
{
ctxt = xmlNewParserCtxt();
return(NULL);
}
if (options)
if (inputStream == NULL) {
return(NULL);
}
return(ctxt);
}
/**
* xmlCreateFileParserCtxt:
* @filename: the filename
*
* Create a parser context for a file content.
* by default if found at compile-time.
*
* Returns the new parser context or NULL
*/
{
return(xmlCreateURLParserCtxt(filename, 0));
}
#ifdef LIBXML_SAX1_ENABLED
/**
* xmlSAXParseFileWithData:
* @sax: the SAX handler block
* @filename: the filename
* @recovery: work in recovery mode, i.e. tries to read no Well Formed
* documents
* @data: the userdata
*
* compressed document is provided by default if found at compile-time.
* It use the given SAX function block to handle the parsing callback.
* If sax is NULL, fallback to the default DOM tree building routines.
*
* User data (void *) is stored within the parser context in the
* context's _private member, so it is available nearly everywhere in libxml
*
* Returns the resulting document tree
*/
return(NULL);
}
}
}
else
}
}
else {
}
return(ret);
}
/**
* xmlSAXParseFile:
* @sax: the SAX handler block
* @filename: the filename
* @recovery: work in recovery mode, i.e. tries to read no Well Formed
* documents
*
* compressed document is provided by default if found at compile-time.
* It use the given SAX function block to handle the parsing callback.
* If sax is NULL, fallback to the default DOM tree building routines.
*
* Returns the resulting document tree
*/
int recovery) {
}
/**
* xmlRecoverDoc:
* @cur: a pointer to an array of xmlChar
*
* parse an XML in-memory document and build a tree.
* In the case the document is not Well Formed, a tree is built anyway
*
* Returns the resulting document tree
*/
}
/**
* xmlParseFile:
* @filename: the filename
*
* compressed document is provided by default if found at compile-time.
*
* Returns the resulting document tree if the file was wellformed,
* NULL otherwise.
*/
}
/**
* xmlRecoverFile:
* @filename: the filename
*
* compressed document is provided by default if found at compile-time.
* In the case the document is not Well Formed, a tree is built anyway
*
* Returns the resulting document tree
*/
}
/**
* xmlSetupParserForBuffer:
* @ctxt: an XML parser context
* @buffer: a xmlChar * buffer
* @filename: a file name
*
* Setup the parser context to parse a new buffer; Clears any prior
* contents from the parser context. The buffer parameter must not be
* NULL, but the filename parameter can be
*/
void
const char* filename)
{
return;
return;
}
}
/**
* xmlSAXUserParseFile:
* @sax: a SAX handler
* @user_data: The user data returned on SAX callbacks
* @filename: a file name
*
* parse an XML file and call the given SAX handler routines.
*
* Returns 0 in case of success or a error number otherwise
*/
int
const char *filename) {
int ret = 0;
if (ctxt->wellFormed)
ret = 0;
else {
else
ret = -1;
}
}
return ret;
}
#endif /* LIBXML_SAX1_ENABLED */
/************************************************************************
* *
* Front ends when parsing from memory *
* *
************************************************************************/
/**
* xmlCreateMemoryParserCtxt:
* @buffer: a pointer to a char array
* @size: the size of the array
*
* Create a parser context for an XML in-memory document.
*
* Returns the new parser context or NULL
*/
return(NULL);
if (size <= 0)
return(NULL);
ctxt = xmlNewParserCtxt();
return(NULL);
/* TODO: xmlParserInputBufferCreateStatic, requires some serious changes */
return(NULL);
}
return(NULL);
}
return(ctxt);
}
#ifdef LIBXML_SAX1_ENABLED
/**
* xmlSAXParseMemoryWithData:
* @sax: the SAX handler block
* @buffer: an pointer to a char array
* @size: the size of the array
* @recovery: work in recovery mode, i.e. tries to read no Well Formed
* documents
* @data: the userdata
*
* parse an XML in-memory block and use the given SAX function block
* to handle the parsing callback. If sax is NULL, fallback to the default
* DOM tree building routines.
*
* User data (void *) is stored within the parser context in the
* context's _private member, so it is available nearly everywhere in libxml
*
* Returns the resulting document tree
*/
}
}
else {
}
return(ret);
}
/**
* xmlSAXParseMemory:
* @sax: the SAX handler block
* @buffer: an pointer to a char array
* @size: the size of the array
* @recovery: work in recovery mode, i.e. tries to read not Well Formed
* documents
*
* parse an XML in-memory block and use the given SAX function block
* to handle the parsing callback. If sax is NULL, fallback to the default
* DOM tree building routines.
*
* Returns the resulting document tree
*/
}
/**
* xmlParseMemory:
* @buffer: an pointer to a char array
* @size: the size of the array
*
* parse an XML in-memory block and build a tree.
*
* Returns the resulting document tree
*/
}
/**
* xmlRecoverMemory:
* @buffer: an pointer to a char array
* @size: the size of the array
*
* parse an XML in-memory block and build a tree.
* In the case the document is not Well Formed, a tree is built anyway
*
* Returns the resulting document tree
*/
}
/**
* xmlSAXUserParseMemory:
* @sax: a SAX handler
* @user_data: The user data returned on SAX callbacks
* @buffer: an in-memory XML document input
* @size: the length of the XML document in bytes
*
* A better SAX parsing routine.
* parse an XML in-memory buffer and call the given SAX handler routines.
*
* Returns 0 in case of success or a error number otherwise
*/
int ret = 0;
if (ctxt->wellFormed)
ret = 0;
else {
else
ret = -1;
}
}
return ret;
}
#endif /* LIBXML_SAX1_ENABLED */
/**
* xmlCreateDocParserCtxt:
* @cur: a pointer to an array of xmlChar
*
* Creates a parser context for an XML in-memory document.
*
* Returns the new parser context or NULL
*/
int len;
return(NULL);
}
#ifdef LIBXML_SAX1_ENABLED
/**
* xmlSAXParseDoc:
* @sax: the SAX handler block
* @cur: a pointer to an array of xmlChar
* @recovery: work in recovery mode, i.e. tries to read no Well Formed
* documents
*
* parse an XML in-memory document and build a tree.
* It use the given SAX function block to handle the parsing callback.
* If sax is NULL, fallback to the default DOM tree building routines.
*
* Returns the resulting document tree
*/
}
else {
}
return(ret);
}
/**
* xmlParseDoc:
* @cur: a pointer to an array of xmlChar
*
* parse an XML in-memory document and build a tree.
*
* Returns the resulting document tree
*/
}
#endif /* LIBXML_SAX1_ENABLED */
#ifdef LIBXML_LEGACY_ENABLED
/************************************************************************
* *
* Specific function to keep track of entities references *
* and used by the XSLT debugger *
* *
************************************************************************/
/**
* xmlAddEntityReference:
* @ent : A valid entity
* @firstNode : A valid first node for children of entity
* @lastNode : A valid last node of children entity
*
* Notify of a reference to an entity of type XML_EXTERNAL_GENERAL_PARSED_ENTITY
*/
static void
{
if (xmlEntityRefFunc != NULL) {
}
}
/**
* xmlSetEntityReferenceFunc:
* @func: A valid function
*
* Set the function to call call back when a xml reference has been made
*/
void
{
}
#endif /* LIBXML_LEGACY_ENABLED */
/************************************************************************
* *
* Miscellaneous *
* *
************************************************************************/
#ifdef LIBXML_XPATH_ENABLED
#endif
static int xmlParserInitialized = 0;
/**
* xmlInitParser:
*
* Initialization function for the XML parser.
* This is not reentrant. Call once before processing in case of
* use in multithreaded programs.
*/
void
xmlInitParser(void) {
if (xmlParserInitialized != 0)
return;
#ifdef LIBXML_THREAD_ENABLED
if (xmlParserInitialized == 0) {
#endif
if ((xmlGenericError == xmlGenericErrorDefaultFunc) ||
(xmlGenericError == NULL))
#ifdef LIBXML_OUTPUT_ENABLED
#endif /* LIBXML_OUTPUT_ENABLED */
#ifdef LIBXML_HTML_ENABLED
#endif
#ifdef LIBXML_XPATH_ENABLED
xmlXPathInit();
#endif
xmlParserInitialized = 1;
#ifdef LIBXML_THREAD_ENABLED
}
#endif
}
/**
* xmlCleanupParser:
*
* Cleanup function for the XML library. It tries to reclaim all
* parsing related global memory allocated for the library processing.
* It doesn't deallocate any document related memory. Calling this
* function should not prevent reusing the library but one should
* call xmlCleanupParser() only when the process has
* finished using the library or XML document built with it.
*/
void
xmlCleanupParser(void) {
if (!xmlParserInitialized)
return;
#ifdef LIBXML_CATALOG_ENABLED
#endif
#ifdef LIBXML_OUTPUT_ENABLED
#endif
#ifdef LIBXML_SCHEMAS_ENABLED
#endif
xmlCleanupThreads(); /* must be last if called not from the main thread */
xmlParserInitialized = 0;
}
/************************************************************************
* *
* New set (2.6.0) of simpler and more flexible APIs *
* *
************************************************************************/
/**
* DICT_FREE:
* @str: a string
*
* Free a string if it is not owned by the "dict" dictionnary in the
* current scope
*/
/**
* xmlCtxtReset:
* @ctxt: an XML parser context
*
* Reset a parser context
*/
void
{
return;
}
} else {
}
ctxt->hasExternalSubset = 0;
ctxt->disableSAX = 0;
#if 0
#endif
ctxt->record_info = 0;
ctxt->checkIndex = 0;
ctxt->nbentities = 0;
ctxt->sizeentities = 0;
ctxt->sizeentcopy = 0;
}
}
#ifdef LIBXML_CATALOG_ENABLED
#endif
}
/**
* xmlCtxtResetPush:
* @ctxt: an XML parser context
* @chunk: a pointer to an array of chars
* @size: number of chars in the array
* @filename: an optional file name or URI
* @encoding: the document encoding, or NULL
*
* Reset a push parser context
*
* Returns 0 in case of success and 1 in case of error
*/
int
{
return(1);
return(1);
return(1);
}
sizeof(xmlChar *));
return(1);
}
}
} else {
}
if (inputStream == NULL) {
return(1);
}
else
inputStream->filename = (char *)
inputStream->end =
use];
#ifdef DEBUG_PUSH
#endif
}
} else {
}
} else if (enc != XML_CHAR_ENCODING_NONE) {
}
return(0);
}
/**
* xmlCtxtUseOptions:
* @ctxt: an XML parser context
* @options: a combination of xmlParserOption
*
* Applies the options to the parser context
*
* Returns 0 in case of success, the set of unknown or unimplemented options
* in case of error.
*/
int
{
return(-1);
if (options & XML_PARSE_RECOVER) {
} else
if (options & XML_PARSE_DTDLOAD) {
} else
ctxt->loadsubset = 0;
if (options & XML_PARSE_DTDATTR) {
}
if (options & XML_PARSE_NOENT) {
/* ctxt->loadsubset |= XML_DETECT_IDS; */
} else
ctxt->replaceEntities = 0;
if (options & XML_PARSE_PEDANTIC) {
} else
if (options & XML_PARSE_NOBLANKS) {
ctxt->keepBlanks = 0;
} else
if (options & XML_PARSE_DTDVALID) {
if (options & XML_PARSE_NOWARNING)
if (options & XML_PARSE_NOERROR)
} else
if (options & XML_PARSE_NOWARNING) {
}
if (options & XML_PARSE_NOERROR) {
}
#ifdef LIBXML_SAX1_ENABLED
if (options & XML_PARSE_SAX1) {
}
#endif /* LIBXML_SAX1_ENABLED */
if (options & XML_PARSE_NODICT) {
} else {
}
if (options & XML_PARSE_NOCDATA) {
}
if (options & XML_PARSE_NSCLEAN) {
}
if (options & XML_PARSE_NONET) {
}
if (options & XML_PARSE_COMPACT) {
}
return (options);
}
/**
* xmlDoRead:
* @ctxt: an XML parser context
* @URL: the base URL to use for the document
* @encoding: the document encoding, or NULL
* @options: a combination of xmlParserOption
* @reuse: keep the context for reuse
*
* Common front-end for the xmlRead functions
*
* Returns the resulting document tree or NULL
*/
static xmlDocPtr
{
}
else {
}
}
if (!reuse) {
}
return (ret);
}
/**
* xmlReadDoc:
* @cur: a pointer to a zero terminated string
* @URL: the base URL to use for the document
* @encoding: the document encoding, or NULL
* @options: a combination of xmlParserOption
*
* parse an XML in-memory document and build a tree.
*
* Returns the resulting document tree
*/
{
return (NULL);
return (NULL);
}
/**
* xmlReadFile:
* @filename: a file or URL
* @encoding: the document encoding, or NULL
* @options: a combination of xmlParserOption
*
* parse an XML file from the filesystem or the network.
*
* Returns the resulting document tree
*/
{
return (NULL);
}
/**
* xmlReadMemory:
* @buffer: a pointer to a char array
* @size: the size of the array
* @URL: the base URL to use for the document
* @encoding: the document encoding, or NULL
* @options: a combination of xmlParserOption
*
* parse an XML in-memory document and build a tree.
*
* Returns the resulting document tree
*/
{
return (NULL);
}
/**
* xmlReadFd:
* @fd: an open file descriptor
* @URL: the base URL to use for the document
* @encoding: the document encoding, or NULL
* @options: a combination of xmlParserOption
*
* parse an XML from a file descriptor and build a tree.
* NOTE that the file descriptor will not be closed when the
* reader is closed or reset.
*
* Returns the resulting document tree
*/
{
if (fd < 0)
return (NULL);
return (NULL);
ctxt = xmlNewParserCtxt();
return (NULL);
}
return (NULL);
}
}
/**
* xmlReadIO:
* @ioread: an I/O read function
* @ioclose: an I/O close function
* @ioctx: an I/O handler
* @URL: the base URL to use for the document
* @encoding: the document encoding, or NULL
* @options: a combination of xmlParserOption
*
* parse an XML document from I/O functions and source and build a tree.
*
* Returns the resulting document tree
*/
{
return (NULL);
return (NULL);
ctxt = xmlNewParserCtxt();
return (NULL);
}
return (NULL);
}
}
/**
* xmlCtxtReadDoc:
* @ctxt: an XML parser context
* @cur: a pointer to a zero terminated string
* @URL: the base URL to use for the document
* @encoding: the document encoding, or NULL
* @options: a combination of xmlParserOption
*
* parse an XML in-memory document and build a tree.
* This reuses the existing @ctxt parser context
*
* Returns the resulting document tree
*/
{
return (NULL);
return (NULL);
return (NULL);
}
}
/**
* xmlCtxtReadFile:
* @ctxt: an XML parser context
* @filename: a file or URL
* @encoding: the document encoding, or NULL
* @options: a combination of xmlParserOption
*
* parse an XML file from the filesystem or the network.
* This reuses the existing @ctxt parser context
*
* Returns the resulting document tree
*/
{
return (NULL);
return (NULL);
return (NULL);
}
}
/**
* xmlCtxtReadMemory:
* @ctxt: an XML parser context
* @buffer: a pointer to a char array
* @size: the size of the array
* @URL: the base URL to use for the document
* @encoding: the document encoding, or NULL
* @options: a combination of xmlParserOption
*
* parse an XML in-memory document and build a tree.
* This reuses the existing @ctxt parser context
*
* Returns the resulting document tree
*/
{
return (NULL);
return (NULL);
return(NULL);
}
return(NULL);
}
}
/**
* xmlCtxtReadFd:
* @ctxt: an XML parser context
* @fd: an open file descriptor
* @URL: the base URL to use for the document
* @encoding: the document encoding, or NULL
* @options: a combination of xmlParserOption
*
* parse an XML from a file descriptor and build a tree.
* This reuses the existing @ctxt parser context
* NOTE that the file descriptor will not be closed when the
* reader is closed or reset.
*
* Returns the resulting document tree
*/
{
if (fd < 0)
return (NULL);
return (NULL);
return (NULL);
return (NULL);
}
}
/**
* xmlCtxtReadIO:
* @ctxt: an XML parser context
* @ioread: an I/O read function
* @ioclose: an I/O close function
* @ioctx: an I/O handler
* @URL: the base URL to use for the document
* @encoding: the document encoding, or NULL
* @options: a combination of xmlParserOption
*
* parse an XML document from I/O functions and source and build a tree.
* This reuses the existing @ctxt parser context
*
* Returns the resulting document tree
*/
const char *URL,
{
return (NULL);
return (NULL);
return (NULL);
return (NULL);
}
}
#define bottom_parser
#include "elfgcchack.h"