ReactOS 0.4.15-dev-8393-g61b7fb9
parserInternals.h File Reference
#include <libxml/xmlversion.h>
#include <libxml/parser.h>
#include <libxml/HTMLparser.h>
#include <libxml/chvalid.h>
Include dependency graph for parserInternals.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define XML_MAX_TEXT_LENGTH   10000000
 
#define XML_MAX_NAME_LENGTH   50000
 
#define XML_MAX_DICTIONARY_LIMIT   10000000
 
#define XML_MAX_LOOKUP_LIMIT   10000000
 
#define XML_MAX_NAMELEN   100
 
#define INPUT_CHUNK   250
 
#define IS_BYTE_CHAR(c)   xmlIsChar_ch(c)
 
#define IS_CHAR(c)   xmlIsCharQ(c)
 
#define IS_CHAR_CH(c)   xmlIsChar_ch(c)
 
#define IS_BLANK(c)   xmlIsBlankQ(c)
 
#define IS_BLANK_CH(c)   xmlIsBlank_ch(c)
 
#define IS_BASECHAR(c)   xmlIsBaseCharQ(c)
 
#define IS_DIGIT(c)   xmlIsDigitQ(c)
 
#define IS_DIGIT_CH(c)   xmlIsDigit_ch(c)
 
#define IS_COMBINING(c)   xmlIsCombiningQ(c)
 
#define IS_COMBINING_CH(c)   0
 
#define IS_EXTENDER(c)   xmlIsExtenderQ(c)
 
#define IS_EXTENDER_CH(c)   xmlIsExtender_ch(c)
 
#define IS_IDEOGRAPHIC(c)   xmlIsIdeographicQ(c)
 
#define IS_LETTER(c)   (IS_BASECHAR(c) || IS_IDEOGRAPHIC(c))
 
#define IS_LETTER_CH(c)   xmlIsBaseChar_ch(c)
 
#define IS_ASCII_LETTER(c)
 
#define IS_ASCII_DIGIT(c)   ((0x30 <= (c)) && ((c) <= 0x39))
 
#define IS_PUBIDCHAR(c)   xmlIsPubidCharQ(c)
 
#define IS_PUBIDCHAR_CH(c)   xmlIsPubidChar_ch(c)
 
#define SKIP_EOL(p)
 
#define MOVETO_ENDTAG(p)    while ((*p) && (*(p) != '>')) (p)++
 
#define MOVETO_STARTTAG(p)    while ((*p) && (*(p) != '<')) (p)++
 
#define XML_SUBSTITUTE_NONE   0
 
#define XML_SUBSTITUTE_REF   1
 
#define XML_SUBSTITUTE_PEREF   2
 
#define XML_SUBSTITUTE_BOTH   3
 

Functions

XMLPUBFUN int XMLCALL xmlIsLetter (int c)
 
XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlCreateFileParserCtxt (const char *filename)
 
XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlCreateURLParserCtxt (const char *filename, int options)
 
XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlCreateMemoryParserCtxt (const char *buffer, int size)
 
XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlCreateEntityParserCtxt (const xmlChar *URL, const xmlChar *ID, const xmlChar *base)
 
XMLPUBFUN int XMLCALL xmlSwitchEncoding (xmlParserCtxtPtr ctxt, xmlCharEncoding enc)
 
XMLPUBFUN int XMLCALL xmlSwitchToEncoding (xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler)
 
XML_DEPRECATED XMLPUBFUN int XMLCALL xmlSwitchInputEncoding (xmlParserCtxtPtr ctxt, xmlParserInputPtr input, xmlCharEncodingHandlerPtr handler)
 
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewStringInputStream (xmlParserCtxtPtr ctxt, const xmlChar *buffer)
 
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewEntityInputStream (xmlParserCtxtPtr ctxt, xmlEntityPtr entity)
 
XMLPUBFUN int XMLCALL xmlPushInput (xmlParserCtxtPtr ctxt, xmlParserInputPtr input)
 
XMLPUBFUN xmlChar XMLCALL xmlPopInput (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlFreeInputStream (xmlParserInputPtr input)
 
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewInputFromFile (xmlParserCtxtPtr ctxt, const char *filename)
 
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewInputStream (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN xmlChar *XMLCALL xmlSplitQName (xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefix)
 
XMLPUBFUN const xmlChar *XMLCALL xmlParseName (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN xmlChar *XMLCALL xmlParseNmtoken (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN xmlChar *XMLCALL xmlParseEntityValue (xmlParserCtxtPtr ctxt, xmlChar **orig)
 
XMLPUBFUN xmlChar *XMLCALL xmlParseAttValue (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN xmlChar *XMLCALL xmlParseSystemLiteral (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN xmlChar *XMLCALL xmlParsePubidLiteral (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseCharData (xmlParserCtxtPtr ctxt, int cdata)
 
XMLPUBFUN xmlChar *XMLCALL xmlParseExternalID (xmlParserCtxtPtr ctxt, xmlChar **publicID, int strict)
 
XMLPUBFUN void XMLCALL xmlParseComment (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN const xmlChar *XMLCALL xmlParsePITarget (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParsePI (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseNotationDecl (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseEntityDecl (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN int XMLCALL xmlParseDefaultDecl (xmlParserCtxtPtr ctxt, xmlChar **value)
 
XMLPUBFUN xmlEnumerationPtr XMLCALL xmlParseNotationType (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN xmlEnumerationPtr XMLCALL xmlParseEnumerationType (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN int XMLCALL xmlParseEnumeratedType (xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree)
 
XMLPUBFUN int XMLCALL xmlParseAttributeType (xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree)
 
XMLPUBFUN void XMLCALL xmlParseAttributeListDecl (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN xmlElementContentPtr XMLCALL xmlParseElementMixedContentDecl (xmlParserCtxtPtr ctxt, int inputchk)
 
XMLPUBFUN xmlElementContentPtr XMLCALL xmlParseElementChildrenContentDecl (xmlParserCtxtPtr ctxt, int inputchk)
 
XMLPUBFUN int XMLCALL xmlParseElementContentDecl (xmlParserCtxtPtr ctxt, const xmlChar *name, xmlElementContentPtr *result)
 
XMLPUBFUN int XMLCALL xmlParseElementDecl (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseMarkupDecl (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN int XMLCALL xmlParseCharRef (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN xmlEntityPtr XMLCALL xmlParseEntityRef (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseReference (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParsePEReference (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseDocTypeDecl (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseCDSect (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseContent (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseElement (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN xmlChar *XMLCALL xmlParseVersionNum (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN xmlChar *XMLCALL xmlParseVersionInfo (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN xmlChar *XMLCALL xmlParseEncName (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN const xmlChar *XMLCALL xmlParseEncodingDecl (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN int XMLCALL xmlParseSDDecl (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseXMLDecl (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseTextDecl (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseMisc (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseExternalSubset (xmlParserCtxtPtr ctxt, const xmlChar *ExternalID, const xmlChar *SystemID)
 
XMLPUBFUN xmlChar *XMLCALL xmlStringDecodeEntities (xmlParserCtxtPtr ctxt, const xmlChar *str, int what, xmlChar end, xmlChar end2, xmlChar end3)
 
XMLPUBFUN xmlChar *XMLCALL xmlStringLenDecodeEntities (xmlParserCtxtPtr ctxt, const xmlChar *str, int len, int what, xmlChar end, xmlChar end2, xmlChar end3)
 
XMLPUBFUN int XMLCALL nodePush (xmlParserCtxtPtr ctxt, xmlNodePtr value)
 
XMLPUBFUN xmlNodePtr XMLCALL nodePop (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN int XMLCALL inputPush (xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
 
XMLPUBFUN xmlParserInputPtr XMLCALL inputPop (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN const xmlChar *XMLCALL namePop (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN int XMLCALL namePush (xmlParserCtxtPtr ctxt, const xmlChar *value)
 
XMLPUBFUN int XMLCALL xmlSkipBlankChars (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN int XMLCALL xmlStringCurrentChar (xmlParserCtxtPtr ctxt, const xmlChar *cur, int *len)
 
XMLPUBFUN void XMLCALL xmlParserHandlePEReference (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN int XMLCALL xmlCheckLanguageID (const xmlChar *lang)
 
XMLPUBFUN int XMLCALL xmlCurrentChar (xmlParserCtxtPtr ctxt, int *len)
 
XMLPUBFUN int XMLCALL xmlCopyCharMultiByte (xmlChar *out, int val)
 
XMLPUBFUN int XMLCALL xmlCopyChar (int len, xmlChar *out, int val)
 
XMLPUBFUN void XMLCALL xmlNextChar (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParserInputShrink (xmlParserInputPtr in)
 

Variables

XMLPUBVAR unsigned int xmlParserMaxDepth
 
XMLPUBVAR const xmlChar xmlStringText []
 
XMLPUBVAR const xmlChar xmlStringTextNoenc []
 
XMLPUBVAR const xmlChar xmlStringComment []
 

Macro Definition Documentation

◆ INPUT_CHUNK

#define INPUT_CHUNK   250

INPUT_CHUNK:

The parser tries to always have that amount of input ready. One of the point is providing context when reporting errors.

Definition at line 89 of file parserInternals.h.

◆ IS_ASCII_DIGIT

#define IS_ASCII_DIGIT (   c)    ((0x30 <= (c)) && ((c) <= 0x39))

IS_ASCII_DIGIT: : an xmlChar value

Macro to check [0-9]

Definition at line 260 of file parserInternals.h.

◆ IS_ASCII_LETTER

#define IS_ASCII_LETTER (   c)
Value:
(((0x41 <= (c)) && ((c) <= 0x5a)) || \
((0x61 <= (c)) && ((c) <= 0x7a)))
const GLubyte * c
Definition: glext.h:8905
#define c
Definition: ke_i.h:80

IS_ASCII_LETTER: : an xmlChar value

Macro to check [a-zA-Z]

Definition at line 250 of file parserInternals.h.

◆ IS_BASECHAR

#define IS_BASECHAR (   c)    xmlIsBaseCharQ(c)

IS_BASECHAR: : an UNICODE value (int)

Macro to check the following production in the XML spec:

[85] BaseChar ::= ... long list see REC ...

Definition at line 153 of file parserInternals.h.

◆ IS_BLANK

#define IS_BLANK (   c)    xmlIsBlankQ(c)

IS_BLANK: : an UNICODE value (int)

Macro to check the following production in the XML spec:

[3] S ::= (#x20 | #x9 | #xD | #xA)+

Definition at line 135 of file parserInternals.h.

◆ IS_BLANK_CH

#define IS_BLANK_CH (   c)    xmlIsBlank_ch(c)

IS_BLANK_CH: : an xmlChar value (normally unsigned char)

Behaviour same as IS_BLANK

Definition at line 143 of file parserInternals.h.

◆ IS_BYTE_CHAR

#define IS_BYTE_CHAR (   c)    xmlIsChar_ch(c)

IS_BYTE_CHAR: : an byte value (int)

Macro to check the following production in the XML spec:

[2] Char ::= #x9 | #xA | #xD | [#x20...] any byte character in the accepted range

Definition at line 105 of file parserInternals.h.

◆ IS_CHAR

#define IS_CHAR (   c)    xmlIsCharQ(c)

IS_CHAR: : an UNICODE value (int)

Macro to check the following production in the XML spec:

[2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.

Definition at line 117 of file parserInternals.h.

◆ IS_CHAR_CH

#define IS_CHAR_CH (   c)    xmlIsChar_ch(c)

IS_CHAR_CH: : an xmlChar (usually an unsigned char)

Behaves like IS_CHAR on single-byte value

Definition at line 125 of file parserInternals.h.

◆ IS_COMBINING

#define IS_COMBINING (   c)    xmlIsCombiningQ(c)

IS_COMBINING: : an UNICODE value (int)

Macro to check the following production in the XML spec:

[87] CombiningChar ::= ... long list see REC ...

Definition at line 181 of file parserInternals.h.

◆ IS_COMBINING_CH

#define IS_COMBINING_CH (   c)    0

IS_COMBINING_CH: : an xmlChar (usually an unsigned char)

Always false (all combining chars > 0xff)

Definition at line 189 of file parserInternals.h.

◆ IS_DIGIT

#define IS_DIGIT (   c)    xmlIsDigitQ(c)

IS_DIGIT: : an UNICODE value (int)

Macro to check the following production in the XML spec:

[88] Digit ::= ... long list see REC ...

Definition at line 163 of file parserInternals.h.

◆ IS_DIGIT_CH

#define IS_DIGIT_CH (   c)    xmlIsDigit_ch(c)

IS_DIGIT_CH: : an xmlChar value (usually an unsigned char)

Behaves like IS_DIGIT but with a single byte argument

Definition at line 171 of file parserInternals.h.

◆ IS_EXTENDER

#define IS_EXTENDER (   c)    xmlIsExtenderQ(c)

IS_EXTENDER: : an UNICODE value (int)

Macro to check the following production in the XML spec:

[89] Extender ::= #x00B7 | #x02D0 | #x02D1 | #x0387 | #x0640 | #x0E46 | #x0EC6 | #x3005 | [#x3031-#x3035] | [#x309D-#x309E] | [#x30FC-#x30FE]

Definition at line 202 of file parserInternals.h.

◆ IS_EXTENDER_CH

#define IS_EXTENDER_CH (   c)    xmlIsExtender_ch(c)

IS_EXTENDER_CH: : an xmlChar value (usually an unsigned char)

Behaves like IS_EXTENDER but with a single-byte argument

Definition at line 210 of file parserInternals.h.

◆ IS_IDEOGRAPHIC

#define IS_IDEOGRAPHIC (   c)    xmlIsIdeographicQ(c)

IS_IDEOGRAPHIC: : an UNICODE value (int)

Macro to check the following production in the XML spec:

[86] Ideographic ::= [#x4E00-#x9FA5] | #x3007 | [#x3021-#x3029]

Definition at line 221 of file parserInternals.h.

◆ IS_LETTER

#define IS_LETTER (   c)    (IS_BASECHAR(c) || IS_IDEOGRAPHIC(c))

IS_LETTER: : an UNICODE value (int)

Macro to check the following production in the XML spec:

[84] Letter ::= BaseChar | Ideographic

Definition at line 232 of file parserInternals.h.

◆ IS_LETTER_CH

#define IS_LETTER_CH (   c)    xmlIsBaseChar_ch(c)

IS_LETTER_CH: : an xmlChar value (normally unsigned char)

Macro behaves like IS_LETTER, but only check base chars

Definition at line 241 of file parserInternals.h.

◆ IS_PUBIDCHAR

#define IS_PUBIDCHAR (   c)    xmlIsPubidCharQ(c)

IS_PUBIDCHAR: : an UNICODE value (int)

Macro to check the following production in the XML spec:

[13] PubidChar ::= #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#$_%]

Definition at line 271 of file parserInternals.h.

◆ IS_PUBIDCHAR_CH

#define IS_PUBIDCHAR_CH (   c)    xmlIsPubidChar_ch(c)

IS_PUBIDCHAR_CH: : an xmlChar value (normally unsigned char)

Same as IS_PUBIDCHAR but for single-byte value

Definition at line 279 of file parserInternals.h.

◆ MOVETO_ENDTAG

#define MOVETO_ENDTAG (   p)     while ((*p) && (*(p) != '>')) (p)++

MOVETO_ENDTAG: : and UTF8 string pointer

Skips to the next '>' char.

Definition at line 297 of file parserInternals.h.

◆ MOVETO_STARTTAG

#define MOVETO_STARTTAG (   p)     while ((*p) && (*(p) != '<')) (p)++

MOVETO_STARTTAG: : and UTF8 string pointer

Skips to the next '<' char.

Definition at line 306 of file parserInternals.h.

◆ SKIP_EOL

#define SKIP_EOL (   p)
Value:
if (*(p) == 0x13) { p++ ; if (*(p) == 0x10) p++; } \
if (*(p) == 0x10) { p++ ; if (*(p) == 0x13) p++; }
GLfloat GLfloat p
Definition: glext.h:8902

SKIP_EOL: : and UTF8 string pointer

Skips the end of line chars.

Definition at line 287 of file parserInternals.h.

◆ XML_MAX_DICTIONARY_LIMIT

#define XML_MAX_DICTIONARY_LIMIT   10000000

XML_MAX_DICTIONARY_LIMIT:

Maximum size allowed by the parser for a dictionary by default This is not a limitation of the parser but a safety boundary feature, use XML_PARSE_HUGE option to override it. Introduced in 2.9.0

Definition at line 63 of file parserInternals.h.

◆ XML_MAX_LOOKUP_LIMIT

#define XML_MAX_LOOKUP_LIMIT   10000000

XML_MAX_LOOKUP_LIMIT:

Maximum size allowed by the parser for ahead lookup This is an upper boundary enforced by the parser to avoid bad behaviour on "unfriendly' content Introduced in 2.9.0

Definition at line 73 of file parserInternals.h.

◆ XML_MAX_NAME_LENGTH

#define XML_MAX_NAME_LENGTH   50000

XML_MAX_NAME_LENGTH:

Maximum size allowed for a markup identifier. This is not a limitation of the parser but a safety boundary feature, use XML_PARSE_HUGE option to override it. Note that with the use of parsing dictionaries overriding the limit may result in more runtime memory usage in face of "unfriendly' content Introduced in 2.9.0

Definition at line 53 of file parserInternals.h.

◆ XML_MAX_NAMELEN

#define XML_MAX_NAMELEN   100

XML_MAX_NAMELEN:

Identifiers can be longer, but this will be more costly at runtime.

Definition at line 81 of file parserInternals.h.

◆ XML_MAX_TEXT_LENGTH

#define XML_MAX_TEXT_LENGTH   10000000

XML_MAX_TEXT_LENGTH:

Maximum size allowed for a single text node when building a tree. This is not a limitation of the parser but a safety boundary feature, use XML_PARSE_HUGE option to override it. Introduced in 2.9.0

Definition at line 41 of file parserInternals.h.

◆ XML_SUBSTITUTE_BOTH

#define XML_SUBSTITUTE_BOTH   3

XML_SUBSTITUTE_BOTH:

Both general and parameter entities need to be substituted.

Definition at line 520 of file parserInternals.h.

◆ XML_SUBSTITUTE_NONE

#define XML_SUBSTITUTE_NONE   0

XML_SUBSTITUTE_NONE:

If no entities need to be substituted.

Definition at line 502 of file parserInternals.h.

◆ XML_SUBSTITUTE_PEREF

#define XML_SUBSTITUTE_PEREF   2

XML_SUBSTITUTE_PEREF:

Whether parameter entities need to be substituted.

Definition at line 514 of file parserInternals.h.

◆ XML_SUBSTITUTE_REF

#define XML_SUBSTITUTE_REF   1

XML_SUBSTITUTE_REF:

Whether general entities need to be substituted.

Definition at line 508 of file parserInternals.h.

Function Documentation

◆ inputPop()

inputPop: @ctxt: an XML parser context

Pops the top parser input from the input stack

Returns the input just removed

Definition at line 1774 of file parser.c.

1775{
1777
1778 if (ctxt == NULL)
1779 return(NULL);
1780 if (ctxt->inputNr <= 0)
1781 return (NULL);
1782 ctxt->inputNr--;
1783 if (ctxt->inputNr > 0)
1784 ctxt->input = ctxt->inputTab[ctxt->inputNr - 1];
1785 else
1786 ctxt->input = NULL;
1787 ret = ctxt->inputTab[ctxt->inputNr];
1788 ctxt->inputTab[ctxt->inputNr] = NULL;
1789 return (ret);
1790}
#define NULL
Definition: types.h:112
xmlParserInputPtr * inputTab
Definition: parser.h:202
xmlParserInputPtr input
Definition: parser.h:199
int ret

Referenced by xmlCtxtReset(), xmlFreeParserCtxt(), xmlHaltParser(), xmlInitParserCtxt(), xmlPopInput(), and xmlPushInput().

◆ inputPush()

XMLPUBFUN int XMLCALL inputPush ( xmlParserCtxtPtr  ctxt,
xmlParserInputPtr  value 
)

inputPush: @ctxt: an XML parser context @value: the parser input

Pushes a new parser input on top of the input stack

Returns -1 in case of error, the index in the stack otherwise

Definition at line 1745 of file parser.c.

1746{
1747 if ((ctxt == NULL) || (value == NULL))
1748 return(-1);
1749 if (ctxt->inputNr >= ctxt->inputMax) {
1750 ctxt->inputMax *= 2;
1751 ctxt->inputTab =
1753 ctxt->inputMax *
1754 sizeof(ctxt->inputTab[0]));
1755 if (ctxt->inputTab == NULL) {
1756 xmlErrMemory(ctxt, NULL);
1757 ctxt->inputMax /= 2;
1758 return (-1);
1759 }
1760 }
1761 ctxt->inputTab[ctxt->inputNr] = value;
1762 ctxt->input = value;
1763 return (ctxt->inputNr++);
1764}
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:250
int inputMax
Definition: parser.h:201
Definition: pdh_main.c:94

Referenced by testSAX(), xmlCreateEntityParserCtxtInternal(), xmlCreateIOParserCtxt(), xmlCreateMemoryParserCtxt(), xmlCreateURLParserCtxt(), xmlCtxtReadFd(), xmlCtxtReadFile(), xmlCtxtReadIO(), xmlCtxtReadMemory(), xmlCtxtResetPush(), xmlPushInput(), xmlReadFd(), xmlReadIO(), and xsltDocDefaultLoaderFunc().

◆ namePop()

namePop: @ctxt: an XML parser context

Pops the top element name from the name stack

Returns the name just removed

Definition at line 1981 of file parser.c.

1982{
1983 const xmlChar *ret;
1984
1985 if ((ctxt == NULL) || (ctxt->nameNr <= 0))
1986 return (NULL);
1987 ctxt->nameNr--;
1988 if (ctxt->nameNr > 0)
1989 ctxt->name = ctxt->nameTab[ctxt->nameNr - 1];
1990 else
1991 ctxt->name = NULL;
1992 ret = ctxt->nameTab[ctxt->nameNr];
1993 ctxt->nameTab[ctxt->nameNr] = NULL;
1994 return (ret);
1995}
const xmlChar * name
Definition: parser.h:229
const xmlChar ** nameTab
Definition: parser.h:232
unsigned char xmlChar
Definition: xmlstring.h:28

Referenced by xmlParseElementEnd(), and xmlParseElementStart().

◆ namePush()

XMLPUBFUN int XMLCALL namePush ( xmlParserCtxtPtr  ctxt,
const xmlChar value 
)

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

Definition at line 1950 of file parser.c.

1951{
1952 if (ctxt == NULL) return (-1);
1953
1954 if (ctxt->nameNr >= ctxt->nameMax) {
1955 const xmlChar * *tmp;
1956 tmp = (const xmlChar * *) xmlRealloc((xmlChar * *)ctxt->nameTab,
1957 ctxt->nameMax * 2 *
1958 sizeof(ctxt->nameTab[0]));
1959 if (tmp == NULL) {
1960 goto mem_error;
1961 }
1962 ctxt->nameTab = tmp;
1963 ctxt->nameMax *= 2;
1964 }
1965 ctxt->nameTab[ctxt->nameNr] = value;
1966 ctxt->name = value;
1967 return (ctxt->nameNr++);
1968mem_error:
1969 xmlErrMemory(ctxt, NULL);
1970 return (-1);
1971}

◆ nodePop()

nodePop: @ctxt: an XML parser context

Pops the top element node from the node stack

Returns the node just removed

Definition at line 1839 of file parser.c.

1840{
1842
1843 if (ctxt == NULL) return(NULL);
1844 if (ctxt->nodeNr <= 0)
1845 return (NULL);
1846 ctxt->nodeNr--;
1847 if (ctxt->nodeNr > 0)
1848 ctxt->node = ctxt->nodeTab[ctxt->nodeNr - 1];
1849 else
1850 ctxt->node = NULL;
1851 ret = ctxt->nodeTab[ctxt->nodeNr];
1852 ctxt->nodeTab[ctxt->nodeNr] = NULL;
1853 return (ret);
1854}
Definition: tree.h:489
xmlNodePtr * nodeTab
Definition: parser.h:208
xmlNodePtr node
Definition: parser.h:205

Referenced by xmlParseElementStart(), and xmlSAX2EndElementNs().

◆ nodePush()

XMLPUBFUN int XMLCALL nodePush ( xmlParserCtxtPtr  ctxt,
xmlNodePtr  value 
)

nodePush: @ctxt: an XML parser context @value: the element node

Pushes a new element node on top of the node stack

Returns -1 in case of error, the index in the stack otherwise

Definition at line 1801 of file parser.c.

1802{
1803 if (ctxt == NULL) return(0);
1804 if (ctxt->nodeNr >= ctxt->nodeMax) {
1805 xmlNodePtr *tmp;
1806
1807 tmp = (xmlNodePtr *) xmlRealloc(ctxt->nodeTab,
1808 ctxt->nodeMax * 2 *
1809 sizeof(ctxt->nodeTab[0]));
1810 if (tmp == NULL) {
1811 xmlErrMemory(ctxt, NULL);
1812 return (-1);
1813 }
1814 ctxt->nodeTab = tmp;
1815 ctxt->nodeMax *= 2;
1816 }
1817 if ((((unsigned int) ctxt->nodeNr) > xmlParserMaxDepth) &&
1818 ((ctxt->options & XML_PARSE_HUGE) == 0)) {
1819 xmlFatalErrMsgInt(ctxt, XML_ERR_INTERNAL_ERROR,
1820 "Excessive depth in document: %d use XML_PARSE_HUGE option\n",
1822 xmlHaltParser(ctxt);
1823 return(-1);
1824 }
1825 ctxt->nodeTab[ctxt->nodeNr] = value;
1826 ctxt->node = value;
1827 return (ctxt->nodeNr++);
1828}
@ XML_PARSE_HUGE
Definition: parser.h:1114
unsigned int xmlParserMaxDepth
Definition: parser.c:270
static void xmlHaltParser(xmlParserCtxtPtr ctxt)
Definition: parser.c:12549
@ XML_ERR_INTERNAL_ERROR
Definition: xmlerror.h:101

Referenced by xmlParseBalancedChunkMemoryInternal(), xmlParseExternalEntityPrivate(), xmlParseInNodeContext(), and xmlSAX2StartElementNs().

◆ xmlCheckLanguageID()

XMLPUBFUN int XMLCALL xmlCheckLanguageID ( const xmlChar lang)

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])+

The current REC reference the successors of RFC 1766, currently 5646

http://www.rfc-editor.org/rfc/rfc5646.txt langtag = language ["-" script] ["-" region] *("-" variant) *("-" extension) ["-" privateuse] language = 2*3ALPHA ; shortest ISO 639 code ["-" extlang] ; sometimes followed by ; extended language subtags / 4ALPHA ; or reserved for future use / 5*8ALPHA ; or registered language subtag

extlang = 3ALPHA ; selected ISO 639 codes *2("-" 3ALPHA) ; permanently reserved

script = 4ALPHA ; ISO 15924 code

region = 2ALPHA ; ISO 3166-1 code / 3DIGIT ; UN M.49 code

variant = 5*8alphanum ; registered variants / (DIGIT 3alphanum)

extension = singleton 1*("-" (2*8alphanum))

                                ; Single alphanumerics
                                ; "x" reserved for private use

singleton = DIGIT ; 0 - 9 / x41-57 ; A - W / x59-5A ; Y - Z / x61-77 ; a - w / x79-7A ; y - z

it sounds right to still allow Irregular i-xxx IANA and user codes too The parser below doesn't try to cope with extension or privateuse that could be added but that's not interoperable anyway

Returns 1 if correct 0 otherwise

Definition at line 1474 of file parser.c.

1475{
1476 const xmlChar *cur = lang, *nxt;
1477
1478 if (cur == NULL)
1479 return (0);
1480 if (((cur[0] == 'i') && (cur[1] == '-')) ||
1481 ((cur[0] == 'I') && (cur[1] == '-')) ||
1482 ((cur[0] == 'x') && (cur[1] == '-')) ||
1483 ((cur[0] == 'X') && (cur[1] == '-'))) {
1484 /*
1485 * Still allow IANA code and user code which were coming
1486 * from the previous version of the XML-1.0 specification
1487 * it's deprecated but we should not fail
1488 */
1489 cur += 2;
1490 while (((cur[0] >= 'A') && (cur[0] <= 'Z')) ||
1491 ((cur[0] >= 'a') && (cur[0] <= 'z')))
1492 cur++;
1493 return(cur[0] == 0);
1494 }
1495 nxt = cur;
1496 while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) ||
1497 ((nxt[0] >= 'a') && (nxt[0] <= 'z')))
1498 nxt++;
1499 if (nxt - cur >= 4) {
1500 /*
1501 * Reserved
1502 */
1503 if ((nxt - cur > 8) || (nxt[0] != 0))
1504 return(0);
1505 return(1);
1506 }
1507 if (nxt - cur < 2)
1508 return(0);
1509 /* we got an ISO 639 code */
1510 if (nxt[0] == 0)
1511 return(1);
1512 if (nxt[0] != '-')
1513 return(0);
1514
1515 nxt++;
1516 cur = nxt;
1517 /* now we can have extlang or script or region or variant */
1518 if ((nxt[0] >= '0') && (nxt[0] <= '9'))
1519 goto region_m49;
1520
1521 while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) ||
1522 ((nxt[0] >= 'a') && (nxt[0] <= 'z')))
1523 nxt++;
1524 if (nxt - cur == 4)
1525 goto script;
1526 if (nxt - cur == 2)
1527 goto region;
1528 if ((nxt - cur >= 5) && (nxt - cur <= 8))
1529 goto variant;
1530 if (nxt - cur != 3)
1531 return(0);
1532 /* we parsed an extlang */
1533 if (nxt[0] == 0)
1534 return(1);
1535 if (nxt[0] != '-')
1536 return(0);
1537
1538 nxt++;
1539 cur = nxt;
1540 /* now we can have script or region or variant */
1541 if ((nxt[0] >= '0') && (nxt[0] <= '9'))
1542 goto region_m49;
1543
1544 while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) ||
1545 ((nxt[0] >= 'a') && (nxt[0] <= 'z')))
1546 nxt++;
1547 if (nxt - cur == 2)
1548 goto region;
1549 if ((nxt - cur >= 5) && (nxt - cur <= 8))
1550 goto variant;
1551 if (nxt - cur != 4)
1552 return(0);
1553 /* we parsed a script */
1554script:
1555 if (nxt[0] == 0)
1556 return(1);
1557 if (nxt[0] != '-')
1558 return(0);
1559
1560 nxt++;
1561 cur = nxt;
1562 /* now we can have region or variant */
1563 if ((nxt[0] >= '0') && (nxt[0] <= '9'))
1564 goto region_m49;
1565
1566 while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) ||
1567 ((nxt[0] >= 'a') && (nxt[0] <= 'z')))
1568 nxt++;
1569
1570 if ((nxt - cur >= 5) && (nxt - cur <= 8))
1571 goto variant;
1572 if (nxt - cur != 2)
1573 return(0);
1574 /* we parsed a region */
1575region:
1576 if (nxt[0] == 0)
1577 return(1);
1578 if (nxt[0] != '-')
1579 return(0);
1580
1581 nxt++;
1582 cur = nxt;
1583 /* now we can just have a variant */
1584 while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) ||
1585 ((nxt[0] >= 'a') && (nxt[0] <= 'z')))
1586 nxt++;
1587
1588 if ((nxt - cur < 5) || (nxt - cur > 8))
1589 return(0);
1590
1591 /* we parsed a variant */
1592variant:
1593 if (nxt[0] == 0)
1594 return(1);
1595 if (nxt[0] != '-')
1596 return(0);
1597 /* extensions and private use subtags not checked */
1598 return (1);
1599
1600region_m49:
1601 if (((nxt[1] >= '0') && (nxt[1] <= '9')) &&
1602 ((nxt[2] >= '0') && (nxt[2] <= '9'))) {
1603 nxt += 3;
1604 goto region;
1605 }
1606 return(0);
1607}
FxCollectionEntry * cur
script
Definition: msipriv.h:383
static const WCHAR lang[]
Definition: wbemdisp.c:287

Referenced by xmlParseAttribute2().

◆ xmlCopyChar()

XMLPUBFUN int XMLCALL xmlCopyChar ( int len  ATTRIBUTE_UNUSED,
xmlChar out,
int  val 
)

xmlCopyChar: @len: Ignored, compatibility @out: pointer to an array of xmlChar @val: the char value

append the char value in the array

Returns the number of xmlChar written

Definition at line 852 of file parserInternals.c.

852 {
853 if (out == NULL) return(0);
854 /* the len parameter is ignored */
855 if (val >= 0x80) {
856 return(xmlCopyCharMultiByte (out, val));
857 }
858 *out = (xmlChar) val;
859 return 1;
860}
GLuint GLfloat * val
Definition: glext.h:7180
int xmlCopyCharMultiByte(xmlChar *out, int val)
static FILE * out
Definition: regtests2xml.c:44

Referenced by xmlParseAttValueComplex().

◆ xmlCopyCharMultiByte()

XMLPUBFUN int XMLCALL xmlCopyCharMultiByte ( xmlChar out,
int  val 
)

xmlCopyCharMultiByte: @out: pointer to an array of xmlChar @val: the char value

append the char value in the array

Returns the number of xmlChar written

Definition at line 809 of file parserInternals.c.

809 {
810 if (out == NULL) return(0);
811 /*
812 * We are supposed to handle UTF8, check it's valid
813 * From rfc2044: encoding of the Unicode values on UTF-8:
814 *
815 * UCS-4 range (hex.) UTF-8 octet sequence (binary)
816 * 0000 0000-0000 007F 0xxxxxxx
817 * 0000 0080-0000 07FF 110xxxxx 10xxxxxx
818 * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx
819 */
820 if (val >= 0x80) {
821 xmlChar *savedout = out;
822 int bits;
823 if (val < 0x800) { *out++= (val >> 6) | 0xC0; bits= 0; }
824 else if (val < 0x10000) { *out++= (val >> 12) | 0xE0; bits= 6;}
825 else if (val < 0x110000) { *out++= (val >> 18) | 0xF0; bits= 12; }
826 else {
827 xmlErrEncodingInt(NULL, XML_ERR_INVALID_CHAR,
828 "Internal error, xmlCopyCharMultiByte 0x%X out of bound\n",
829 val);
830 return(0);
831 }
832 for ( ; bits >= 0; bits-= 6)
833 *out++= ((val >> bits) & 0x3F) | 0x80 ;
834 return (out - savedout);
835 }
836 *out = (xmlChar) val;
837 return 1;
838}
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
#define bits
Definition: infblock.c:15
@ XML_ERR_INVALID_CHAR
Definition: xmlerror.h:109

Referenced by xmlCopyChar(), and xsltNumberFormatDecimal().

◆ xmlCreateEntityParserCtxt()

XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlCreateEntityParserCtxt ( const xmlChar URL,
const xmlChar ID,
const xmlChar base 
)

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 Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time.

Returns the new parser context or NULL

Definition at line 14027 of file parser.c.

14028 {
14030
14031}
#define ID
Definition: ruserpass.c:36
static xmlParserCtxtPtr xmlCreateEntityParserCtxtInternal(const xmlChar *URL, const xmlChar *ID, const xmlChar *base, xmlParserCtxtPtr pctx)
Definition: parser.c:13954

◆ xmlCreateFileParserCtxt()

XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlCreateFileParserCtxt ( const char filename)

Parser context.

xmlCreateFileParserCtxt: @filename: the filename

Create a parser context for a file content. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time.

Returns the new parser context or NULL

Definition at line 14093 of file parser.c.

14094{
14095 return(xmlCreateURLParserCtxt(filename, 0));
14096}
const char * filename
Definition: ioapi.h:137
xmlParserCtxtPtr xmlCreateURLParserCtxt(const char *filename, int options)
Definition: parser.c:14051

◆ xmlCreateMemoryParserCtxt()

XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlCreateMemoryParserCtxt ( const char buffer,
int  size 
)

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

Definition at line 14339 of file parser.c.

14339 {
14340 xmlParserCtxtPtr ctxt;
14343
14344 if (buffer == NULL)
14345 return(NULL);
14346 if (size <= 0)
14347 return(NULL);
14348
14349 ctxt = xmlNewParserCtxt();
14350 if (ctxt == NULL)
14351 return(NULL);
14352
14353 /* TODO: xmlParserInputBufferCreateStatic, requires some serious changes */
14355 if (buf == NULL) {
14356 xmlFreeParserCtxt(ctxt);
14357 return(NULL);
14358 }
14359
14360 input = xmlNewInputStream(ctxt);
14361 if (input == NULL) {
14363 xmlFreeParserCtxt(ctxt);
14364 return(NULL);
14365 }
14366
14367 input->filename = NULL;
14368 input->buf = buf;
14369 xmlBufResetInput(input->buf->buffer, input);
14370
14371 inputPush(ctxt, input);
14372 return(ctxt);
14373}
int xmlBufResetInput(xmlBufPtr buf, xmlParserInputPtr input)
Definition: buf.c:1094
@ XML_CHAR_ENCODING_NONE
Definition: encoding.h:58
GLsizeiptr size
Definition: glext.h:5919
GLuint buffer
Definition: glext.h:5915
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLenum GLenum input
Definition: glext.h:9031
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewInputStream(xmlParserCtxtPtr ctxt)
XMLPUBFUN void XMLCALL xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlNewParserCtxt(void)
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1745
XMLPUBFUN void XMLCALL xmlFreeParserInputBuffer(xmlParserInputBufferPtr in)
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateMem(const char *mem, int size, xmlCharEncoding enc)

Referenced by xmlCreateDocParserCtxt(), xmlParseBalancedChunkMemoryInternal(), xmlParseInNodeContext(), and xmlReadMemory().

◆ xmlCreateURLParserCtxt()

XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlCreateURLParserCtxt ( const char filename,
int  options 
)

xmlCreateURLParserCtxt: @filename: the filename or URL @options: a combination of xmlParserOption

Create a parser context for a file or URL content. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time and for file accesses

Returns the new parser context or NULL

Definition at line 14051 of file parser.c.

14052{
14053 xmlParserCtxtPtr ctxt;
14054 xmlParserInputPtr inputStream;
14055 char *directory = NULL;
14056
14057 ctxt = xmlNewParserCtxt();
14058 if (ctxt == NULL) {
14059 xmlErrMemory(NULL, "cannot allocate parser context");
14060 return(NULL);
14061 }
14062
14063 if (options)
14065 ctxt->linenumbers = 1;
14066
14067 inputStream = xmlLoadExternalEntity(filename, NULL, ctxt);
14068 if (inputStream == NULL) {
14069 xmlFreeParserCtxt(ctxt);
14070 return(NULL);
14071 }
14072
14073 inputPush(ctxt, inputStream);
14074 if ((ctxt->directory == NULL) && (directory == NULL))
14076 if ((ctxt->directory == NULL) && (directory != NULL))
14077 ctxt->directory = directory;
14078
14079 return(ctxt);
14080}
XMLPUBFUN xmlParserInputPtr XMLCALL xmlLoadExternalEntity(const char *URL, const char *ID, xmlParserCtxtPtr ctxt)
static int xmlCtxtUseOptionsInternal(xmlParserCtxtPtr ctxt, int options, const char *encoding)
Definition: parser.c:15000
char * directory
Definition: parser.h:226
int linenumbers
Definition: parser.h:259
XMLPUBFUN char *XMLCALL xmlParserGetDirectory(const char *filename)

Referenced by xmlCreateFileParserCtxt(), and xmlReadFile().

◆ xmlCurrentChar()

XMLPUBFUN int XMLCALL xmlCurrentChar ( xmlParserCtxtPtr  ctxt,
int len 
)

xmlCurrentChar: @ctxt: the XML parser context @len: pointer to the length of the char read

The current char value, if using UTF-8 this may actually span multiple bytes in the input buffer. Implement the end of line normalization: 2.11 End-of-Line Handling Wherever an external parsed entity or the literal entity value of an internal parsed entity contains either the literal two-character sequence "#xD#xA" or a standalone literal #xD, an XML processor must pass to the application the single character #xA. This behavior can conveniently be produced by normalizing all line breaks to #xA on input, before parsing.)

Returns the current char value and its length

Definition at line 542 of file parserInternals.c.

542 {
543 if ((ctxt == NULL) || (len == NULL) || (ctxt->input == NULL)) return(0);
544 if (ctxt->instate == XML_PARSER_EOF)
545 return(0);
546
547 if ((*ctxt->input->cur >= 0x20) && (*ctxt->input->cur <= 0x7F)) {
548 *len = 1;
549 return((int) *ctxt->input->cur);
550 }
551 if (ctxt->charset == XML_CHAR_ENCODING_UTF8) {
552 /*
553 * We are supposed to handle UTF8, check it's valid
554 * From rfc2044: encoding of the Unicode values on UTF-8:
555 *
556 * UCS-4 range (hex.) UTF-8 octet sequence (binary)
557 * 0000 0000-0000 007F 0xxxxxxx
558 * 0000 0080-0000 07FF 110xxxxx 10xxxxxx
559 * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx
560 *
561 * Check for the 0x110000 limit too
562 */
563 const unsigned char *cur = ctxt->input->cur;
564 unsigned char c;
565 unsigned int val;
566
567 c = *cur;
568 if (c & 0x80) {
569 if (((c & 0x40) == 0) || (c == 0xC0))
570 goto encoding_error;
571 if (cur[1] == 0) {
573 cur = ctxt->input->cur;
574 }
575 if ((cur[1] & 0xc0) != 0x80)
576 goto encoding_error;
577 if ((c & 0xe0) == 0xe0) {
578 if (cur[2] == 0) {
580 cur = ctxt->input->cur;
581 }
582 if ((cur[2] & 0xc0) != 0x80)
583 goto encoding_error;
584 if ((c & 0xf0) == 0xf0) {
585 if (cur[3] == 0) {
587 cur = ctxt->input->cur;
588 }
589 if (((c & 0xf8) != 0xf0) ||
590 ((cur[3] & 0xc0) != 0x80))
591 goto encoding_error;
592 /* 4-byte code */
593 *len = 4;
594 val = (cur[0] & 0x7) << 18;
595 val |= (cur[1] & 0x3f) << 12;
596 val |= (cur[2] & 0x3f) << 6;
597 val |= cur[3] & 0x3f;
598 if (val < 0x10000)
599 goto encoding_error;
600 } else {
601 /* 3-byte code */
602 *len = 3;
603 val = (cur[0] & 0xf) << 12;
604 val |= (cur[1] & 0x3f) << 6;
605 val |= cur[2] & 0x3f;
606 if (val < 0x800)
607 goto encoding_error;
608 }
609 } else {
610 /* 2-byte code */
611 *len = 2;
612 val = (cur[0] & 0x1f) << 6;
613 val |= cur[1] & 0x3f;
614 if (val < 0x80)
615 goto encoding_error;
616 }
617 if (!IS_CHAR(val)) {
618 xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR,
619 "Char 0x%X out of allowed range\n", val);
620 }
621 return(val);
622 } else {
623 /* 1-byte code */
624 *len = 1;
625 if (*ctxt->input->cur == 0)
627 if ((*ctxt->input->cur == 0) &&
628 (ctxt->input->end > ctxt->input->cur)) {
629 xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR,
630 "Char 0x0 out of allowed range\n", 0);
631 }
632 if (*ctxt->input->cur == 0xD) {
633 if (ctxt->input->cur[1] == 0xA) {
634 ctxt->input->cur++;
635 }
636 return(0xA);
637 }
638 return((int) *ctxt->input->cur);
639 }
640 }
641 /*
642 * Assume it's a fixed length encoding (1) with
643 * a compatible encoding for the ASCII set, since
644 * XML constructs only use < 128 chars
645 */
646 *len = 1;
647 if (*ctxt->input->cur == 0xD) {
648 if (ctxt->input->cur[1] == 0xA) {
649 ctxt->input->cur++;
650 }
651 return(0xA);
652 }
653 return((int) *ctxt->input->cur);
654encoding_error:
655 /*
656 * An encoding problem may arise from a truncated input buffer
657 * splitting a character in the middle. In that case do not raise
658 * an error but return 0 to indicate an end of stream problem
659 */
660 if (ctxt->input->end - ctxt->input->cur < 4) {
661 *len = 0;
662 return(0);
663 }
664
665 /*
666 * If we detect an UTF8 error that probably mean that the
667 * input encoding didn't get properly advertised in the
668 * declaration header. Report the error and switch the encoding
669 * to ISO-Latin-1 (if you don't like this policy, just declare the
670 * encoding !)
671 */
672 {
673 char buffer[150];
674
675 snprintf(&buffer[0], 149, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
676 ctxt->input->cur[0], ctxt->input->cur[1],
677 ctxt->input->cur[2], ctxt->input->cur[3]);
679 "Input is not proper UTF-8, indicate encoding !\n%s",
681 }
683 *len = 1;
684 return((int) *ctxt->input->cur);
685}
@ XML_CHAR_ENCODING_UTF8
Definition: encoding.h:59
@ XML_CHAR_ENCODING_8859_1
Definition: encoding.h:68
GLenum GLsizei len
Definition: glext.h:6722
void __xmlErrEncoding(xmlParserCtxtPtr ctxt, xmlParserErrors xmlerr, const char *msg, const xmlChar *str1, const xmlChar *str2)
int xmlParserInputGrow(xmlParserInputPtr in, int len)
#define IS_CHAR(c)
#define INPUT_CHUNK
@ XML_PARSER_EOF
Definition: parser.h:111
xmlParserInputState instate
Definition: parser.h:223
const xmlChar * end
Definition: parser.h:60
const xmlChar * cur
Definition: parser.h:59
#define snprintf
Definition: wintirpc.h:48
#define BAD_CAST
Definition: xmlstring.h:35

◆ xmlFreeInputStream()

XMLPUBFUN void XMLCALL xmlFreeInputStream ( xmlParserInputPtr  input)

xmlFreeInputStream: @input: an xmlParserInputPtr

Free up an input stream.

Definition at line 1192 of file parserInternals.c.

1192 {
1193 if (input == NULL) return;
1194
1195 if (input->filename != NULL) xmlFree((char *) input->filename);
1196 if (input->directory != NULL) xmlFree((char *) input->directory);
1197 if (input->encoding != NULL) xmlFree((char *) input->encoding);
1198 if (input->version != NULL) xmlFree((char *) input->version);
1199 if ((input->free != NULL) && (input->base != NULL))
1200 input->free((xmlChar *) input->base);
1201 if (input->buf != NULL)
1203 xmlFree(input);
1204}
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:251

Referenced by xmlCtxtReset(), xmlFreeParserCtxt(), xmlHaltParser(), xmlInitParserCtxt(), xmlLoadEntityContent(), xmlParsePEReference(), xmlPopInput(), xmlPushInput(), and xmlSAX2ExternalSubset().

◆ xmlIsLetter()

XMLPUBFUN int XMLCALL xmlIsLetter ( int  c)

xmlIsLetter: : an unicode character (int)

Check whether the character is allowed by the production [84] Letter ::= BaseChar | Ideographic

Returns 0 if not, non-zero otherwise

Definition at line 213 of file parserInternals.c.

213 {
214 return(IS_BASECHAR(c) || IS_IDEOGRAPHIC(c));
215}
#define IS_IDEOGRAPHIC(c)
#define IS_BASECHAR(c)

◆ xmlNewEntityInputStream()

XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewEntityInputStream ( xmlParserCtxtPtr  ctxt,
xmlEntityPtr  entity 
)

xmlNewEntityInputStream: @ctxt: an XML parser context @entity: an Entity pointer

Create a new input stream based on an xmlEntityPtr

Returns the new input stream or NULL

Definition at line 1283 of file parserInternals.c.

1283 {
1285
1286 if (entity == NULL) {
1287 xmlErrInternal(ctxt, "xmlNewEntityInputStream entity = NULL\n",
1288 NULL);
1289 return(NULL);
1290 }
1293 "new input from entity: %s\n", entity->name);
1294 if (entity->content == NULL) {
1295 switch (entity->etype) {
1297 xmlErrInternal(ctxt, "Cannot parse entity %s\n",
1298 entity->name);
1299 break;
1302 return(xmlLoadExternalEntity((char *) entity->URI,
1303 (char *) entity->ExternalID, ctxt));
1305 xmlErrInternal(ctxt,
1306 "Internal entity %s without content !\n",
1307 entity->name);
1308 break;
1310 xmlErrInternal(ctxt,
1311 "Internal parameter entity %s without content !\n",
1312 entity->name);
1313 break;
1315 xmlErrInternal(ctxt,
1316 "Predefined entity %s without content !\n",
1317 entity->name);
1318 break;
1319 }
1320 return(NULL);
1321 }
1322 input = xmlNewInputStream(ctxt);
1323 if (input == NULL) {
1324 return(NULL);
1325 }
1326 if (entity->URI != NULL)
1327 input->filename = (char *) xmlStrdup((xmlChar *) entity->URI);
1328 input->base = entity->content;
1329 if (entity->length == 0)
1330 entity->length = xmlStrlen(entity->content);
1331 input->cur = entity->content;
1332 input->length = entity->length;
1333 input->end = &entity->content[input->length];
1334 return(input);
1335}
@ XML_EXTERNAL_GENERAL_PARSED_ENTITY
Definition: entities.h:26
@ XML_INTERNAL_PREDEFINED_ENTITY
Definition: entities.h:30
@ XML_EXTERNAL_GENERAL_UNPARSED_ENTITY
Definition: entities.h:27
@ XML_INTERNAL_GENERAL_ENTITY
Definition: entities.h:25
@ XML_INTERNAL_PARAMETER_ENTITY
Definition: entities.h:28
@ XML_EXTERNAL_PARAMETER_ENTITY
Definition: entities.h:29
xmlParserInputPtr xmlNewInputStream(xmlParserCtxtPtr ctxt)
XMLPUBVAR int xmlParserDebugEntities
Definition: globals.h:423
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:353
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:337
Definition: actctx.c:448
WCHAR * name
Definition: actctx.c:465
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:67
XMLPUBFUN int XMLCALL xmlStrlen(const xmlChar *str)
Definition: xmlstring.c:426

Referenced by xmlLoadEntityContent(), and xmlParsePEReference().

◆ xmlNewInputFromFile()

XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewInputFromFile ( xmlParserCtxtPtr  ctxt,
const char filename 
)

xmlNewInputFromFile: @ctxt: an XML parser context @filename: the filename to use as entity

Create a new input stream based on a file or an URL.

Returns the new input stream or NULL in case of error

Definition at line 1379 of file parserInternals.c.

1379 {
1381 xmlParserInputPtr inputStream;
1382 char *directory = NULL;
1383 xmlChar *URI = NULL;
1384
1387 "new input from file: %s\n", filename);
1388 if (ctxt == NULL) return(NULL);
1390 if (buf == NULL) {
1391 if (filename == NULL)
1392 __xmlLoaderErr(ctxt,
1393 "failed to load external entity: NULL filename \n",
1394 NULL);
1395 else
1396 __xmlLoaderErr(ctxt, "failed to load external entity \"%s\"\n",
1397 (const char *) filename);
1398 return(NULL);
1399 }
1400
1401 inputStream = xmlNewInputStream(ctxt);
1402 if (inputStream == NULL) {
1404 return(NULL);
1405 }
1406
1407 inputStream->buf = buf;
1408 inputStream = xmlCheckHTTPInput(ctxt, inputStream);
1409 if (inputStream == NULL)
1410 return(NULL);
1411
1412 if (inputStream->filename == NULL)
1413 URI = xmlStrdup((xmlChar *) filename);
1414 else
1415 URI = xmlStrdup((xmlChar *) inputStream->filename);
1416 directory = xmlParserGetDirectory((const char *) URI);
1417 if (inputStream->filename != NULL) xmlFree((char *)inputStream->filename);
1418 inputStream->filename = (char *) xmlCanonicPath((const xmlChar *) URI);
1419 if (URI != NULL) xmlFree((char *) URI);
1420 inputStream->directory = directory;
1421
1422 xmlBufResetInput(inputStream->buf->buffer, inputStream);
1423 if ((ctxt->directory == NULL) && (directory != NULL))
1424 ctxt->directory = (char *) xmlStrdup((const xmlChar *) directory);
1425 return(inputStream);
1426}
void __xmlLoaderErr(void *ctx, const char *msg, const char *filename) LIBXML_ATTR_FORMAT(2
xmlBufPtr buffer
Definition: xmlIO.h:132
const char * filename
Definition: parser.h:56
xmlParserInputBufferPtr buf
Definition: parser.h:54
const char * directory
Definition: parser.h:57
XMLPUBFUN xmlChar *XMLCALL xmlCanonicPath(const xmlChar *path)
Definition: uri.c:2380
XMLPUBFUN xmlParserInputPtr XMLCALL xmlCheckHTTPInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr ret)
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc)

◆ xmlNewInputStream()

XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewInputStream ( xmlParserCtxtPtr  ctxt)

xmlNewInputStream: @ctxt: an XML parser context

Create a new input stream structure.

Returns the new input stream or NULL

Definition at line 1215 of file parserInternals.c.

1215 {
1217
1219 if (input == NULL) {
1220 xmlErrMemory(ctxt, "couldn't allocate a new input stream\n");
1221 return(NULL);
1222 }
1223 memset(input, 0, sizeof(xmlParserInput));
1224 input->line = 1;
1225 input->col = 1;
1226 input->standalone = -1;
1227
1228 /*
1229 * If the context is NULL the id cannot be initialized, but that
1230 * should not happen while parsing which is the situation where
1231 * the id is actually needed.
1232 */
1233 if (ctxt != NULL)
1234 input->id = ctxt->input_id++;
1235
1236 return(input);
1237}
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:248
xmlParserInput * xmlParserInputPtr
Definition: tree.h:36
#define memset(x, y, z)
Definition: compat.h:39
int input_id
Definition: parser.h:312

Referenced by xmlCreateMemoryParserCtxt(), xmlCtxtResetPush(), xmlNewEntityInputStream(), xmlNewInputFromFile(), xmlNewIOInputStream(), and xmlNewStringInputStream().

◆ xmlNewStringInputStream()

XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewStringInputStream ( xmlParserCtxtPtr  ctxt,
const xmlChar buffer 
)

Input Streams.

xmlNewStringInputStream: @ctxt: an XML parser context @buffer: an memory buffer

Create a new input stream based on a memory buffer. Returns the new input stream

Definition at line 1346 of file parserInternals.c.

1346 {
1348
1349 if (buffer == NULL) {
1350 xmlErrInternal(ctxt, "xmlNewStringInputStream string = NULL\n",
1351 NULL);
1352 return(NULL);
1353 }
1356 "new fixed input: %.30s\n", buffer);
1357 input = xmlNewInputStream(ctxt);
1358 if (input == NULL) {
1359 xmlErrMemory(ctxt, "couldn't allocate a new input stream\n");
1360 return(NULL);
1361 }
1362 input->base = buffer;
1363 input->cur = buffer;
1364 input->length = xmlStrlen(buffer);
1365 input->end = &buffer[input->length];
1366 return(input);
1367}

◆ xmlNextChar()

XMLPUBFUN void XMLCALL xmlNextChar ( xmlParserCtxtPtr  ctxt)

xmlNextChar: @ctxt: the XML parser context

Skip to the next char input char.

Definition at line 380 of file parserInternals.c.

381{
382 if ((ctxt == NULL) || (ctxt->instate == XML_PARSER_EOF) ||
383 (ctxt->input == NULL))
384 return;
385
386 if (!(VALID_CTXT(ctxt))) {
387 xmlErrInternal(ctxt, "Parser input data memory error\n", NULL);
389 xmlStopParser(ctxt);
390 return;
391 }
392
393 if ((*ctxt->input->cur == 0) &&
394 (xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0)) {
395 return;
396 }
397
398 if (ctxt->charset == XML_CHAR_ENCODING_UTF8) {
399 const unsigned char *cur;
400 unsigned char c;
401
402 /*
403 * 2.11 End-of-Line Handling
404 * the literal two-character sequence "#xD#xA" or a standalone
405 * literal #xD, an XML processor must pass to the application
406 * the single character #xA.
407 */
408 if (*(ctxt->input->cur) == '\n') {
409 ctxt->input->line++; ctxt->input->col = 1;
410 } else
411 ctxt->input->col++;
412
413 /*
414 * We are supposed to handle UTF8, check it's valid
415 * From rfc2044: encoding of the Unicode values on UTF-8:
416 *
417 * UCS-4 range (hex.) UTF-8 octet sequence (binary)
418 * 0000 0000-0000 007F 0xxxxxxx
419 * 0000 0080-0000 07FF 110xxxxx 10xxxxxx
420 * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx
421 *
422 * Check for the 0x110000 limit too
423 */
424 cur = ctxt->input->cur;
425
426 c = *cur;
427 if (c & 0x80) {
428 if (c == 0xC0)
429 goto encoding_error;
430 if (cur[1] == 0) {
432 cur = ctxt->input->cur;
433 }
434 if ((cur[1] & 0xc0) != 0x80)
435 goto encoding_error;
436 if ((c & 0xe0) == 0xe0) {
437 unsigned int val;
438
439 if (cur[2] == 0) {
441 cur = ctxt->input->cur;
442 }
443 if ((cur[2] & 0xc0) != 0x80)
444 goto encoding_error;
445 if ((c & 0xf0) == 0xf0) {
446 if (cur[3] == 0) {
448 cur = ctxt->input->cur;
449 }
450 if (((c & 0xf8) != 0xf0) ||
451 ((cur[3] & 0xc0) != 0x80))
452 goto encoding_error;
453 /* 4-byte code */
454 ctxt->input->cur += 4;
455 val = (cur[0] & 0x7) << 18;
456 val |= (cur[1] & 0x3f) << 12;
457 val |= (cur[2] & 0x3f) << 6;
458 val |= cur[3] & 0x3f;
459 } else {
460 /* 3-byte code */
461 ctxt->input->cur += 3;
462 val = (cur[0] & 0xf) << 12;
463 val |= (cur[1] & 0x3f) << 6;
464 val |= cur[2] & 0x3f;
465 }
466 if (((val > 0xd7ff) && (val < 0xe000)) ||
467 ((val > 0xfffd) && (val < 0x10000)) ||
468 (val >= 0x110000)) {
469 xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR,
470 "Char 0x%X out of allowed range\n",
471 val);
472 }
473 } else
474 /* 2-byte code */
475 ctxt->input->cur += 2;
476 } else
477 /* 1-byte code */
478 ctxt->input->cur++;
479 } else {
480 /*
481 * Assume it's a fixed length encoding (1) with
482 * a compatible encoding for the ASCII set, since
483 * XML constructs only use < 128 chars
484 */
485
486 if (*(ctxt->input->cur) == '\n') {
487 ctxt->input->line++; ctxt->input->col = 1;
488 } else
489 ctxt->input->col++;
490 ctxt->input->cur++;
491 }
492 if (*ctxt->input->cur == 0)
494 return;
495encoding_error:
496 /*
497 * If we detect an UTF8 error that probably mean that the
498 * input encoding didn't get properly advertised in the
499 * declaration header. Report the error and switch the encoding
500 * to ISO-Latin-1 (if you don't like this policy, just declare the
501 * encoding !)
502 */
503 if ((ctxt == NULL) || (ctxt->input == NULL) ||
504 (ctxt->input->end - ctxt->input->cur < 4)) {
506 "Input is not proper UTF-8, indicate encoding !\n",
507 NULL, NULL);
508 } else {
509 char buffer[150];
510
511 snprintf(buffer, 149, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
512 ctxt->input->cur[0], ctxt->input->cur[1],
513 ctxt->input->cur[2], ctxt->input->cur[3]);
515 "Input is not proper UTF-8, indicate encoding !\n%s",
517 }
519 ctxt->input->cur++;
520 return;
521}
#define VALID_CTXT(ctxt)
XMLPUBFUN void XMLCALL xmlStopParser(xmlParserCtxtPtr ctxt)
Definition: parser.c:12583

◆ xmlParseAttributeListDecl()

XMLPUBFUN void XMLCALL xmlParseAttributeListDecl ( xmlParserCtxtPtr  ctxt)

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

Definition at line 5976 of file parser.c.

5976 {
5977 const xmlChar *elemName;
5978 const xmlChar *attrName;
5980
5981 if (CMP9(CUR_PTR, '<', '!', 'A', 'T', 'T', 'L', 'I', 'S', 'T')) {
5982 int inputid = ctxt->input->id;
5983
5984 SKIP(9);
5985 if (SKIP_BLANKS == 0) {
5986 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5987 "Space required after '<!ATTLIST'\n");
5988 }
5989 elemName = xmlParseName(ctxt);
5990 if (elemName == NULL) {
5991 xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
5992 "ATTLIST: no name for Element\n");
5993 return;
5994 }
5996 GROW;
5997 while ((RAW != '>') && (ctxt->instate != XML_PARSER_EOF)) {
5998 int type;
5999 int def;
6000 xmlChar *defaultValue = NULL;
6001
6002 GROW;
6003 tree = NULL;
6004 attrName = xmlParseName(ctxt);
6005 if (attrName == NULL) {
6006 xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
6007 "ATTLIST: no name for Attribute\n");
6008 break;
6009 }
6010 GROW;
6011 if (SKIP_BLANKS == 0) {
6012 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
6013 "Space required after the attribute name\n");
6014 break;
6015 }
6016
6018 if (type <= 0) {
6019 break;
6020 }
6021
6022 GROW;
6023 if (SKIP_BLANKS == 0) {
6024 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
6025 "Space required after the attribute type\n");
6026 if (tree != NULL)
6028 break;
6029 }
6030
6031 def = xmlParseDefaultDecl(ctxt, &defaultValue);
6032 if (def <= 0) {
6033 if (defaultValue != NULL)
6034 xmlFree(defaultValue);
6035 if (tree != NULL)
6037 break;
6038 }
6039 if ((type != XML_ATTRIBUTE_CDATA) && (defaultValue != NULL))
6040 xmlAttrNormalizeSpace(defaultValue, defaultValue);
6041
6042 GROW;
6043 if (RAW != '>') {
6044 if (SKIP_BLANKS == 0) {
6045 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
6046 "Space required after the attribute default value\n");
6047 if (defaultValue != NULL)
6048 xmlFree(defaultValue);
6049 if (tree != NULL)
6051 break;
6052 }
6053 }
6054 if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
6055 (ctxt->sax->attributeDecl != NULL))
6056 ctxt->sax->attributeDecl(ctxt->userData, elemName, attrName,
6057 type, def, defaultValue, tree);
6058 else if (tree != NULL)
6060
6061 if ((ctxt->sax2) && (defaultValue != NULL) &&
6062 (def != XML_ATTRIBUTE_IMPLIED) &&
6063 (def != XML_ATTRIBUTE_REQUIRED)) {
6064 xmlAddDefAttrs(ctxt, elemName, attrName, defaultValue);
6065 }
6066 if (ctxt->sax2) {
6067 xmlAddSpecialAttr(ctxt, elemName, attrName, type);
6068 }
6069 if (defaultValue != NULL)
6070 xmlFree(defaultValue);
6071 GROW;
6072 }
6073 if (RAW == '>') {
6074 if (inputid != ctxt->input->id) {
6075 xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
6076 "Attribute list declaration doesn't start and"
6077 " stop in the same entity\n");
6078 }
6079 NEXT;
6080 }
6081 }
6082}
struct _tree tree
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
@ XML_ATTRIBUTE_CDATA
Definition: tree.h:207
@ XML_ATTRIBUTE_REQUIRED
Definition: tree.h:227
@ XML_ATTRIBUTE_IMPLIED
Definition: tree.h:228
int xmlParseDefaultDecl(xmlParserCtxtPtr ctxt, xmlChar **value)
Definition: parser.c:5682
static void xmlAddDefAttrs(xmlParserCtxtPtr ctxt, const xmlChar *fullname, const xmlChar *fullattr, const xmlChar *value)
Definition: parser.c:1242
#define NEXT
Definition: parser.c:2147
static xmlChar * xmlAttrNormalizeSpace(const xmlChar *src, xmlChar *dst)
Definition: parser.c:1152
const xmlChar * xmlParseName(xmlParserCtxtPtr ctxt)
Definition: parser.c:3344
#define SKIP_BLANKS
Definition: parser.c:2145
int xmlParseAttributeType(xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree)
Definition: parser.c:5934
#define RAW
Definition: parser.c:2064
#define GROW
Definition: parser.c:2117
#define CMP9(s, c1, c2, c3, c4, c5, c6, c7, c8, c9)
Definition: parser.c:2081
static void xmlAddSpecialAttr(xmlParserCtxtPtr ctxt, const xmlChar *fullname, const xmlChar *fullattr, int type)
Definition: parser.c:1353
#define SKIP(val)
Definition: parser.c:2088
#define CUR_PTR
Definition: parser.c:2067
int disableSAX
Definition: parser.h:237
struct _xmlSAXHandler * sax
Definition: parser.h:185
void * userData
Definition: parser.h:186
XMLPUBFUN void XMLCALL xmlFreeEnumeration(xmlEnumerationPtr cur)
Definition: valid.c:1817
@ XML_ERR_ENTITY_BOUNDARY
Definition: xmlerror.h:190
@ XML_ERR_SPACE_REQUIRED
Definition: xmlerror.h:165
@ XML_ERR_NAME_REQUIRED
Definition: xmlerror.h:168

Referenced by xmlParseMarkupDecl().

◆ xmlParseAttributeType()

XMLPUBFUN int XMLCALL xmlParseAttributeType ( xmlParserCtxtPtr  ctxt,
xmlEnumerationPtr tree 
)

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

Definition at line 5934 of file parser.c.

5934 {
5935 SHRINK;
5936 if (CMP5(CUR_PTR, 'C', 'D', 'A', 'T', 'A')) {
5937 SKIP(5);
5938 return(XML_ATTRIBUTE_CDATA);
5939 } else if (CMP6(CUR_PTR, 'I', 'D', 'R', 'E', 'F', 'S')) {
5940 SKIP(6);
5941 return(XML_ATTRIBUTE_IDREFS);
5942 } else if (CMP5(CUR_PTR, 'I', 'D', 'R', 'E', 'F')) {
5943 SKIP(5);
5944 return(XML_ATTRIBUTE_IDREF);
5945 } else if ((RAW == 'I') && (NXT(1) == 'D')) {
5946 SKIP(2);
5947 return(XML_ATTRIBUTE_ID);
5948 } else if (CMP6(CUR_PTR, 'E', 'N', 'T', 'I', 'T', 'Y')) {
5949 SKIP(6);
5950 return(XML_ATTRIBUTE_ENTITY);
5951 } else if (CMP8(CUR_PTR, 'E', 'N', 'T', 'I', 'T', 'I', 'E', 'S')) {
5952 SKIP(8);
5953 return(XML_ATTRIBUTE_ENTITIES);
5954 } else if (CMP8(CUR_PTR, 'N', 'M', 'T', 'O', 'K', 'E', 'N', 'S')) {
5955 SKIP(8);
5956 return(XML_ATTRIBUTE_NMTOKENS);
5957 } else if (CMP7(CUR_PTR, 'N', 'M', 'T', 'O', 'K', 'E', 'N')) {
5958 SKIP(7);
5959 return(XML_ATTRIBUTE_NMTOKEN);
5960 }
5961 return(xmlParseEnumeratedType(ctxt, tree));
5962}
@ XML_ATTRIBUTE_NMTOKENS
Definition: tree.h:214
@ XML_ATTRIBUTE_IDREF
Definition: tree.h:209
@ XML_ATTRIBUTE_ENTITIES
Definition: tree.h:212
@ XML_ATTRIBUTE_IDREFS
Definition: tree.h:210
@ XML_ATTRIBUTE_ID
Definition: tree.h:208
@ XML_ATTRIBUTE_NMTOKEN
Definition: tree.h:213
@ XML_ATTRIBUTE_ENTITY
Definition: tree.h:211
#define SHRINK
Definition: parser.c:2106
#define CMP7(s, c1, c2, c3, c4, c5, c6, c7)
Definition: parser.c:2077
int xmlParseEnumeratedType(xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree)
Definition: parser.c:5871
#define CMP5(s, c1, c2, c3, c4, c5)
Definition: parser.c:2073
#define CMP8(s, c1, c2, c3, c4, c5, c6, c7, c8)
Definition: parser.c:2079
#define CMP6(s, c1, c2, c3, c4, c5, c6)
Definition: parser.c:2075
#define NXT(val)
Definition: parser.c:2066

Referenced by xmlParseAttributeListDecl().

◆ xmlParseAttValue()

XMLPUBFUN xmlChar *XMLCALL xmlParseAttValue ( xmlParserCtxtPtr  ctxt)

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.

Definition at line 4182 of file parser.c.

4182 {
4183 if ((ctxt == NULL) || (ctxt->input == NULL)) return(NULL);
4184 return(xmlParseAttValueInternal(ctxt, NULL, NULL, 0));
4185}
static xmlChar * xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc, int normalize)
Definition: parser.c:8960

Referenced by xmlParseDefaultDecl().

◆ xmlParseCDSect()

XMLPUBFUN void XMLCALL xmlParseCDSect ( xmlParserCtxtPtr  ctxt)

xmlParseCDSect: @ctxt: an XML parser context

Parse escaped pure raw content.

[18] CDSect ::= CDStart CData CDEnd

[19] CDStart ::= ''

[20] Data ::= (Char* - (Char* '' Char*))

[21] CDEnd ::= ']]>'

Definition at line 9765 of file parser.c.

9765 {
9766 xmlChar *buf = NULL;
9767 int len = 0;
9769 int r, rl;
9770 int s, sl;
9771 int cur, l;
9772 int count = 0;
9773 int maxLength = (ctxt->options & XML_PARSE_HUGE) ?
9776
9777 /* Check 2.6.0 was NXT(0) not RAW */
9778 if (CMP9(CUR_PTR, '<', '!', '[', 'C', 'D', 'A', 'T', 'A', '[')) {
9779 SKIP(9);
9780 } else
9781 return;
9782
9784 r = CUR_CHAR(rl);
9785 if (!IS_CHAR(r)) {
9788 return;
9789 }
9790 NEXTL(rl);
9791 s = CUR_CHAR(sl);
9792 if (!IS_CHAR(s)) {
9795 return;
9796 }
9797 NEXTL(sl);
9798 cur = CUR_CHAR(l);
9799 buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
9800 if (buf == NULL) {
9801 xmlErrMemory(ctxt, NULL);
9802 return;
9803 }
9804 while (IS_CHAR(cur) &&
9805 ((r != ']') || (s != ']') || (cur != '>'))) {
9806 if (len + 5 >= size) {
9807 xmlChar *tmp;
9808
9809 tmp = (xmlChar *) xmlRealloc(buf, size * 2 * sizeof(xmlChar));
9810 if (tmp == NULL) {
9811 xmlFree(buf);
9812 xmlErrMemory(ctxt, NULL);
9813 return;
9814 }
9815 buf = tmp;
9816 size *= 2;
9817 }
9818 COPY_BUF(rl,buf,len,r);
9819 r = s;
9820 rl = sl;
9821 s = cur;
9822 sl = l;
9823 count++;
9824 if (count > 50) {
9825 SHRINK;
9826 GROW;
9827 if (ctxt->instate == XML_PARSER_EOF) {
9828 xmlFree(buf);
9829 return;
9830 }
9831 count = 0;
9832 }
9833 NEXTL(l);
9834 cur = CUR_CHAR(l);
9835 if (len > maxLength) {
9836 xmlFatalErrMsg(ctxt, XML_ERR_CDATA_NOT_FINISHED,
9837 "CData section too big found\n");
9838 xmlFree(buf);
9839 return;
9840 }
9841 }
9842 buf[len] = 0;
9844 if (cur != '>') {
9845 xmlFatalErrMsgStr(ctxt, XML_ERR_CDATA_NOT_FINISHED,
9846 "CData section not finished\n%.50s\n", buf);
9847 xmlFree(buf);
9848 return;
9849 }
9850 NEXTL(l);
9851
9852 /*
9853 * OK the buffer is to be consumed as cdata.
9854 */
9855 if ((ctxt->sax != NULL) && (!ctxt->disableSAX)) {
9856 if (ctxt->sax->cdataBlock != NULL)
9857 ctxt->sax->cdataBlock(ctxt->userData, buf, len);
9858 else if (ctxt->sax->characters != NULL)
9859 ctxt->sax->characters(ctxt->userData, buf, len);
9860 }
9861 xmlFree(buf);
9862}
r l[0]
Definition: byte_order.h:168
GLdouble s
Definition: gl.h:2039
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLsizei maxLength
Definition: glext.h:6877
#define XML_MAX_TEXT_LENGTH
XMLPUBVAR xmlMallocFunc xmlMallocAtomic
Definition: globals.h:249
@ XML_PARSER_CONTENT
Definition: parser.h:119
@ XML_PARSER_CDATA_SECTION
Definition: parser.h:120
#define NEXTL(l)
Definition: parser.c:2156
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:378
#define XML_PARSER_BUFFER_SIZE
Definition: parser.c:276
#define COPY_BUF(l, b, i, v)
Definition: parser.c:2166
#define CUR_CHAR(l)
Definition: parser.c:2163
#define XML_MAX_HUGE_LENGTH
Definition: parser.c:105
@ XML_ERR_CDATA_NOT_FINISHED
Definition: xmlerror.h:163

Referenced by xmlParseContentInternal().

◆ xmlParseCharData()

XMLPUBFUN void XMLCALL xmlParseCharData ( xmlParserCtxtPtr  ctxt,
int  cdata 
)

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 "&gt;", and must, for compatibility, be escaped using "&gt;" 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 ::= [^<&]* - ([^<&]* ']]>' [^<&]*)

Definition at line 4425 of file parser.c.

4425 {
4426 const xmlChar *in;
4427 int nbchar = 0;
4428 int line = ctxt->input->line;
4429 int col = ctxt->input->col;
4430 int ccol;
4431
4432 SHRINK;
4433 GROW;
4434 /*
4435 * Accelerated common case where input don't need to be
4436 * modified before passing it to the handler.
4437 */
4438 if (!cdata) {
4439 in = ctxt->input->cur;
4440 do {
4441get_more_space:
4442 while (*in == 0x20) { in++; ctxt->input->col++; }
4443 if (*in == 0xA) {
4444 do {
4445 ctxt->input->line++; ctxt->input->col = 1;
4446 in++;
4447 } while (*in == 0xA);
4448 goto get_more_space;
4449 }
4450 if (*in == '<') {
4451 nbchar = in - ctxt->input->cur;
4452 if (nbchar > 0) {
4453 const xmlChar *tmp = ctxt->input->cur;
4454 ctxt->input->cur = in;
4455
4456 if ((ctxt->sax != NULL) &&
4457 (ctxt->sax->ignorableWhitespace !=
4458 ctxt->sax->characters)) {
4459 if (areBlanks(ctxt, tmp, nbchar, 1)) {
4460 if (ctxt->sax->ignorableWhitespace != NULL)
4461 ctxt->sax->ignorableWhitespace(ctxt->userData,
4462 tmp, nbchar);
4463 } else {
4464 if (ctxt->sax->characters != NULL)
4465 ctxt->sax->characters(ctxt->userData,
4466 tmp, nbchar);
4467 if (*ctxt->space == -1)
4468 *ctxt->space = -2;
4469 }
4470 } else if ((ctxt->sax != NULL) &&
4471 (ctxt->sax->characters != NULL)) {
4472 ctxt->sax->characters(ctxt->userData,
4473 tmp, nbchar);
4474 }
4475 }
4476 return;
4477 }
4478
4479get_more:
4480 ccol = ctxt->input->col;
4481 while (test_char_data[*in]) {
4482 in++;
4483 ccol++;
4484 }
4485 ctxt->input->col = ccol;
4486 if (*in == 0xA) {
4487 do {
4488 ctxt->input->line++; ctxt->input->col = 1;
4489 in++;
4490 } while (*in == 0xA);
4491 goto get_more;
4492 }
4493 if (*in == ']') {
4494 if ((in[1] == ']') && (in[2] == '>')) {
4496 ctxt->input->cur = in + 1;
4497 return;
4498 }
4499 in++;
4500 ctxt->input->col++;
4501 goto get_more;
4502 }
4503 nbchar = in - ctxt->input->cur;
4504 if (nbchar > 0) {
4505 if ((ctxt->sax != NULL) &&
4506 (ctxt->sax->ignorableWhitespace !=
4507 ctxt->sax->characters) &&
4508 (IS_BLANK_CH(*ctxt->input->cur))) {
4509 const xmlChar *tmp = ctxt->input->cur;
4510 ctxt->input->cur = in;
4511
4512 if (areBlanks(ctxt, tmp, nbchar, 0)) {
4513 if (ctxt->sax->ignorableWhitespace != NULL)
4514 ctxt->sax->ignorableWhitespace(ctxt->userData,
4515 tmp, nbchar);
4516 } else {
4517 if (ctxt->sax->characters != NULL)
4518 ctxt->sax->characters(ctxt->userData,
4519 tmp, nbchar);
4520 if (*ctxt->space == -1)
4521 *ctxt->space = -2;
4522 }
4523 line = ctxt->input->line;
4524 col = ctxt->input->col;
4525 } else if (ctxt->sax != NULL) {
4526 if (ctxt->sax->characters != NULL)
4527 ctxt->sax->characters(ctxt->userData,
4528 ctxt->input->cur, nbchar);
4529 line = ctxt->input->line;
4530 col = ctxt->input->col;
4531 }
4532 /* something really bad happened in the SAX callback */
4533 if (ctxt->instate != XML_PARSER_CONTENT)
4534 return;
4535 }
4536 ctxt->input->cur = in;
4537 if (*in == 0xD) {
4538 in++;
4539 if (*in == 0xA) {
4540 ctxt->input->cur = in;
4541 in++;
4542 ctxt->input->line++; ctxt->input->col = 1;
4543 continue; /* while */
4544 }
4545 in--;
4546 }
4547 if (*in == '<') {
4548 return;
4549 }
4550 if (*in == '&') {
4551 return;
4552 }
4553 SHRINK;
4554 GROW;
4555 if (ctxt->instate == XML_PARSER_EOF)
4556 return;
4557 in = ctxt->input->cur;
4558 } while (((*in >= 0x20) && (*in <= 0x7F)) || (*in == 0x09) || (*in == 0x0a));
4559 nbchar = 0;
4560 }
4561 ctxt->input->line = line;
4562 ctxt->input->col = col;
4563 xmlParseCharDataComplex(ctxt, cdata);
4564}
GLuint in
Definition: glext.h:9616
#define IS_BLANK_CH(c)
static int areBlanks(xmlParserCtxtPtr ctxt, const xmlChar *str, int len, int blank_chars)
Definition: parser.c:2864
static void xmlParseCharDataComplex(xmlParserCtxtPtr ctxt, int cdata)
Definition: parser.c:4576
static const unsigned char test_char_data[256]
Definition: parser.c:4373
int * space
Definition: parser.h:244
Definition: parser.c:49
@ XML_ERR_MISPLACED_CDATA_END
Definition: xmlerror.h:162

Referenced by xmlParseContentInternal().

◆ xmlParseCharRef()

XMLPUBFUN int XMLCALL xmlParseCharRef ( xmlParserCtxtPtr  ctxt)

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

Definition at line 2332 of file parser.c.

2332 {
2333 int val = 0;
2334 int count = 0;
2335
2336 /*
2337 * Using RAW/CUR/NEXT is okay since we are working on ASCII range here
2338 */
2339 if ((RAW == '&') && (NXT(1) == '#') &&
2340 (NXT(2) == 'x')) {
2341 SKIP(3);
2342 GROW;
2343 while (RAW != ';') { /* loop blocked by count */
2344 if (count++ > 20) {
2345 count = 0;
2346 GROW;
2347 if (ctxt->instate == XML_PARSER_EOF)
2348 return(0);
2349 }
2350 if ((RAW >= '0') && (RAW <= '9'))
2351 val = val * 16 + (CUR - '0');
2352 else if ((RAW >= 'a') && (RAW <= 'f') && (count < 20))
2353 val = val * 16 + (CUR - 'a') + 10;
2354 else if ((RAW >= 'A') && (RAW <= 'F') && (count < 20))
2355 val = val * 16 + (CUR - 'A') + 10;
2356 else {
2358 val = 0;
2359 break;
2360 }
2361 if (val > 0x110000)
2362 val = 0x110000;
2363
2364 NEXT;
2365 count++;
2366 }
2367 if (RAW == ';') {
2368 /* on purpose to avoid reentrancy problems with NEXT and SKIP */
2369 ctxt->input->col++;
2370 ctxt->input->cur++;
2371 }
2372 } else if ((RAW == '&') && (NXT(1) == '#')) {
2373 SKIP(2);
2374 GROW;
2375 while (RAW != ';') { /* loop blocked by count */
2376 if (count++ > 20) {
2377 count = 0;
2378 GROW;
2379 if (ctxt->instate == XML_PARSER_EOF)
2380 return(0);
2381 }
2382 if ((RAW >= '0') && (RAW <= '9'))
2383 val = val * 10 + (CUR - '0');
2384 else {
2386 val = 0;
2387 break;
2388 }
2389 if (val > 0x110000)
2390 val = 0x110000;
2391
2392 NEXT;
2393 count++;
2394 }
2395 if (RAW == ';') {
2396 /* on purpose to avoid reentrancy problems with NEXT and SKIP */
2397 ctxt->input->col++;
2398 ctxt->input->cur++;
2399 }
2400 } else {
2402 }
2403
2404 /*
2405 * [ WFC: Legal Character ]
2406 * Characters referred to using character references must match the
2407 * production for Char.
2408 */
2409 if (val >= 0x110000) {
2410 xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR,
2411 "xmlParseCharRef: character reference out of bounds\n",
2412 val);
2413 } else if (IS_CHAR(val)) {
2414 return(val);
2415 } else {
2416 xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR,
2417 "xmlParseCharRef: invalid xmlChar value %d\n",
2418 val);
2419 }
2420 return(0);
2421}
#define CUR
Definition: parser.c:2065
@ XML_ERR_INVALID_CHARREF
Definition: xmlerror.h:108
@ XML_ERR_INVALID_DEC_CHARREF
Definition: xmlerror.h:107
@ XML_ERR_INVALID_HEX_CHARREF
Definition: xmlerror.h:106

Referenced by xmlParseAttValueComplex(), and xmlParseReference().

◆ xmlParseComment()

XMLPUBFUN void XMLCALL xmlParseComment ( xmlParserCtxtPtr  ctxt)

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 ::= ''

Definition at line 4888 of file parser.c.

4888 {
4889 xmlChar *buf = NULL;
4891 size_t len = 0;
4892 size_t maxLength = (ctxt->options & XML_PARSE_HUGE) ?
4896 const xmlChar *in;
4897 size_t nbchar = 0;
4898 int ccol;
4899 int inputid;
4900
4901 /*
4902 * Check that there is a comment right here.
4903 */
4904 if ((RAW != '<') || (NXT(1) != '!') ||
4905 (NXT(2) != '-') || (NXT(3) != '-')) return;
4906 state = ctxt->instate;
4908 inputid = ctxt->input->id;
4909 SKIP(4);
4910 SHRINK;
4911 GROW;
4912
4913 /*
4914 * Accelerated common case where input don't need to be
4915 * modified before passing it to the handler.
4916 */
4917 in = ctxt->input->cur;
4918 do {
4919 if (*in == 0xA) {
4920 do {
4921 ctxt->input->line++; ctxt->input->col = 1;
4922 in++;
4923 } while (*in == 0xA);
4924 }
4925get_more:
4926 ccol = ctxt->input->col;
4927 while (((*in > '-') && (*in <= 0x7F)) ||
4928 ((*in >= 0x20) && (*in < '-')) ||
4929 (*in == 0x09)) {
4930 in++;
4931 ccol++;
4932 }
4933 ctxt->input->col = ccol;
4934 if (*in == 0xA) {
4935 do {
4936 ctxt->input->line++; ctxt->input->col = 1;
4937 in++;
4938 } while (*in == 0xA);
4939 goto get_more;
4940 }
4941 nbchar = in - ctxt->input->cur;
4942 /*
4943 * save current set of data
4944 */
4945 if (nbchar > 0) {
4946 if ((ctxt->sax != NULL) &&
4947 (ctxt->sax->comment != NULL)) {
4948 if (buf == NULL) {
4949 if ((*in == '-') && (in[1] == '-'))
4950 size = nbchar + 1;
4951 else
4952 size = XML_PARSER_BUFFER_SIZE + nbchar;
4953 buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
4954 if (buf == NULL) {
4955 xmlErrMemory(ctxt, NULL);
4956 ctxt->instate = state;
4957 return;
4958 }
4959 len = 0;
4960 } else if (len + nbchar + 1 >= size) {
4961 xmlChar *new_buf;
4962 size += len + nbchar + XML_PARSER_BUFFER_SIZE;
4963 new_buf = (xmlChar *) xmlRealloc(buf,
4964 size * sizeof(xmlChar));
4965 if (new_buf == NULL) {
4966 xmlFree (buf);
4967 xmlErrMemory(ctxt, NULL);
4968 ctxt->instate = state;
4969 return;
4970 }
4971 buf = new_buf;
4972 }
4973 memcpy(&buf[len], ctxt->input->cur, nbchar);
4974 len += nbchar;
4975 buf[len] = 0;
4976 }
4977 }
4978 if (len > maxLength) {
4979 xmlFatalErrMsgStr(ctxt, XML_ERR_COMMENT_NOT_FINISHED,
4980 "Comment too big found", NULL);
4981 xmlFree (buf);
4982 return;
4983 }
4984 ctxt->input->cur = in;
4985 if (*in == 0xA) {
4986 in++;
4987 ctxt->input->line++; ctxt->input->col = 1;
4988 }
4989 if (*in == 0xD) {
4990 in++;
4991 if (*in == 0xA) {
4992 ctxt->input->cur = in;
4993 in++;
4994 ctxt->input->line++; ctxt->input->col = 1;
4995 goto get_more;
4996 }
4997 in--;
4998 }
4999 SHRINK;
5000 GROW;
5001 if (ctxt->instate == XML_PARSER_EOF) {
5002 xmlFree(buf);
5003 return;
5004 }
5005 in = ctxt->input->cur;
5006 if (*in == '-') {
5007 if (in[1] == '-') {
5008 if (in[2] == '>') {
5009 if (ctxt->input->id != inputid) {
5010 xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
5011 "comment doesn't start and stop in the"
5012 " same entity\n");
5013 }
5014 SKIP(3);
5015 if ((ctxt->sax != NULL) && (ctxt->sax->comment != NULL) &&
5016 (!ctxt->disableSAX)) {
5017 if (buf != NULL)
5018 ctxt->sax->comment(ctxt->userData, buf);
5019 else
5020 ctxt->sax->comment(ctxt->userData, BAD_CAST "");
5021 }
5022 if (buf != NULL)
5023 xmlFree(buf);
5024 if (ctxt->instate != XML_PARSER_EOF)
5025 ctxt->instate = state;
5026 return;
5027 }
5028 if (buf != NULL) {
5029 xmlFatalErrMsgStr(ctxt, XML_ERR_HYPHEN_IN_COMMENT,
5030 "Double hyphen within comment: "
5031 "<!--%.50s\n",
5032 buf);
5033 } else
5034 xmlFatalErrMsgStr(ctxt, XML_ERR_HYPHEN_IN_COMMENT,
5035 "Double hyphen within comment\n", NULL);
5036 if (ctxt->instate == XML_PARSER_EOF) {
5037 xmlFree(buf);
5038 return;
5039 }
5040 in++;
5041 ctxt->input->col++;
5042 }
5043 in++;
5044 ctxt->input->col++;
5045 goto get_more;
5046 }
5047 } while (((*in >= 0x20) && (*in <= 0x7F)) || (*in == 0x09) || (*in == 0x0a));
5049 ctxt->instate = state;
5050 return;
5051}
static int state
Definition: maze.c:121
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
xmlParserInputState
Definition: parser.h:110
@ XML_PARSER_COMMENT
Definition: parser.h:117
static void xmlParseCommentComplex(xmlParserCtxtPtr ctxt, xmlChar *buf, size_t len, size_t size)
Definition: parser.c:4750
@ XML_ERR_HYPHEN_IN_COMMENT
Definition: xmlerror.h:180
@ XML_ERR_COMMENT_NOT_FINISHED
Definition: xmlerror.h:145

Referenced by xmlParseContentInternal(), xmlParseMarkupDecl(), and xmlParseMisc().

◆ xmlParseContent()

XMLPUBFUN void XMLCALL xmlParseContent ( xmlParserCtxtPtr  ctxt)

xmlParseContent: @ctxt: an XML parser context

Parse a content sequence. Stops at EOF or '</'.

[43] content ::= (element | CharData | Reference | CDSect | PI | Comment)*

Definition at line 9958 of file parser.c.

9958 {
9959 int nameNr = ctxt->nameNr;
9960
9962
9963 if ((ctxt->instate != XML_PARSER_EOF) && (ctxt->nameNr > nameNr)) {
9964 const xmlChar *name = ctxt->nameTab[ctxt->nameNr - 1];
9965 int line = ctxt->pushTab[ctxt->nameNr - 1].line;
9966 xmlFatalErrMsgStrIntStr(ctxt, XML_ERR_TAG_NOT_FINISHED,
9967 "Premature end of data in tag %s line %d\n",
9968 name, line, NULL);
9969 }
9970}
static void xmlParseContentInternal(xmlParserCtxtPtr ctxt)
Definition: parser.c:9873
xmlStartTag * pushTab
Definition: parser.h:283
int line
Definition: parser.c:80
Definition: name.c:39
@ XML_ERR_TAG_NOT_FINISHED
Definition: xmlerror.h:177

Referenced by xmlParseBalancedChunkMemoryInternal(), xmlParseExternalEntityPrivate(), xmlParseExtParsedEnt(), and xmlParseInNodeContext().

◆ xmlParseDefaultDecl()

XMLPUBFUN int XMLCALL xmlParseDefaultDecl ( xmlParserCtxtPtr  ctxt,
xmlChar **  value 
)

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.

Definition at line 5682 of file parser.c.

5682 {
5683 int val;
5684 xmlChar *ret;
5685
5686 *value = NULL;
5687 if (CMP9(CUR_PTR, '#', 'R', 'E', 'Q', 'U', 'I', 'R', 'E', 'D')) {
5688 SKIP(9);
5689 return(XML_ATTRIBUTE_REQUIRED);
5690 }
5691 if (CMP8(CUR_PTR, '#', 'I', 'M', 'P', 'L', 'I', 'E', 'D')) {
5692 SKIP(8);
5693 return(XML_ATTRIBUTE_IMPLIED);
5694 }
5696 if (CMP6(CUR_PTR, '#', 'F', 'I', 'X', 'E', 'D')) {
5697 SKIP(6);
5699 if (SKIP_BLANKS == 0) {
5700 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5701 "Space required after '#FIXED'\n");
5702 }
5703 }
5704 ret = xmlParseAttValue(ctxt);
5705 ctxt->instate = XML_PARSER_DTD;
5706 if (ret == NULL) {
5707 xmlFatalErrMsg(ctxt, (xmlParserErrors)ctxt->errNo,
5708 "Attribute default value declaration error\n");
5709 } else
5710 *value = ret;
5711 return(val);
5712}
@ XML_PARSER_DTD
Definition: parser.h:115
@ XML_ATTRIBUTE_NONE
Definition: tree.h:226
@ XML_ATTRIBUTE_FIXED
Definition: tree.h:229
xmlChar * xmlParseAttValue(xmlParserCtxtPtr ctxt)
Definition: parser.c:4182
xmlParserErrors
Definition: xmlerror.h:99

Referenced by xmlParseAttributeListDecl().

◆ xmlParseDocTypeDecl()

XMLPUBFUN void XMLCALL xmlParseDocTypeDecl ( xmlParserCtxtPtr  ctxt)

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.

Definition at line 8282 of file parser.c.

8282 {
8283 const xmlChar *name = NULL;
8284 xmlChar *ExternalID = NULL;
8285 xmlChar *URI = NULL;
8286
8287 /*
8288 * We know that '<!DOCTYPE' has been detected.
8289 */
8290 SKIP(9);
8291
8293
8294 /*
8295 * Parse the DOCTYPE name.
8296 */
8297 name = xmlParseName(ctxt);
8298 if (name == NULL) {
8299 xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
8300 "xmlParseDocTypeDecl : no DOCTYPE name !\n");
8301 }
8302 ctxt->intSubName = name;
8303
8305
8306 /*
8307 * Check for SystemID and ExternalID
8308 */
8309 URI = xmlParseExternalID(ctxt, &ExternalID, 1);
8310
8311 if ((URI != NULL) || (ExternalID != NULL)) {
8312 ctxt->hasExternalSubset = 1;
8313 }
8314 ctxt->extSubURI = URI;
8315 ctxt->extSubSystem = ExternalID;
8316
8318
8319 /*
8320 * Create and update the internal subset.
8321 */
8322 if ((ctxt->sax != NULL) && (ctxt->sax->internalSubset != NULL) &&
8323 (!ctxt->disableSAX))
8324 ctxt->sax->internalSubset(ctxt->userData, name, ExternalID, URI);
8325 if (ctxt->instate == XML_PARSER_EOF)
8326 return;
8327
8328 /*
8329 * Is there any internal subset declarations ?
8330 * they are handled separately in xmlParseInternalSubset()
8331 */
8332 if (RAW == '[')
8333 return;
8334
8335 /*
8336 * We should be at the end of the DOCTYPE declaration.
8337 */
8338 if (RAW != '>') {
8340 }
8341 NEXT;
8342}
xmlChar * xmlParseExternalID(xmlParserCtxtPtr ctxt, xmlChar **publicID, int strict)
Definition: parser.c:4683
const xmlChar * intSubName
Definition: parser.h:239
xmlChar * extSubSystem
Definition: parser.h:241
int hasExternalSubset
Definition: parser.h:215
xmlChar * extSubURI
Definition: parser.h:240
@ XML_ERR_DOCTYPE_NOT_FINISHED
Definition: xmlerror.h:161

Referenced by xmlParseDocument().

◆ xmlParseElement()

XMLPUBFUN void XMLCALL xmlParseElement ( xmlParserCtxtPtr  ctxt)

xmlParseElement: @ctxt: an XML parser context

parse an XML element

[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.

Definition at line 9987 of file parser.c.

9987 {
9988 if (xmlParseElementStart(ctxt) != 0)
9989 return;
9990
9992 if (ctxt->instate == XML_PARSER_EOF)
9993 return;
9994
9995 if (CUR == 0) {
9996 const xmlChar *name = ctxt->nameTab[ctxt->nameNr - 1];
9997 int line = ctxt->pushTab[ctxt->nameNr - 1].line;
9998 xmlFatalErrMsgStrIntStr(ctxt, XML_ERR_TAG_NOT_FINISHED,
9999 "Premature end of data in tag %s line %d\n",
10000 name, line, NULL);
10001 return;
10002 }
10003
10004 xmlParseElementEnd(ctxt);
10005}
static int xmlParseElementStart(xmlParserCtxtPtr ctxt)
Definition: parser.c:10015
static void xmlParseElementEnd(xmlParserCtxtPtr ctxt)
Definition: parser.c:10144

Referenced by xmlParseDocument().

◆ xmlParseElementChildrenContentDecl()

XMLPUBFUN xmlElementContentPtr XMLCALL xmlParseElementChildrenContentDecl ( xmlParserCtxtPtr  ctxt,
int  inputchk 
)

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? ')'

[ VC: Proper Group/PE Nesting ] applies to [49] and [50] 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.

Definition at line 6533 of file parser.c.

6533 {
6534 /* stub left for API/ABI compat */
6535 return(xmlParseElementChildrenContentDeclPriv(ctxt, inputchk, 1));
6536}
static xmlElementContentPtr xmlParseElementChildrenContentDeclPriv(xmlParserCtxtPtr ctxt, int inputchk, int depth)
Definition: parser.c:6230

◆ xmlParseElementContentDecl()

XMLPUBFUN int XMLCALL xmlParseElementContentDecl ( xmlParserCtxtPtr  ctxt,
const xmlChar name,
xmlElementContentPtr result 
)

Definition at line 6553 of file parser.c.

6554 {
6555
6557 int inputid = ctxt->input->id;
6558 int res;
6559
6560 *result = NULL;
6561
6562 if (RAW != '(') {
6563 xmlFatalErrMsgStr(ctxt, XML_ERR_ELEMCONTENT_NOT_STARTED,
6564 "xmlParseElementContentDecl : %s '(' expected\n", name);
6565 return(-1);
6566 }
6567 NEXT;
6568 GROW;
6569 if (ctxt->instate == XML_PARSER_EOF)
6570 return(-1);
6572 if (CMP7(CUR_PTR, '#', 'P', 'C', 'D', 'A', 'T', 'A')) {
6573 tree = xmlParseElementMixedContentDecl(ctxt, inputid);
6575 } else {
6576 tree = xmlParseElementChildrenContentDeclPriv(ctxt, inputid, 1);
6578 }
6580 *result = tree;
6581 return(res);
6582}
GLuint res
Definition: glext.h:9613
GLuint64EXT * result
Definition: glext.h:11304
@ XML_ELEMENT_TYPE_MIXED
Definition: tree.h:326
@ XML_ELEMENT_TYPE_ELEMENT
Definition: tree.h:327
xmlElementContentPtr xmlParseElementMixedContentDecl(xmlParserCtxtPtr ctxt, int inputchk)
Definition: parser.c:6104
@ XML_ERR_ELEMCONTENT_NOT_STARTED
Definition: xmlerror.h:154

Referenced by xmlParseElementDecl().

◆ xmlParseElementDecl()

XMLPUBFUN int XMLCALL xmlParseElementDecl ( xmlParserCtxtPtr  ctxt)

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

Definition at line 6598 of file parser.c.

6598 {
6599 const xmlChar *name;
6600 int ret = -1;
6602
6603 /* GROW; done in the caller */
6604 if (CMP9(CUR_PTR, '<', '!', 'E', 'L', 'E', 'M', 'E', 'N', 'T')) {
6605 int inputid = ctxt->input->id;
6606
6607 SKIP(9);
6608 if (SKIP_BLANKS == 0) {
6609 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
6610 "Space required after 'ELEMENT'\n");
6611 return(-1);
6612 }
6613 name = xmlParseName(ctxt);
6614 if (name == NULL) {
6615 xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
6616 "xmlParseElementDecl: no name for Element\n");
6617 return(-1);
6618 }
6619 if (SKIP_BLANKS == 0) {
6620 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
6621 "Space required after the element name\n");
6622 }
6623 if (CMP5(CUR_PTR, 'E', 'M', 'P', 'T', 'Y')) {
6624 SKIP(5);
6625 /*
6626 * Element must always be empty.
6627 */
6629 } else if ((RAW == 'A') && (NXT(1) == 'N') &&
6630 (NXT(2) == 'Y')) {
6631 SKIP(3);
6632 /*
6633 * Element is a generic container.
6634 */
6636 } else if (RAW == '(') {
6638 } else {
6639 /*
6640 * [ WFC: PEs in Internal Subset ] error handling.
6641 */
6642 if ((RAW == '%') && (ctxt->external == 0) &&
6643 (ctxt->inputNr == 1)) {
6644 xmlFatalErrMsg(ctxt, XML_ERR_PEREF_IN_INT_SUBSET,
6645 "PEReference: forbidden within markup decl in internal subset\n");
6646 } else {
6647 xmlFatalErrMsg(ctxt, XML_ERR_ELEMCONTENT_NOT_STARTED,
6648 "xmlParseElementDecl: 'EMPTY', 'ANY' or '(' expected\n");
6649 }
6650 return(-1);
6651 }
6652
6654
6655 if (RAW != '>') {
6657 if (content != NULL) {
6659 }
6660 } else {
6661 if (inputid != ctxt->input->id) {
6662 xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
6663 "Element declaration doesn't start and stop in"
6664 " the same entity\n");
6665 }
6666
6667 NEXT;
6668 if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
6669 (ctxt->sax->elementDecl != NULL)) {
6670 if (content != NULL)
6671 content->parent = NULL;
6672 ctxt->sax->elementDecl(ctxt->userData, name, ret,
6673 content);
6674 if ((content != NULL) && (content->parent == NULL)) {
6675 /*
6676 * this is a trick: if xmlAddElementDecl is called,
6677 * instead of copying the full tree it is plugged directly
6678 * if called from the parser. Avoid duplicating the
6679 * interfaces or change the API/ABI
6680 */
6682 }
6683 } else if (content != NULL) {
6685 }
6686 }
6687 }
6688 return(ret);
6689}
content
Definition: atl_ax.c:994
@ XML_ELEMENT_TYPE_EMPTY
Definition: tree.h:324
@ XML_ELEMENT_TYPE_ANY
Definition: tree.h:325
int xmlParseElementContentDecl(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlElementContentPtr *result)
Definition: parser.c:6553
int external
Definition: parser.h:217
xmlDocPtr myDoc
Definition: parser.h:187
XMLPUBFUN void XMLCALL xmlFreeDocElementContent(xmlDocPtr doc, xmlElementContentPtr cur)
Definition: valid.c:1089
@ XML_ERR_PEREF_IN_INT_SUBSET
Definition: xmlerror.h:121
@ XML_ERR_GT_REQUIRED
Definition: xmlerror.h:173

Referenced by xmlParseMarkupDecl().

◆ xmlParseElementMixedContentDecl()

XMLPUBFUN xmlElementContentPtr XMLCALL xmlParseElementMixedContentDecl ( xmlParserCtxtPtr  ctxt,
int  inputchk 
)

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: Proper Group/PE Nesting ] applies to [51] too (see [49])

[ 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

Definition at line 6104 of file parser.c.

6104 {
6106 const xmlChar *elem = NULL;
6107
6108 GROW;
6109 if (CMP7(CUR_PTR, '#', 'P', 'C', 'D', 'A', 'T', 'A')) {
6110 SKIP(7);
6112 SHRINK;
6113 if (RAW == ')') {
6114 if (ctxt->input->id != inputchk) {
6115 xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
6116 "Element content declaration doesn't start and"
6117 " stop in the same entity\n");
6118 }
6119 NEXT;
6121 if (ret == NULL)
6122 return(NULL);
6123 if (RAW == '*') {
6125 NEXT;
6126 }
6127 return(ret);
6128 }
6129 if ((RAW == '(') || (RAW == '|')) {
6131 if (ret == NULL) return(NULL);
6132 }
6133 while ((RAW == '|') && (ctxt->instate != XML_PARSER_EOF)) {
6134 NEXT;
6135 if (elem == NULL) {
6137 if (ret == NULL) {
6139 return(NULL);
6140 }
6141 ret->c1 = cur;
6142 if (cur != NULL)
6143 cur->parent = ret;
6144 cur = ret;
6145 } else {
6147 if (n == NULL) {
6149 return(NULL);
6150 }
6152 if (n->c1 != NULL)
6153 n->c1->parent = n;
6154 cur->c2 = n;
6155 if (n != NULL)
6156 n->parent = cur;
6157 cur = n;
6158 }
6160 elem = xmlParseName(ctxt);
6161 if (elem == NULL) {
6162 xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
6163 "xmlParseElementMixedContentDecl : Name expected\n");
6165 return(NULL);
6166 }
6168 GROW;
6169 }
6170 if ((RAW == ')') && (NXT(1) == '*')) {
6171 if (elem != NULL) {
6174 if (cur->c2 != NULL)
6175 cur->c2->parent = cur;
6176 }
6177 if (ret != NULL)
6179 if (ctxt->input->id != inputchk) {
6180 xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
6181 "Element content declaration doesn't start and"
6182 " stop in the same entity\n");
6183 }
6184 SKIP(2);
6185 } else {
6188 return(NULL);
6189 }
6190
6191 } else {
6193 }
6194 return(ret);
6195}
GLdouble n
Definition: glext.h:7729
static size_t elem
Definition: string.c:68
@ XML_ELEMENT_CONTENT_MULT
Definition: tree.h:293
@ XML_ELEMENT_CONTENT_PCDATA
Definition: tree.h:279
@ XML_ELEMENT_CONTENT_ELEMENT
Definition: tree.h:280
@ XML_ELEMENT_CONTENT_OR
Definition: tree.h:282
XMLPUBFUN xmlElementContentPtr XMLCALL xmlNewDocElementContent(xmlDocPtr doc, const xmlChar *name, xmlElementContentType type)
Definition: valid.c:908
@ XML_ERR_MIXED_NOT_STARTED
Definition: xmlerror.h:152
@ XML_ERR_PCDATA_REQUIRED
Definition: xmlerror.h:169

Referenced by xmlParseElementContentDecl().

◆ xmlParseEncName()

XMLPUBFUN xmlChar *XMLCALL xmlParseEncName ( xmlParserCtxtPtr  ctxt)

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

Definition at line 10293 of file parser.c.

10293 {
10294 xmlChar *buf = NULL;
10295 int len = 0;
10296 int size = 10;
10297 xmlChar cur;
10298
10299 cur = CUR;
10300 if (((cur >= 'a') && (cur <= 'z')) ||
10301 ((cur >= 'A') && (cur <= 'Z'))) {
10302 buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
10303 if (buf == NULL) {
10304 xmlErrMemory(ctxt, NULL);
10305 return(NULL);
10306 }
10307
10308 buf[len++] = cur;
10309 NEXT;
10310 cur = CUR;
10311 while (((cur >= 'a') && (cur <= 'z')) ||
10312 ((cur >= 'A') && (cur <= 'Z')) ||
10313 ((cur >= '0') && (cur <= '9')) ||
10314 (cur == '.') || (cur == '_') ||
10315 (cur == '-')) {
10316 if (len + 1 >= size) {
10317 xmlChar *tmp;
10318
10319 size *= 2;
10320 tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
10321 if (tmp == NULL) {
10322 xmlErrMemory(ctxt, NULL);
10323 xmlFree(buf);
10324 return(NULL);
10325 }
10326 buf = tmp;
10327 }
10328 buf[len++] = cur;
10329 NEXT;
10330 cur = CUR;
10331 if (cur == 0) {
10332 SHRINK;
10333 GROW;
10334 cur = CUR;
10335 }
10336 }
10337 buf[len] = 0;
10338 } else {
10340 }
10341 return(buf);
10342}
@ XML_ERR_ENCODING_NAME
Definition: xmlerror.h:179

Referenced by xmlParseEncodingDecl().

◆ xmlParseEncodingDecl()

XMLPUBFUN const xmlChar *XMLCALL xmlParseEncodingDecl ( xmlParserCtxtPtr  ctxt)

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

Definition at line 10358 of file parser.c.

10358 {
10360
10362 if (CMP8(CUR_PTR, 'e', 'n', 'c', 'o', 'd', 'i', 'n', 'g')) {
10363 SKIP(8);
10365 if (RAW != '=') {
10367 return(NULL);
10368 }
10369 NEXT;
10371 if (RAW == '"') {
10372 NEXT;
10373 encoding = xmlParseEncName(ctxt);
10374 if (RAW != '"') {
10377 return(NULL);
10378 } else
10379 NEXT;
10380 } else if (RAW == '\''){
10381 NEXT;
10382 encoding = xmlParseEncName(ctxt);
10383 if (RAW != '\'') {
10386 return(NULL);
10387 } else
10388 NEXT;
10389 } else {
10391 }
10392
10393 /*
10394 * Non standard parsing, allowing the user to ignore encoding
10395 */
10396 if (ctxt->options & XML_PARSE_IGNORE_ENC) {
10398 return(NULL);
10399 }
10400
10401 /*
10402 * UTF-16 encoding switch has already taken place at this stage,
10403 * more over the little-endian/big-endian selection is already done
10404 */
10405 if ((encoding != NULL) &&
10406 ((!xmlStrcasecmp(encoding, BAD_CAST "UTF-16")) ||
10407 (!xmlStrcasecmp(encoding, BAD_CAST "UTF16")))) {
10408 /*
10409 * If no encoding was passed to the parser, that we are
10410 * using UTF-16 and no decoder is present i.e. the
10411 * document is apparently UTF-8 compatible, then raise an
10412 * encoding mismatch fatal error
10413 */
10414 if ((ctxt->encoding == NULL) &&
10415 (ctxt->input->buf != NULL) &&
10416 (ctxt->input->buf->encoder == NULL)) {
10417 xmlFatalErrMsg(ctxt, XML_ERR_INVALID_ENCODING,
10418 "Document labelled UTF-16 but has UTF-8 content\n");
10419 }
10420 if (ctxt->encoding != NULL)
10421 xmlFree((xmlChar *) ctxt->encoding);
10422 ctxt->encoding = encoding;
10423 }
10424 /*
10425 * UTF-8 encoding is handled natively
10426 */
10427 else if ((encoding != NULL) &&
10428 ((!xmlStrcasecmp(encoding, BAD_CAST "UTF-8")) ||
10429 (!xmlStrcasecmp(encoding, BAD_CAST "UTF8")))) {
10430 if (ctxt->encoding != NULL)
10431 xmlFree((xmlChar *) ctxt->encoding);
10432 ctxt->encoding = encoding;
10433 }
10434 else if (encoding != NULL) {
10436
10437 if (ctxt->input->encoding != NULL)
10438 xmlFree((xmlChar *) ctxt->input->encoding);
10439 ctxt->input->encoding = encoding;
10440
10442 if (handler != NULL) {
10443 if (xmlSwitchToEncoding(ctxt, handler) < 0) {
10444 /* failed to convert */
10446 return(NULL);
10447 }
10448 } else {
10449 xmlFatalErrMsgStr(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
10450 "Unsupported encoding %s\n", encoding);
10451 return(NULL);
10452 }
10453 }
10454 }
10455 return(encoding);
10456}
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7482
XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL xmlFindCharEncodingHandler(const char *name)
Definition: encoding.c:1678
XMLPUBFUN int XMLCALL xmlSwitchToEncoding(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler)
@ XML_PARSE_IGNORE_ENC
Definition: parser.h:1116
xmlChar * xmlParseEncName(xmlParserCtxtPtr ctxt)
Definition: parser.c:10293
const xmlChar * encoding
Definition: parser.h:191
xmlCharEncodingHandlerPtr encoder
Definition: xmlIO.h:130
const xmlChar * encoding
Definition: parser.h:71
@ XML_ERR_INVALID_ENCODING
Definition: xmlerror.h:181
@ XML_ERR_STRING_NOT_CLOSED
Definition: xmlerror.h:134
@ XML_ERR_STRING_NOT_STARTED
Definition: xmlerror.h:133
@ XML_ERR_EQUAL_REQUIRED
Definition: xmlerror.h:175
@ XML_ERR_UNSUPPORTED_ENCODING
Definition: xmlerror.h:132
static char * encoding
Definition: xmllint.c:155
XMLPUBFUN int XMLCALL xmlStrcasecmp(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:275

Referenced by xmlParseTextDecl(), and xmlParseXMLDecl().

◆ xmlParseEntityDecl()

XMLPUBFUN void XMLCALL xmlParseEntityDecl ( xmlParserCtxtPtr  ctxt)

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.

Definition at line 5409 of file parser.c.

5409 {
5410 const xmlChar *name = NULL;
5411 xmlChar *value = NULL;
5412 xmlChar *URI = NULL, *literal = NULL;
5413 const xmlChar *ndata = NULL;
5414 int isParameter = 0;
5415 xmlChar *orig = NULL;
5416
5417 /* GROW; done in the caller */
5418 if (CMP8(CUR_PTR, '<', '!', 'E', 'N', 'T', 'I', 'T', 'Y')) {
5419 int inputid = ctxt->input->id;
5420 SHRINK;
5421 SKIP(8);
5422 if (SKIP_BLANKS == 0) {
5423 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5424 "Space required after '<!ENTITY'\n");
5425 }
5426
5427 if (RAW == '%') {
5428 NEXT;
5429 if (SKIP_BLANKS == 0) {
5430 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5431 "Space required after '%%'\n");
5432 }
5433 isParameter = 1;
5434 }
5435
5436 name = xmlParseName(ctxt);
5437 if (name == NULL) {
5438 xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
5439 "xmlParseEntityDecl: no name\n");
5440 return;
5441 }
5442 if (xmlStrchr(name, ':') != NULL) {
5443 xmlNsErr(ctxt, XML_NS_ERR_COLON,
5444 "colons are forbidden from entities names '%s'\n",
5445 name, NULL, NULL);
5446 }
5447 if (SKIP_BLANKS == 0) {
5448 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5449 "Space required after the entity name\n");
5450 }
5451
5453 /*
5454 * handle the various case of definitions...
5455 */
5456 if (isParameter) {
5457 if ((RAW == '"') || (RAW == '\'')) {
5458 value = xmlParseEntityValue(ctxt, &orig);
5459 if (value) {
5460 if ((ctxt->sax != NULL) &&
5461 (!ctxt->disableSAX) && (ctxt->sax->entityDecl != NULL))
5462 ctxt->sax->entityDecl(ctxt->userData, name,
5464 NULL, NULL, value);
5465 }
5466 } else {
5467 URI = xmlParseExternalID(ctxt, &literal, 1);
5468 if ((URI == NULL) && (literal == NULL)) {
5470 }
5471 if (URI) {
5472 xmlURIPtr uri;
5473
5474 uri = xmlParseURI((const char *) URI);
5475 if (uri == NULL) {
5476 xmlErrMsgStr(ctxt, XML_ERR_INVALID_URI,
5477 "Invalid URI: %s\n", URI);
5478 /*
5479 * This really ought to be a well formedness error
5480 * but the XML Core WG decided otherwise c.f. issue
5481 * E26 of the XML erratas.
5482 */
5483 } else {
5484 if (uri->fragment != NULL) {
5485 /*
5486 * Okay this is foolish to block those but not
5487 * invalid URIs.
5488 */
5490 } else {
5491 if ((ctxt->sax != NULL) &&
5492 (!ctxt->disableSAX) &&
5493 (ctxt->sax->entityDecl != NULL))
5494 ctxt->sax->entityDecl(ctxt->userData, name,
5496 literal, URI, NULL);
5497 }
5498 xmlFreeURI(uri);
5499 }
5500 }
5501 }
5502 } else {
5503 if ((RAW == '"') || (RAW == '\'')) {
5504 value = xmlParseEntityValue(ctxt, &orig);
5505 if ((ctxt->sax != NULL) &&
5506 (!ctxt->disableSAX) && (ctxt->sax->entityDecl != NULL))
5507 ctxt->sax->entityDecl(ctxt->userData, name,
5509 NULL, NULL, value);
5510 /*
5511 * For expat compatibility in SAX mode.
5512 */
5513 if ((ctxt->myDoc == NULL) ||
5515 if (ctxt->myDoc == NULL) {
5517 if (ctxt->myDoc == NULL) {
5518 xmlErrMemory(ctxt, "New Doc failed");
5519 return;
5520 }
5522 }
5523 if (ctxt->myDoc->intSubset == NULL)
5524 ctxt->myDoc->intSubset = xmlNewDtd(ctxt->myDoc,
5525 BAD_CAST "fake", NULL, NULL);
5526
5528 NULL, NULL, value);
5529 }
5530 } else {
5531 URI = xmlParseExternalID(ctxt, &literal, 1);
5532 if ((URI == NULL) && (literal == NULL)) {
5534 }
5535 if (URI) {
5536 xmlURIPtr uri;
5537
5538 uri = xmlParseURI((const char *)URI);
5539 if (uri == NULL) {
5540 xmlErrMsgStr(ctxt, XML_ERR_INVALID_URI,
5541 "Invalid URI: %s\n", URI);
5542 /*
5543 * This really ought to be a well formedness error
5544 * but the XML Core WG decided otherwise c.f. issue
5545 * E26 of the XML erratas.
5546 */
5547 } else {
5548 if (uri->fragment != NULL) {
5549 /*
5550 * Okay this is foolish to block those but not
5551 * invalid URIs.
5552 */
5554 }
5555 xmlFreeURI(uri);
5556 }
5557 }
5558 if ((RAW != '>') && (SKIP_BLANKS == 0)) {
5559 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5560 "Space required before 'NDATA'\n");
5561 }
5562 if (CMP5(CUR_PTR, 'N', 'D', 'A', 'T', 'A')) {
5563 SKIP(5);
5564 if (SKIP_BLANKS == 0) {
5565 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5566 "Space required after 'NDATA'\n");
5567 }
5568 ndata = xmlParseName(ctxt);
5569 if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
5570 (ctxt->sax->unparsedEntityDecl != NULL))
5571 ctxt->sax->unparsedEntityDecl(ctxt->userData, name,
5572 literal, URI, ndata);
5573 } else {
5574 if ((ctxt->sax != NULL) &&
5575 (!ctxt->disableSAX) && (ctxt->sax->entityDecl != NULL))
5576 ctxt->sax->entityDecl(ctxt->userData, name,
5578 literal, URI, NULL);
5579 /*
5580 * For expat compatibility in SAX mode.
5581 * assuming the entity replacement was asked for
5582 */
5583 if ((ctxt->replaceEntities != 0) &&
5584 ((ctxt->myDoc == NULL) ||
5586 if (ctxt->myDoc == NULL) {
5588 if (ctxt->myDoc == NULL) {
5589 xmlErrMemory(ctxt, "New Doc failed");
5590 return;
5591 }
5593 }
5594
5595 if (ctxt->myDoc->intSubset == NULL)
5596 ctxt->myDoc->intSubset = xmlNewDtd(ctxt->myDoc,
5597 BAD_CAST "fake", NULL, NULL);
5598 xmlSAX2EntityDecl(ctxt, name,
5600 literal, URI, NULL);
5601 }
5602 }
5603 }
5604 }
5605 if (ctxt->instate == XML_PARSER_EOF)
5606 goto done;
5608 if (RAW != '>') {
5609 xmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_NOT_FINISHED,
5610 "xmlParseEntityDecl: entity %s not terminated\n", name);
5611 xmlHaltParser(ctxt);
5612 } else {
5613 if (inputid != ctxt->input->id) {
5614 xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
5615 "Entity declaration doesn't start and stop in"
5616 " the same entity\n");
5617 }
5618 NEXT;
5619 }
5620 if (orig != NULL) {
5621 /*
5622 * Ugly mechanism to save the raw entity value.
5623 */
5625
5626 if (isParameter) {
5627 if ((ctxt->sax != NULL) &&
5628 (ctxt->sax->getParameterEntity != NULL))
5629 cur = ctxt->sax->getParameterEntity(ctxt->userData, name);
5630 } else {
5631 if ((ctxt->sax != NULL) &&
5632 (ctxt->sax->getEntity != NULL))
5633 cur = ctxt->sax->getEntity(ctxt->userData, name);
5634 if ((cur == NULL) && (ctxt->userData==ctxt)) {
5635 cur = xmlSAX2GetEntity(ctxt, name);
5636 }
5637 }
5638 if ((cur != NULL) && (cur->orig == NULL)) {
5639 cur->orig = orig;
5640 orig = NULL;
5641 }
5642 }
5643
5644done:
5645 if (value != NULL) xmlFree(value);
5646 if (URI != NULL) xmlFree(URI);
5647 if (literal != NULL) xmlFree(literal);
5648 if (orig != NULL) xmlFree(orig);
5649 }
5650}
XMLPUBFUN void XMLCALL xmlSAX2EntityDecl(void *ctx, const xmlChar *name, int type, const xmlChar *publicId, const xmlChar *systemId, xmlChar *content)
Definition: SAX2.c:604
XMLPUBFUN xmlEntityPtr XMLCALL xmlSAX2GetEntity(void *ctx, const xmlChar *name)
Definition: SAX2.c:526
const char * uri
Definition: sec_mgr.c:1588
@ XML_PARSER_ENTITY_DECL
Definition: parser.h:122
XMLPUBFUN xmlDtdPtr XMLCALL xmlNewDtd(xmlDocPtr doc, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID)
XMLPUBFUN xmlDocPtr XMLCALL xmlNewDoc(const xmlChar *version)
@ XML_DOC_INTERNAL
Definition: tree.h:540
xmlChar * xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig)
Definition: parser.c:3767
#define SAX_COMPAT_MODE
Definition: parser.c:277
struct _xmlDtd * intSubset
Definition: tree.h:570
const xmlChar * version
Definition: tree.h:573
int properties
Definition: tree.h:584
int replaceEntities
Definition: parser.h:189
Definition: uri.h:33
XMLPUBFUN xmlURIPtr XMLCALL xmlParseURI(const char *str)
Definition: uri.c:940
XMLPUBFUN void XMLCALL xmlFreeURI(xmlURIPtr uri)
Definition: uri.c:1387
@ XML_ERR_ENTITY_NOT_FINISHED
Definition: xmlerror.h:137
@ XML_ERR_INVALID_URI
Definition: xmlerror.h:191
@ XML_ERR_URI_FRAGMENT
Definition: xmlerror.h:192
@ XML_ERR_VALUE_REQUIRED
Definition: xmlerror.h:184
@ XML_NS_ERR_COLON
Definition: xmlerror.h:218
XMLPUBFUN const xmlChar *XMLCALL xmlStrchr(const xmlChar *str, xmlChar val)
Definition: xmlstring.c:325
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:160

Referenced by xmlParseMarkupDecl().

◆ xmlParseEntityRef()

XMLPUBFUN xmlEntityPtr XMLCALL xmlParseEntityRef ( xmlParserCtxtPtr  ctxt)

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.

Definition at line 7531 of file parser.c.

7531 {
7532 const xmlChar *name;
7533 xmlEntityPtr ent = NULL;
7534
7535 GROW;
7536 if (ctxt->instate == XML_PARSER_EOF)
7537 return(NULL);
7538
7539 if (RAW != '&')
7540 return(NULL);
7541 NEXT;
7542 name = xmlParseName(ctxt);
7543 if (name == NULL) {
7544 xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
7545 "xmlParseEntityRef: no name\n");
7546 return(NULL);
7547 }
7548 if (RAW != ';') {
7550 return(NULL);
7551 }
7552 NEXT;
7553
7554 /*
7555 * Predefined entities override any extra definition
7556 */
7557 if ((ctxt->options & XML_PARSE_OLDSAX) == 0) {
7559 if (ent != NULL)
7560 return(ent);
7561 }
7562
7563 /*
7564 * Increase the number of entity references parsed
7565 */
7566 ctxt->nbentities++;
7567
7568 /*
7569 * Ask first SAX for entity resolution, otherwise try the
7570 * entities which may have stored in the parser context.
7571 */
7572 if (ctxt->sax != NULL) {
7573 if (ctxt->sax->getEntity != NULL)
7574 ent = ctxt->sax->getEntity(ctxt->userData, name);
7575 if ((ctxt->wellFormed == 1 ) && (ent == NULL) &&
7576 (ctxt->options & XML_PARSE_OLDSAX))
7578 if ((ctxt->wellFormed == 1 ) && (ent == NULL) &&
7579 (ctxt->userData==ctxt)) {
7580 ent = xmlSAX2GetEntity(ctxt, name);
7581 }
7582 }
7583 if (ctxt->instate == XML_PARSER_EOF)
7584 return(NULL);
7585 /*
7586 * [ WFC: Entity Declared ]
7587 * In a document without any DTD, a document with only an
7588 * internal DTD subset which contains no parameter entity
7589 * references, or a document with "standalone='yes'", the
7590 * Name given in the entity reference must match that in an
7591 * entity declaration, except that well-formed documents
7592 * need not declare any of the following entities: amp, lt,
7593 * gt, apos, quot.
7594 * The declaration of a parameter entity must precede any
7595 * reference to it.
7596 * Similarly, the declaration of a general entity must
7597 * precede any reference to it which appears in a default
7598 * value in an attribute-list declaration. Note that if
7599 * entities are declared in the external subset or in
7600 * external parameter entities, a non-validating processor
7601 * is not obligated to read and process their declarations;
7602 * for such documents, the rule that an entity must be
7603 * declared is a well-formedness constraint only if
7604 * standalone='yes'.
7605 */
7606 if (ent == NULL) {
7607 if ((ctxt->standalone == 1) ||
7608 ((ctxt->hasExternalSubset == 0) &&
7609 (ctxt->hasPErefs == 0))) {
7610 xmlFatalErrMsgStr(ctxt, XML_ERR_UNDECLARED_ENTITY,
7611 "Entity '%s' not defined\n", name);
7612 } else {
7613 xmlErrMsgStr(ctxt, XML_WAR_UNDECLARED_ENTITY,
7614 "Entity '%s' not defined\n", name);
7615 if ((ctxt->inSubset == 0) &&
7616 (ctxt->sax != NULL) &&
7617 (ctxt->sax->reference != NULL)) {
7618 ctxt->sax->reference(ctxt->userData, name);
7619 }
7620 }
7621 xmlParserEntityCheck(ctxt, 0, ent, 0);
7622 ctxt->valid = 0;
7623 }
7624
7625 /*
7626 * [ WFC: Parsed Entity ]
7627 * An entity reference must not contain the name of an
7628 * unparsed entity
7629 */
7631 xmlFatalErrMsgStr(ctxt, XML_ERR_UNPARSED_ENTITY,
7632 "Entity reference to unparsed entity %s\n", name);
7633 }
7634
7635 /*
7636 * [ WFC: No External Entity References ]
7637 * Attribute values cannot contain direct or indirect
7638 * entity references to external entities.
7639 */
7640 else if ((ctxt->instate == XML_PARSER_ATTRIBUTE_VALUE) &&
7642 xmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_IS_EXTERNAL,
7643 "Attribute references external entity '%s'\n", name);
7644 }
7645 /*
7646 * [ WFC: No < in Attribute Values ]
7647 * The replacement text of any entity referred to directly or
7648 * indirectly in an attribute value (other than "&lt;") must
7649 * not contain a <.
7650 */
7651 else if ((ctxt->instate == XML_PARSER_ATTRIBUTE_VALUE) &&
7652 (ent != NULL) &&
7654 if (((ent->checked & 1) || (ent->checked == 0)) &&
7655 (ent->content != NULL) && (xmlStrchr(ent->content, '<'))) {
7656 xmlFatalErrMsgStr(ctxt, XML_ERR_LT_IN_ATTRIBUTE,
7657 "'<' in entity '%s' is not allowed in attributes values\n", name);
7658 }
7659 }
7660
7661 /*
7662 * Internal check, no parameter entities here ...
7663 */
7664 else {
7665 switch (ent->etype) {
7668 xmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_IS_PARAMETER,
7669 "Attempt to reference the parameter entity '%s'\n",
7670 name);
7671 break;
7672 default:
7673 break;
7674 }
7675 }
7676
7677 /*
7678 * [ WFC: No Recursion ]
7679 * A parsed entity must not contain a recursive reference
7680 * to itself, either directly or indirectly.
7681 * Done somewhere else
7682 */
7683 return(ent);
7684}
XMLPUBFUN xmlEntityPtr XMLCALL xmlGetPredefinedEntity(const xmlChar *name)
@ XML_PARSER_ATTRIBUTE_VALUE
Definition: parser.h:124
@ XML_PARSE_OLDSAX
Definition: parser.h:1115
static int xmlParserEntityCheck(xmlParserCtxtPtr ctxt, size_t size, xmlEntityPtr ent, size_t replacement)
Definition: parser.c:128
xmlChar * content
Definition: entities.h:50
xmlEntityType etype
Definition: entities.h:52
int checked
Definition: entities.h:59
int hasPErefs
Definition: parser.h:216
int wellFormed
Definition: parser.h:188
int inSubset
Definition: parser.h:238
int standalone
Definition: parser.h:192
unsigned long nbentities
Definition: parser.h:303
@ XML_ERR_ENTITYREF_SEMICOL_MISSING
Definition: xmlerror.h:123
@ XML_ERR_LT_IN_ATTRIBUTE
Definition: xmlerror.h:138
@ XML_WAR_UNDECLARED_ENTITY
Definition: xmlerror.h:127
@ XML_ERR_ENTITY_IS_PARAMETER
Definition: xmlerror.h:130
@ XML_ERR_ENTITY_IS_EXTERNAL
Definition: xmlerror.h:129
@ XML_ERR_UNDECLARED_ENTITY
Definition: xmlerror.h:126
@ XML_ERR_UNPARSED_ENTITY
Definition: xmlerror.h:128

Referenced by xmlParseAttValueComplex(), and xmlParseReference().

◆ xmlParseEntityValue()

XMLPUBFUN xmlChar *XMLCALL xmlParseEntityValue ( xmlParserCtxtPtr  ctxt,
xmlChar **  orig 
)

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

Definition at line 3767 of file parser.c.

3767 {
3768 xmlChar *buf = NULL;
3769 int len = 0;
3771 int c, l;
3772 int maxLength = (ctxt->options & XML_PARSE_HUGE) ?
3775 xmlChar stop;
3776 xmlChar *ret = NULL;
3777 const xmlChar *cur = NULL;
3779
3780 if (RAW == '"') stop = '"';
3781 else if (RAW == '\'') stop = '\'';
3782 else {
3784 return(NULL);
3785 }
3786 buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
3787 if (buf == NULL) {
3788 xmlErrMemory(ctxt, NULL);
3789 return(NULL);
3790 }
3791
3792 /*
3793 * The content of the entity definition is copied in a buffer.
3794 */
3795
3797 input = ctxt->input;
3798 GROW;
3799 if (ctxt->instate == XML_PARSER_EOF)
3800 goto error;
3801 NEXT;
3802 c = CUR_CHAR(l);
3803 /*
3804 * NOTE: 4.4.5 Included in Literal
3805 * When a parameter entity reference appears in a literal entity
3806 * value, ... a single or double quote character in the replacement
3807 * text is always treated as a normal data character and will not
3808 * terminate the literal.
3809 * In practice it means we stop the loop only when back at parsing
3810 * the initial entity and the quote is found
3811 */
3812 while (((IS_CHAR(c)) && ((c != stop) || /* checked */
3813 (ctxt->input != input))) && (ctxt->instate != XML_PARSER_EOF)) {
3814 if (len + 5 >= size) {
3815 xmlChar *tmp;
3816
3817 size *= 2;
3818 tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
3819 if (tmp == NULL) {
3820 xmlErrMemory(ctxt, NULL);
3821 goto error;
3822 }
3823 buf = tmp;
3824 }
3825 COPY_BUF(l,buf,len,c);
3826 NEXTL(l);
3827
3828 GROW;
3829 c = CUR_CHAR(l);
3830 if (c == 0) {
3831 GROW;
3832 c = CUR_CHAR(l);
3833 }
3834
3835 if (len > maxLength) {
3836 xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_NOT_FINISHED,
3837 "entity value too long\n");
3838 goto error;
3839 }
3840 }
3841 buf[len] = 0;
3842 if (ctxt->instate == XML_PARSER_EOF)
3843 goto error;
3844 if (c != stop) {
3846 goto error;
3847 }
3848 NEXT;
3849
3850 /*
3851 * Raise problem w.r.t. '&' and '%' being used in non-entities
3852 * reference constructs. Note Charref will be handled in
3853 * xmlStringDecodeEntities()
3854 */
3855 cur = buf;
3856 while (*cur != 0) { /* non input consuming */
3857 if ((*cur == '%') || ((*cur == '&') && (cur[1] != '#'))) {
3858 xmlChar *name;
3859 xmlChar tmp = *cur;
3860 int nameOk = 0;
3861
3862 cur++;
3863 name = xmlParseStringName(ctxt, &cur);
3864 if (name != NULL) {
3865 nameOk = 1;
3866 xmlFree(name);
3867 }
3868 if ((nameOk == 0) || (*cur != ';')) {
3869 xmlFatalErrMsgInt(ctxt, XML_ERR_ENTITY_CHAR_ERROR,
3870 "EntityValue: '%c' forbidden except for entities references\n",
3871 tmp);
3872 goto error;
3873 }
3874 if ((tmp == '%') && (ctxt->inSubset == 1) &&
3875 (ctxt->inputNr == 1)) {
3877 goto error;
3878 }
3879 if (*cur == 0)
3880 break;
3881 }
3882 cur++;
3883 }
3884
3885 /*
3886 * Then PEReference entities are substituted.
3887 *
3888 * NOTE: 4.4.7 Bypassed
3889 * When a general entity reference appears in the EntityValue in
3890 * an entity declaration, it is bypassed and left as is.
3891 * so XML_SUBSTITUTE_REF is not set here.
3892 */
3893 ++ctxt->depth;
3895 0, 0, 0);
3896 --ctxt->depth;
3897 if (orig != NULL) {
3898 *orig = buf;
3899 buf = NULL;
3900 }
3901
3902error:
3903 if (buf != NULL)
3904 xmlFree(buf);
3905 return(ret);
3906}
#define error(str)
Definition: mkdosfs.c:1605
#define XML_SUBSTITUTE_PEREF
@ XML_PARSER_ENTITY_VALUE
Definition: parser.h:123
static xmlChar * xmlParseStringName(xmlParserCtxtPtr ctxt, const xmlChar **str)
Definition: parser.c:3573
xmlChar * xmlStringDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int what, xmlChar end, xmlChar end2, xmlChar end3)
Definition: parser.c:2839
@ XML_ERR_ENTITY_PE_INTERNAL
Definition: xmlerror.h:188
@ XML_ERR_ENTITY_CHAR_ERROR
Definition: xmlerror.h:187
@ XML_ERR_ENTITY_NOT_STARTED
Definition: xmlerror.h:136

Referenced by xmlParseEntityDecl().

◆ xmlParseEnumeratedType()

XMLPUBFUN int XMLCALL xmlParseEnumeratedType ( xmlParserCtxtPtr  ctxt,
xmlEnumerationPtr tree 
)

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

Definition at line 5871 of file parser.c.

5871 {
5872 if (CMP8(CUR_PTR, 'N', 'O', 'T', 'A', 'T', 'I', 'O', 'N')) {
5873 SKIP(8);
5874 if (SKIP_BLANKS == 0) {
5875 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5876 "Space required after 'NOTATION'\n");
5877 return(0);
5878 }
5879 *tree = xmlParseNotationType(ctxt);
5880 if (*tree == NULL) return(0);
5881 return(XML_ATTRIBUTE_NOTATION);
5882 }
5884 if (*tree == NULL) return(0);
5886}
@ XML_ATTRIBUTE_NOTATION
Definition: tree.h:216
@ XML_ATTRIBUTE_ENUMERATION
Definition: tree.h:215
xmlEnumerationPtr xmlParseNotationType(xmlParserCtxtPtr ctxt)
Definition: parser.c:5732
xmlEnumerationPtr xmlParseEnumerationType(xmlParserCtxtPtr ctxt)
Definition: parser.c:5802

Referenced by xmlParseAttributeType().

◆ xmlParseEnumerationType()

XMLPUBFUN xmlEnumerationPtr XMLCALL xmlParseEnumerationType ( xmlParserCtxtPtr  ctxt)

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

Definition at line 5802 of file parser.c.

5802 {
5803 xmlChar *name;
5805
5806 if (RAW != '(') {
5808 return(NULL);
5809 }
5810 SHRINK;
5811 do {
5812 NEXT;
5814 name = xmlParseNmtoken(ctxt);
5815 if (name == NULL) {
5817 return(ret);
5818 }
5819 tmp = ret;
5820 while (tmp != NULL) {
5821 if (xmlStrEqual(name, tmp->name)) {
5822 xmlValidityError(ctxt, XML_DTD_DUP_TOKEN,
5823 "standalone: attribute enumeration value token %s duplicated\n",
5824 name, NULL);
5825 if (!xmlDictOwns(ctxt->dict, name))
5826 xmlFree(name);
5827 break;
5828 }
5829 tmp = tmp->next;
5830 }
5831 if (tmp == NULL) {
5833 if (!xmlDictOwns(ctxt->dict, name))
5834 xmlFree(name);
5835 if (cur == NULL) {
5837 return(NULL);
5838 }
5839 if (last == NULL) ret = last = cur;
5840 else {
5841 last->next = cur;
5842 last = cur;
5843 }
5844 }
5846 } while (RAW == '|');
5847 if (RAW != ')') {
5849 return(ret);
5850 }
5851 NEXT;
5852 return(ret);
5853}
static UINT UINT last
Definition: font.c:45
XMLPUBFUN int XMLCALL xmlDictOwns(xmlDictPtr dict, const xmlChar *str)
Definition: dict.c:1220
xmlChar * xmlParseNmtoken(xmlParserCtxtPtr ctxt)
Definition: parser.c:3662
xmlDictPtr dict
Definition: parser.h:263
WCHAR * name
Definition: name.c:42
XMLPUBFUN xmlEnumerationPtr XMLCALL xmlCreateEnumeration(const xmlChar *name)
Definition: valid.c:1795
@ XML_ERR_ATTLIST_NOT_STARTED
Definition: xmlerror.h:150
@ XML_DTD_DUP_TOKEN
Definition: xmlerror.h:260
@ XML_ERR_NMTOKEN_REQUIRED
Definition: xmlerror.h:167
@ XML_ERR_ATTLIST_NOT_FINISHED
Definition: xmlerror.h:151

Referenced by xmlParseEnumeratedType().

◆ xmlParseExternalID()

XMLPUBFUN xmlChar *XMLCALL xmlParseExternalID ( xmlParserCtxtPtr  ctxt,
xmlChar **  publicID,
int  strict 
)

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.

Definition at line 4683 of file parser.c.

4683 {
4684 xmlChar *URI = NULL;
4685
4686 SHRINK;
4687
4688 *publicID = NULL;
4689 if (CMP6(CUR_PTR, 'S', 'Y', 'S', 'T', 'E', 'M')) {
4690 SKIP(6);
4691 if (SKIP_BLANKS == 0) {
4692 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
4693 "Space required after 'SYSTEM'\n");
4694 }
4695 URI = xmlParseSystemLiteral(ctxt);
4696 if (URI == NULL) {
4698 }
4699 } else if (CMP6(CUR_PTR, 'P', 'U', 'B', 'L', 'I', 'C')) {
4700 SKIP(6);
4701 if (SKIP_BLANKS == 0) {
4702 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
4703 "Space required after 'PUBLIC'\n");
4704 }
4705 *publicID = xmlParsePubidLiteral(ctxt);
4706 if (*publicID == NULL) {
4708 }
4709 if (strict) {
4710 /*
4711 * We don't handle [83] so "S SystemLiteral" is required.
4712 */
4713 if (SKIP_BLANKS == 0) {
4714 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
4715 "Space required after the Public Identifier\n");
4716 }
4717 } else {
4718 /*
4719 * We handle [83] so we return immediately, if
4720 * "S SystemLiteral" is not detected. We skip blanks if no
4721 * system literal was found, but this is harmless since we must
4722 * be at the end of a NotationDecl.
4723 */
4724 if (SKIP_BLANKS == 0) return(NULL);
4725 if ((CUR != '\'') && (CUR != '"')) return(NULL);
4726 }
4727 URI = xmlParseSystemLiteral(ctxt);
4728 if (URI == NULL) {
4730 }
4731 }
4732 return(URI);
4733}
static int strict
Definition: error.c:51
xmlChar * xmlParsePubidLiteral(xmlParserCtxtPtr ctxt)
Definition: parser.c:4291
xmlChar * xmlParseSystemLiteral(xmlParserCtxtPtr ctxt)
Definition: parser.c:4199
@ XML_ERR_PUBID_REQUIRED
Definition: xmlerror.h:171
@ XML_ERR_URI_REQUIRED
Definition: xmlerror.h:170

Referenced by xmlParseDocTypeDecl(), xmlParseEntityDecl(), and xmlParseNotationDecl().

◆ xmlParseExternalSubset()

XMLPUBFUN void XMLCALL xmlParseExternalSubset ( xmlParserCtxtPtr  ctxt,
const xmlChar ExternalID,
const xmlChar SystemID 
)

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) *

Definition at line 6998 of file parser.c.

6999 {
7000 xmlDetectSAX2(ctxt);
7001 GROW;
7002
7003 if ((ctxt->encoding == NULL) &&
7004 (ctxt->input->end - ctxt->input->cur >= 4)) {
7005 xmlChar start[4];
7006 xmlCharEncoding enc;
7007
7008 start[0] = RAW;
7009 start[1] = NXT(1);
7010 start[2] = NXT(2);
7011 start[3] = NXT(3);
7012 enc = xmlDetectCharEncoding(start, 4);
7013 if (enc != XML_CHAR_ENCODING_NONE)
7014 xmlSwitchEncoding(ctxt, enc);
7015 }
7016
7017 if (CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) {
7018 xmlParseTextDecl(ctxt);
7019 if (ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) {
7020 /*
7021 * The XML REC instructs us to stop parsing right here
7022 */
7023 xmlHaltParser(ctxt);
7024 return;
7025 }
7026 }
7027 if (ctxt->myDoc == NULL) {
7028 ctxt->myDoc = xmlNewDoc(BAD_CAST "1.0");
7029 if (ctxt->myDoc == NULL) {
7030 xmlErrMemory(ctxt, "New Doc failed");
7031 return;
7032 }
7034 }
7035 if ((ctxt->myDoc != NULL) && (ctxt->myDoc->intSubset == NULL))
7036 xmlCreateIntSubset(ctxt->myDoc, NULL, ExternalID, SystemID);
7037
7038 ctxt->instate = XML_PARSER_DTD;
7039 ctxt->external = 1;
7041 while (((RAW == '<') && (NXT(1) == '?')) ||
7042 ((RAW == '<') && (NXT(1) == '!')) ||
7043 (RAW == '%')) {
7044 int id = ctxt->input->id;
7045 unsigned long cons = CUR_CONSUMED;
7046
7047 GROW;
7048 if ((RAW == '<') && (NXT(1) == '!') && (NXT(2) == '[')) {
7050 } else
7051 xmlParseMarkupDecl(ctxt);
7053
7054 if ((id == ctxt->input->id) && (cons == CUR_CONSUMED)) {
7056 break;
7057 }
7058 }
7059
7060 if (RAW != 0) {
7062 }
7063
7064}
pair cons(caddr_t car, pair cdr)
Definition: tree.c:57
xmlCharEncoding
Definition: encoding.h:56
XMLPUBFUN xmlCharEncoding XMLCALL xmlDetectCharEncoding(const unsigned char *in, int len)
Definition: encoding.c:952
GLuint start
Definition: gl.h:1545
XMLPUBFUN int XMLCALL xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc)
XMLPUBFUN xmlDtdPtr XMLCALL xmlCreateIntSubset(xmlDocPtr doc, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID)
static void xmlParseConditionalSections(xmlParserCtxtPtr ctxt)
Definition: parser.c:6703
void xmlParseTextDecl(xmlParserCtxtPtr ctxt)
Definition: parser.c:6915
#define CUR_CONSUMED
Definition: parser.c:2170
void xmlParseMarkupDecl(xmlParserCtxtPtr ctxt)
Definition: parser.c:6866
static void xmlDetectSAX2(xmlParserCtxtPtr ctxt)
Definition: parser.c:1094
@ XML_ERR_EXT_SUBSET_NOT_FINISHED
Definition: xmlerror.h:160

Referenced by xmlSAX2ExternalSubset().

◆ xmlParseMarkupDecl()

XMLPUBFUN void XMLCALL xmlParseMarkupDecl ( xmlParserCtxtPtr  ctxt)

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.)

Definition at line 6866 of file parser.c.

6866 {
6867 GROW;
6868 if (CUR == '<') {
6869 if (NXT(1) == '!') {
6870 switch (NXT(2)) {
6871 case 'E':
6872 if (NXT(3) == 'L')
6873 xmlParseElementDecl(ctxt);
6874 else if (NXT(3) == 'N')
6875 xmlParseEntityDecl(ctxt);
6876 break;
6877 case 'A':
6879 break;
6880 case 'N':
6882 break;
6883 case '-':
6884 xmlParseComment(ctxt);
6885 break;
6886 default:
6887 /* there is an error but it will be detected later */
6888 break;
6889 }
6890 } else if (NXT(1) == '?') {
6891 xmlParsePI(ctxt);
6892 }
6893 }
6894
6895 /*
6896 * detect requirement to exit there and act accordingly
6897 * and avoid having instate overridden later on
6898 */
6899 if (ctxt->instate == XML_PARSER_EOF)
6900 return;
6901
6902 ctxt->instate = XML_PARSER_DTD;
6903}
void xmlParsePI(xmlParserCtxtPtr ctxt)
Definition: parser.c:5174
int xmlParseElementDecl(xmlParserCtxtPtr ctxt)
Definition: parser.c:6598
void xmlParseEntityDecl(xmlParserCtxtPtr ctxt)
Definition: parser.c:5409
void xmlParseComment(xmlParserCtxtPtr ctxt)
Definition: parser.c:4888
void xmlParseNotationDecl(xmlParserCtxtPtr ctxt)
Definition: parser.c:5331
void xmlParseAttributeListDecl(xmlParserCtxtPtr ctxt)
Definition: parser.c:5976

Referenced by xmlParseConditionalSections(), xmlParseExternalSubset(), and xmlParseInternalSubset().

◆ xmlParseMisc()

XMLPUBFUN void XMLCALL xmlParseMisc ( xmlParserCtxtPtr  ctxt)

xmlParseMisc: @ctxt: an XML parser context

parse an XML Misc* optional field.

[27] Misc ::= Comment | PI | S

Definition at line 10667 of file parser.c.

10667 {
10668 while (ctxt->instate != XML_PARSER_EOF) {
10670 GROW;
10671 if ((RAW == '<') && (NXT(1) == '?')) {
10672 xmlParsePI(ctxt);
10673 } else if (CMP4(CUR_PTR, '<', '!', '-', '-')) {
10674 xmlParseComment(ctxt);
10675 } else {
10676 break;
10677 }
10678 }
10679}
#define CMP4(s, c1, c2, c3, c4)
Definition: parser.c:2070

Referenced by xmlParseDocument().

◆ xmlParseName()

XMLPUBFUN const xmlChar *XMLCALL xmlParseName ( xmlParserCtxtPtr  ctxt)

Generic production rules.

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

Definition at line 3344 of file parser.c.

3344 {
3345 const xmlChar *in;
3346 const xmlChar *ret;
3347 size_t count = 0;
3348 size_t maxLength = (ctxt->options & XML_PARSE_HUGE) ?
3351
3352 GROW;
3353
3354#ifdef DEBUG
3355 nbParseName++;
3356#endif
3357
3358 /*
3359 * Accelerator for simple ASCII names
3360 */
3361 in = ctxt->input->cur;
3362 if (((*in >= 0x61) && (*in <= 0x7A)) ||
3363 ((*in >= 0x41) && (*in <= 0x5A)) ||
3364 (*in == '_') || (*in == ':')) {
3365 in++;
3366 while (((*in >= 0x61) && (*in <= 0x7A)) ||
3367 ((*in >= 0x41) && (*in <= 0x5A)) ||
3368 ((*in >= 0x30) && (*in <= 0x39)) ||
3369 (*in == '_') || (*in == '-') ||
3370 (*in == ':') || (*in == '.'))
3371 in++;
3372 if ((*in > 0) && (*in < 0x80)) {
3373 count = in - ctxt->input->cur;
3374 if (count > maxLength) {
3375 xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "Name");
3376 return(NULL);
3377 }
3378 ret = xmlDictLookup(ctxt->dict, ctxt->input->cur, count);
3379 ctxt->input->cur = in;
3380 ctxt->input->col += count;
3381 if (ret == NULL)
3382 xmlErrMemory(ctxt, NULL);
3383 return(ret);
3384 }
3385 }
3386 /* accelerator for special cases */
3387 return(xmlParseNameComplex(ctxt));
3388}
#define XML_MAX_NAME_LENGTH
XMLPUBFUN const xmlChar *XMLCALL xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:867
static const xmlChar * xmlParseNameComplex(xmlParserCtxtPtr ctxt)
Definition: parser.c:3203
@ XML_ERR_NAME_TOO_LONG
Definition: xmlerror.h:210

Referenced by xmlParseAttributeListDecl(), xmlParseDocTypeDecl(), xmlParseElementChildrenContentDeclPriv(), xmlParseElementDecl(), xmlParseElementMixedContentDecl(), xmlParseEntityDecl(), xmlParseEntityRef(), xmlParseNameAndCompare(), xmlParseNotationDecl(), xmlParseNotationType(), xmlParsePEReference(), xmlParsePITarget(), and xmlParseQName().

◆ xmlParseNmtoken()

XMLPUBFUN xmlChar *XMLCALL xmlParseNmtoken ( xmlParserCtxtPtr  ctxt)

xmlParseNmtoken: @ctxt: an XML parser context

parse an XML Nmtoken.

[7] Nmtoken ::= (NameChar)+

[8] Nmtokens ::= Nmtoken (#x20 Nmtoken)*

Returns the Nmtoken parsed or NULL

Definition at line 3662 of file parser.c.

3662 {
3664 int len = 0, l;
3665 int c;
3666 int count = 0;
3667 int maxLength = (ctxt->options & XML_PARSE_HUGE) ?
3670
3671#ifdef DEBUG
3672 nbParseNmToken++;
3673#endif
3674
3675 GROW;
3676 if (ctxt->instate == XML_PARSER_EOF)
3677 return(NULL);
3678 c = CUR_CHAR(l);
3679
3680 while (xmlIsNameChar(ctxt, c)) {
3681 if (