ReactOS  0.4.15-dev-1389-g828d5fa
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)
 
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 519 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 501 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 513 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 507 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 1749 of file parser.c.

1750 {
1752 
1753  if (ctxt == NULL)
1754  return(NULL);
1755  if (ctxt->inputNr <= 0)
1756  return (NULL);
1757  ctxt->inputNr--;
1758  if (ctxt->inputNr > 0)
1759  ctxt->input = ctxt->inputTab[ctxt->inputNr - 1];
1760  else
1761  ctxt->input = NULL;
1762  ret = ctxt->inputTab[ctxt->inputNr];
1763  ctxt->inputTab[ctxt->inputNr] = NULL;
1764  return (ret);
1765 }
xmlParserInputPtr * inputTab
Definition: parser.h:202
xmlParserInputPtr input
Definition: parser.h:199
int ret
#define NULL
Definition: types.h:112

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 1718 of file parser.c.

1719 {
1720  if ((ctxt == NULL) || (value == NULL))
1721  return(-1);
1722  if (ctxt->inputNr >= ctxt->inputMax) {
1723  ctxt->inputMax *= 2;
1724  ctxt->inputTab =
1726  ctxt->inputMax *
1727  sizeof(ctxt->inputTab[0]));
1728  if (ctxt->inputTab == NULL) {
1729  xmlErrMemory(ctxt, NULL);
1731  ctxt->inputMax /= 2;
1732  value = NULL;
1733  return (-1);
1734  }
1735  }
1736  ctxt->inputTab[ctxt->inputNr] = value;
1737  ctxt->input = value;
1738  return (ctxt->inputNr++);
1739 }
xmlParserInputPtr * inputTab
Definition: parser.h:202
xmlParserInputPtr input
Definition: parser.h:199
XMLPUBFUN void XMLCALL xmlFreeInputStream(xmlParserInputPtr input)
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:249
int inputMax
Definition: parser.h:201
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
GLsizei const GLfloat * value
Definition: glext.h:6069
#define NULL
Definition: types.h:112

Referenced by testSAX(), xmlCreateEntityParserCtxtInternal(), xmlCreateIOParserCtxt(), xmlCreateMemoryParserCtxt(), xmlCreateURLParserCtxt(), xmlCtxtReadDoc(), 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 1950 of file parser.c.

1951 {
1952  const xmlChar *ret;
1953 
1954  if ((ctxt == NULL) || (ctxt->nameNr <= 0))
1955  return (NULL);
1956  ctxt->nameNr--;
1957  if (ctxt->nameNr > 0)
1958  ctxt->name = ctxt->nameTab[ctxt->nameNr - 1];
1959  else
1960  ctxt->name = NULL;
1961  ret = ctxt->nameTab[ctxt->nameNr];
1962  ctxt->nameTab[ctxt->nameNr] = NULL;
1963  return (ret);
1964 }
const xmlChar * name
Definition: parser.h:229
int ret
unsigned char xmlChar
Definition: xmlstring.h:28
#define NULL
Definition: types.h:112
const xmlChar ** nameTab
Definition: parser.h:232

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 1919 of file parser.c.

1920 {
1921  if (ctxt == NULL) return (-1);
1922 
1923  if (ctxt->nameNr >= ctxt->nameMax) {
1924  const xmlChar * *tmp;
1925  tmp = (const xmlChar * *) xmlRealloc((xmlChar * *)ctxt->nameTab,
1926  ctxt->nameMax * 2 *
1927  sizeof(ctxt->nameTab[0]));
1928  if (tmp == NULL) {
1929  goto mem_error;
1930  }
1931  ctxt->nameTab = tmp;
1932  ctxt->nameMax *= 2;
1933  }
1934  ctxt->nameTab[ctxt->nameNr] = value;
1935  ctxt->name = value;
1936  return (ctxt->nameNr++);
1937 mem_error:
1938  xmlErrMemory(ctxt, NULL);
1939  return (-1);
1940 }
const xmlChar * name
Definition: parser.h:229
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:249
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
unsigned char xmlChar
Definition: xmlstring.h:28
GLsizei const GLfloat * value
Definition: glext.h:6069
#define NULL
Definition: types.h:112
const xmlChar ** nameTab
Definition: parser.h:232

Referenced by xmlParseElementStart().

◆ nodePop()

nodePop: @ctxt: an XML parser context

Pops the top element node from the node stack

Returns the node just removed

Definition at line 1814 of file parser.c.

1815 {
1816  xmlNodePtr ret;
1817 
1818  if (ctxt == NULL) return(NULL);
1819  if (ctxt->nodeNr <= 0)
1820  return (NULL);
1821  ctxt->nodeNr--;
1822  if (ctxt->nodeNr > 0)
1823  ctxt->node = ctxt->nodeTab[ctxt->nodeNr - 1];
1824  else
1825  ctxt->node = NULL;
1826  ret = ctxt->nodeTab[ctxt->nodeNr];
1827  ctxt->nodeTab[ctxt->nodeNr] = NULL;
1828  return (ret);
1829 }
xmlNodePtr * nodeTab
Definition: parser.h:208
xmlNodePtr node
Definition: parser.h:205
Definition: tree.h:489
int ret
#define NULL
Definition: types.h:112

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 1776 of file parser.c.

1777 {
1778  if (ctxt == NULL) return(0);
1779  if (ctxt->nodeNr >= ctxt->nodeMax) {
1780  xmlNodePtr *tmp;
1781 
1782  tmp = (xmlNodePtr *) xmlRealloc(ctxt->nodeTab,
1783  ctxt->nodeMax * 2 *
1784  sizeof(ctxt->nodeTab[0]));
1785  if (tmp == NULL) {
1786  xmlErrMemory(ctxt, NULL);
1787  return (-1);
1788  }
1789  ctxt->nodeTab = tmp;
1790  ctxt->nodeMax *= 2;
1791  }
1792  if ((((unsigned int) ctxt->nodeNr) > xmlParserMaxDepth) &&
1793  ((ctxt->options & XML_PARSE_HUGE) == 0)) {
1794  xmlFatalErrMsgInt(ctxt, XML_ERR_INTERNAL_ERROR,
1795  "Excessive depth in document: %d use XML_PARSE_HUGE option\n",
1797  xmlHaltParser(ctxt);
1798  return(-1);
1799  }
1800  ctxt->nodeTab[ctxt->nodeNr] = value;
1801  ctxt->node = value;
1802  return (ctxt->nodeNr++);
1803 }
xmlNodePtr * nodeTab
Definition: parser.h:208
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:249
xmlNodePtr node
Definition: parser.h:205
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
unsigned int xmlParserMaxDepth
Definition: parser.c:251
Definition: tree.h:489
GLsizei const GLfloat * value
Definition: glext.h:6069
#define NULL
Definition: types.h:112
static void xmlHaltParser(xmlParserCtxtPtr ctxt)
Definition: parser.c:12478

Referenced by xmlParseBalancedChunkMemoryInternal(), xmlParseCtxtExternalEntity(), 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 1447 of file parser.c.

1448 {
1449  const xmlChar *cur = lang, *nxt;
1450 
1451  if (cur == NULL)
1452  return (0);
1453  if (((cur[0] == 'i') && (cur[1] == '-')) ||
1454  ((cur[0] == 'I') && (cur[1] == '-')) ||
1455  ((cur[0] == 'x') && (cur[1] == '-')) ||
1456  ((cur[0] == 'X') && (cur[1] == '-'))) {
1457  /*
1458  * Still allow IANA code and user code which were coming
1459  * from the previous version of the XML-1.0 specification
1460  * it's deprecated but we should not fail
1461  */
1462  cur += 2;
1463  while (((cur[0] >= 'A') && (cur[0] <= 'Z')) ||
1464  ((cur[0] >= 'a') && (cur[0] <= 'z')))
1465  cur++;
1466  return(cur[0] == 0);
1467  }
1468  nxt = cur;
1469  while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) ||
1470  ((nxt[0] >= 'a') && (nxt[0] <= 'z')))
1471  nxt++;
1472  if (nxt - cur >= 4) {
1473  /*
1474  * Reserved
1475  */
1476  if ((nxt - cur > 8) || (nxt[0] != 0))
1477  return(0);
1478  return(1);
1479  }
1480  if (nxt - cur < 2)
1481  return(0);
1482  /* we got an ISO 639 code */
1483  if (nxt[0] == 0)
1484  return(1);
1485  if (nxt[0] != '-')
1486  return(0);
1487 
1488  nxt++;
1489  cur = nxt;
1490  /* now we can have extlang or script or region or variant */
1491  if ((nxt[0] >= '0') && (nxt[0] <= '9'))
1492  goto region_m49;
1493 
1494  while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) ||
1495  ((nxt[0] >= 'a') && (nxt[0] <= 'z')))
1496  nxt++;
1497  if (nxt - cur == 4)
1498  goto script;
1499  if (nxt - cur == 2)
1500  goto region;
1501  if ((nxt - cur >= 5) && (nxt - cur <= 8))
1502  goto variant;
1503  if (nxt - cur != 3)
1504  return(0);
1505  /* we parsed an extlang */
1506  if (nxt[0] == 0)
1507  return(1);
1508  if (nxt[0] != '-')
1509  return(0);
1510 
1511  nxt++;
1512  cur = nxt;
1513  /* now we can have script or region or variant */
1514  if ((nxt[0] >= '0') && (nxt[0] <= '9'))
1515  goto region_m49;
1516 
1517  while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) ||
1518  ((nxt[0] >= 'a') && (nxt[0] <= 'z')))
1519  nxt++;
1520  if (nxt - cur == 2)
1521  goto region;
1522  if ((nxt - cur >= 5) && (nxt - cur <= 8))
1523  goto variant;
1524  if (nxt - cur != 4)
1525  return(0);
1526  /* we parsed a script */
1527 script:
1528  if (nxt[0] == 0)
1529  return(1);
1530  if (nxt[0] != '-')
1531  return(0);
1532 
1533  nxt++;
1534  cur = nxt;
1535  /* now we can have region or variant */
1536  if ((nxt[0] >= '0') && (nxt[0] <= '9'))
1537  goto region_m49;
1538 
1539  while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) ||
1540  ((nxt[0] >= 'a') && (nxt[0] <= 'z')))
1541  nxt++;
1542 
1543  if ((nxt - cur >= 5) && (nxt - cur <= 8))
1544  goto variant;
1545  if (nxt - cur != 2)
1546  return(0);
1547  /* we parsed a region */
1548 region:
1549  if (nxt[0] == 0)
1550  return(1);
1551  if (nxt[0] != '-')
1552  return(0);
1553 
1554  nxt++;
1555  cur = nxt;
1556  /* now we can just have a variant */
1557  while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) ||
1558  ((nxt[0] >= 'a') && (nxt[0] <= 'z')))
1559  nxt++;
1560 
1561  if ((nxt - cur < 5) || (nxt - cur > 8))
1562  return(0);
1563 
1564  /* we parsed a variant */
1565 variant:
1566  if (nxt[0] == 0)
1567  return(1);
1568  if (nxt[0] != '-')
1569  return(0);
1570  /* extensions and private use subtags not checked */
1571  return (1);
1572 
1573 region_m49:
1574  if (((nxt[1] >= '0') && (nxt[1] <= '9')) &&
1575  ((nxt[2] >= '0') && (nxt[2] <= '9'))) {
1576  nxt += 3;
1577  goto region;
1578  }
1579  return(0);
1580 }
script
Definition: msipriv.h:374
static const WCHAR lang[]
Definition: wbemdisp.c:287
unsigned char xmlChar
Definition: xmlstring.h:28
FxCollectionEntry * cur
#define NULL
Definition: types.h:112

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 900 of file parserInternals.c.

900  {
901  if (out == NULL) return(0);
902  /* the len parameter is ignored */
903  if (val >= 0x80) {
904  return(xmlCopyCharMultiByte (out, val));
905  }
906  *out = (xmlChar) val;
907  return 1;
908 }
int xmlCopyCharMultiByte(xmlChar *out, int val)
GLuint GLfloat * val
Definition: glext.h:7180
static FILE * out
Definition: regtests2xml.c:44
unsigned char xmlChar
Definition: xmlstring.h:28
#define NULL
Definition: types.h:112

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 857 of file parserInternals.c.

857  {
858  if (out == NULL) return(0);
859  /*
860  * We are supposed to handle UTF8, check it's valid
861  * From rfc2044: encoding of the Unicode values on UTF-8:
862  *
863  * UCS-4 range (hex.) UTF-8 octet sequence (binary)
864  * 0000 0000-0000 007F 0xxxxxxx
865  * 0000 0080-0000 07FF 110xxxxx 10xxxxxx
866  * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx
867  */
868  if (val >= 0x80) {
869  xmlChar *savedout = out;
870  int bits;
871  if (val < 0x800) { *out++= (val >> 6) | 0xC0; bits= 0; }
872  else if (val < 0x10000) { *out++= (val >> 12) | 0xE0; bits= 6;}
873  else if (val < 0x110000) { *out++= (val >> 18) | 0xF0; bits= 12; }
874  else {
875  xmlErrEncodingInt(NULL, XML_ERR_INVALID_CHAR,
876  "Internal error, xmlCopyCharMultiByte 0x%X out of bound\n",
877  val);
878  return(0);
879  }
880  for ( ; bits >= 0; bits-= 6)
881  *out++= ((val >> bits) & 0x3F) | 0x80 ;
882  return (out - savedout);
883  }
884  *out = (xmlChar) val;
885  return 1;
886 }
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
GLuint GLfloat * val
Definition: glext.h:7180
static FILE * out
Definition: regtests2xml.c:44
unsigned char xmlChar
Definition: xmlstring.h:28
#define NULL
Definition: types.h:112

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 14091 of file parser.c.

14092  {
14094 
14095 }
static xmlParserCtxtPtr xmlCreateEntityParserCtxtInternal(const xmlChar *URL, const xmlChar *ID, const xmlChar *base, xmlParserCtxtPtr pctx)
Definition: parser.c:14018
#define ID
Definition: ruserpass.c:36
#define NULL
Definition: types.h:112

◆ 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 14157 of file parser.c.

14158 {
14159  return(xmlCreateURLParserCtxt(filename, 0));
14160 }
const char * filename
Definition: ioapi.h:135
xmlParserCtxtPtr xmlCreateURLParserCtxt(const char *filename, int options)
Definition: parser.c:14115

◆ 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 14403 of file parser.c.

14403  {
14404  xmlParserCtxtPtr ctxt;
14407 
14408  if (buffer == NULL)
14409  return(NULL);
14410  if (size <= 0)
14411  return(NULL);
14412 
14413  ctxt = xmlNewParserCtxt();
14414  if (ctxt == NULL)
14415  return(NULL);
14416 
14417  /* TODO: xmlParserInputBufferCreateStatic, requires some serious changes */
14419  if (buf == NULL) {
14420  xmlFreeParserCtxt(ctxt);
14421  return(NULL);
14422  }
14423 
14424  input = xmlNewInputStream(ctxt);
14425  if (input == NULL) {
14427  xmlFreeParserCtxt(ctxt);
14428  return(NULL);
14429  }
14430 
14431  input->filename = NULL;
14432  input->buf = buf;
14433  xmlBufResetInput(input->buf->buffer, input);
14434 
14435  inputPush(ctxt, input);
14436  return(ctxt);
14437 }
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1718
XMLPUBFUN void XMLCALL xmlFreeParserInputBuffer(xmlParserInputBufferPtr in)
XMLPUBFUN void XMLCALL xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
GLuint buffer
Definition: glext.h:5915
int xmlBufResetInput(xmlBufPtr buf, xmlParserInputPtr input)
Definition: buf.c:1283
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateMem(const char *mem, int size, xmlCharEncoding enc)
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLsizeiptr size
Definition: glext.h:5919
GLenum GLenum GLenum input
Definition: glext.h:9031
#define NULL
Definition: types.h:112
XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlNewParserCtxt(void)
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewInputStream(xmlParserCtxtPtr ctxt)

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 14115 of file parser.c.

14116 {
14117  xmlParserCtxtPtr ctxt;
14118  xmlParserInputPtr inputStream;
14119  char *directory = NULL;
14120 
14121  ctxt = xmlNewParserCtxt();
14122  if (ctxt == NULL) {
14123  xmlErrMemory(NULL, "cannot allocate parser context");
14124  return(NULL);
14125  }
14126 
14127  if (options)
14129  ctxt->linenumbers = 1;
14130 
14131  inputStream = xmlLoadExternalEntity(filename, NULL, ctxt);
14132  if (inputStream == NULL) {
14133  xmlFreeParserCtxt(ctxt);
14134  return(NULL);
14135  }
14136 
14137  inputPush(ctxt, inputStream);
14138  if ((ctxt->directory == NULL) && (directory == NULL))
14140  if ((ctxt->directory == NULL) && (directory != NULL))
14141  ctxt->directory = directory;
14142 
14143  return(ctxt);
14144 }
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1718
XMLPUBFUN char *XMLCALL xmlParserGetDirectory(const char *filename)
XMLPUBFUN void XMLCALL xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
const char * filename
Definition: ioapi.h:135
int linenumbers
Definition: parser.h:259
static int xmlCtxtUseOptionsInternal(xmlParserCtxtPtr ctxt, int options, const char *encoding)
Definition: parser.c:15045
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
XMLPUBFUN xmlParserInputPtr XMLCALL xmlLoadExternalEntity(const char *URL, const char *ID, xmlParserCtxtPtr ctxt)
#define NULL
Definition: types.h:112
char * directory
Definition: parser.h:226
XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlNewParserCtxt(void)

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 588 of file parserInternals.c.

588  {
589  if ((ctxt == NULL) || (len == NULL) || (ctxt->input == NULL)) return(0);
590  if (ctxt->instate == XML_PARSER_EOF)
591  return(0);
592 
593  if ((*ctxt->input->cur >= 0x20) && (*ctxt->input->cur <= 0x7F)) {
594  *len = 1;
595  return((int) *ctxt->input->cur);
596  }
597  if (ctxt->charset == XML_CHAR_ENCODING_UTF8) {
598  /*
599  * We are supposed to handle UTF8, check it's valid
600  * From rfc2044: encoding of the Unicode values on UTF-8:
601  *
602  * UCS-4 range (hex.) UTF-8 octet sequence (binary)
603  * 0000 0000-0000 007F 0xxxxxxx
604  * 0000 0080-0000 07FF 110xxxxx 10xxxxxx
605  * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx
606  *
607  * Check for the 0x110000 limit too
608  */
609  const unsigned char *cur = ctxt->input->cur;
610  unsigned char c;
611  unsigned int val;
612 
613  c = *cur;
614  if (c & 0x80) {
615  if (((c & 0x40) == 0) || (c == 0xC0))
616  goto encoding_error;
617  if (cur[1] == 0) {
619  cur = ctxt->input->cur;
620  }
621  if ((cur[1] & 0xc0) != 0x80)
622  goto encoding_error;
623  if ((c & 0xe0) == 0xe0) {
624  if (cur[2] == 0) {
626  cur = ctxt->input->cur;
627  }
628  if ((cur[2] & 0xc0) != 0x80)
629  goto encoding_error;
630  if ((c & 0xf0) == 0xf0) {
631  if (cur[3] == 0) {
633  cur = ctxt->input->cur;
634  }
635  if (((c & 0xf8) != 0xf0) ||
636  ((cur[3] & 0xc0) != 0x80))
637  goto encoding_error;
638  /* 4-byte code */
639  *len = 4;
640  val = (cur[0] & 0x7) << 18;
641  val |= (cur[1] & 0x3f) << 12;
642  val |= (cur[2] & 0x3f) << 6;
643  val |= cur[3] & 0x3f;
644  if (val < 0x10000)
645  goto encoding_error;
646  } else {
647  /* 3-byte code */
648  *len = 3;
649  val = (cur[0] & 0xf) << 12;
650  val |= (cur[1] & 0x3f) << 6;
651  val |= cur[2] & 0x3f;
652  if (val < 0x800)
653  goto encoding_error;
654  }
655  } else {
656  /* 2-byte code */
657  *len = 2;
658  val = (cur[0] & 0x1f) << 6;
659  val |= cur[1] & 0x3f;
660  if (val < 0x80)
661  goto encoding_error;
662  }
663  if (!IS_CHAR(val)) {
664  xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR,
665  "Char 0x%X out of allowed range\n", val);
666  }
667  return(val);
668  } else {
669  /* 1-byte code */
670  *len = 1;
671  if (*ctxt->input->cur == 0)
673  if ((*ctxt->input->cur == 0) &&
674  (ctxt->input->end > ctxt->input->cur)) {
675  xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR,
676  "Char 0x0 out of allowed range\n", 0);
677  }
678  if (*ctxt->input->cur == 0xD) {
679  if (ctxt->input->cur[1] == 0xA) {
680  ctxt->nbChars++;
681  ctxt->input->cur++;
682  }
683  return(0xA);
684  }
685  return((int) *ctxt->input->cur);
686  }
687  }
688  /*
689  * Assume it's a fixed length encoding (1) with
690  * a compatible encoding for the ASCII set, since
691  * XML constructs only use < 128 chars
692  */
693  *len = 1;
694  if (*ctxt->input->cur == 0xD) {
695  if (ctxt->input->cur[1] == 0xA) {
696  ctxt->nbChars++;
697  ctxt->input->cur++;
698  }
699  return(0xA);
700  }
701  return((int) *ctxt->input->cur);
702 encoding_error:
703  /*
704  * An encoding problem may arise from a truncated input buffer
705  * splitting a character in the middle. In that case do not raise
706  * an error but return 0 to indicate an end of stream problem
707  */
708  if (ctxt->input->end - ctxt->input->cur < 4) {
709  *len = 0;
710  return(0);
711  }
712 
713  /*
714  * If we detect an UTF8 error that probably mean that the
715  * input encoding didn't get properly advertised in the
716  * declaration header. Report the error and switch the encoding
717  * to ISO-Latin-1 (if you don't like this policy, just declare the
718  * encoding !)
719  */
720  {
721  char buffer[150];
722 
723  snprintf(&buffer[0], 149, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
724  ctxt->input->cur[0], ctxt->input->cur[1],
725  ctxt->input->cur[2], ctxt->input->cur[3]);
727  "Input is not proper UTF-8, indicate encoding !\n%s",
728  BAD_CAST buffer, NULL);
729  }
731  *len = 1;
732  return((int) *ctxt->input->cur);
733 }
xmlParserInputState instate
Definition: parser.h:223
const xmlChar * cur
Definition: parser.h:61
#define snprintf
Definition: wintirpc.h:48
GLuint buffer
Definition: glext.h:5915
long nbChars
Definition: parser.h:234
xmlParserInputPtr input
Definition: parser.h:199
#define IS_CHAR(c)
#define BAD_CAST
Definition: xmlstring.h:35
GLuint GLfloat * val
Definition: glext.h:7180
const GLubyte * c
Definition: glext.h:8905
void __xmlErrEncoding(xmlParserCtxtPtr ctxt, xmlParserErrors xmlerr, const char *msg, const xmlChar *str1, const xmlChar *str2)
GLenum GLsizei len
Definition: glext.h:6722
#define INPUT_CHUNK
FxCollectionEntry * cur
#define NULL
Definition: types.h:112
int xmlParserInputGrow(xmlParserInputPtr in, int len)
#define c
Definition: ke_i.h:80
const xmlChar * end
Definition: parser.h:62

◆ xmlFreeInputStream()

XMLPUBFUN void XMLCALL xmlFreeInputStream ( xmlParserInputPtr  input)

xmlFreeInputStream: @input: an xmlParserInputPtr

Free up an input stream.

Definition at line 1339 of file parserInternals.c.

1339  {
1340  if (input == NULL) return;
1341 
1342  if (input->filename != NULL) xmlFree((char *) input->filename);
1343  if (input->directory != NULL) xmlFree((char *) input->directory);
1344  if (input->encoding != NULL) xmlFree((char *) input->encoding);
1345  if (input->version != NULL) xmlFree((char *) input->version);
1346  if ((input->free != NULL) && (input->base != NULL))
1347  input->free((xmlChar *) input->base);
1348  if (input->buf != NULL)
1350  xmlFree(input);
1351 }
XMLPUBFUN void XMLCALL xmlFreeParserInputBuffer(xmlParserInputBufferPtr in)
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
unsigned char xmlChar
Definition: xmlstring.h:28
GLenum GLenum GLenum input
Definition: glext.h:9031
#define NULL
Definition: types.h:112

Referenced by inputPush(), xmlCtxtReset(), xmlFreeParserCtxt(), xmlHaltParser(), xmlInitParserCtxt(), 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 229 of file parserInternals.c.

229  {
230  return(IS_BASECHAR(c) || IS_IDEOGRAPHIC(c));
231 }
#define IS_IDEOGRAPHIC(c)
#define IS_BASECHAR(c)
const GLubyte * c
Definition: glext.h:8905

◆ 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 1430 of file parserInternals.c.

1430  {
1432 
1433  if (entity == NULL) {
1434  xmlErrInternal(ctxt, "xmlNewEntityInputStream entity = NULL\n",
1435  NULL);
1436  return(NULL);
1437  }
1440  "new input from entity: %s\n", entity->name);
1441  if (entity->content == NULL) {
1442  switch (entity->etype) {
1444  xmlErrInternal(ctxt, "Cannot parse entity %s\n",
1445  entity->name);
1446  break;
1449  return(xmlLoadExternalEntity((char *) entity->URI,
1450  (char *) entity->ExternalID, ctxt));
1452  xmlErrInternal(ctxt,
1453  "Internal entity %s without content !\n",
1454  entity->name);
1455  break;
1457  xmlErrInternal(ctxt,
1458  "Internal parameter entity %s without content !\n",
1459  entity->name);
1460  break;
1462  xmlErrInternal(ctxt,
1463  "Predefined entity %s without content !\n",
1464  entity->name);
1465  break;
1466  }
1467  return(NULL);
1468  }
1469  input = xmlNewInputStream(ctxt);
1470  if (input == NULL) {
1471  return(NULL);
1472  }
1473  if (entity->URI != NULL)
1474  input->filename = (char *) xmlStrdup((xmlChar *) entity->URI);
1475  input->base = entity->content;
1476  if (entity->length == 0)
1477  entity->length = xmlStrlen(entity->content);
1478  input->cur = entity->content;
1479  input->length = entity->length;
1480  input->end = &entity->content[input->length];
1481  return(input);
1482 }
XMLPUBFUN int XMLCALL xmlStrlen(const xmlChar *str)
Definition: xmlstring.c:422
Definition: actctx.c:387
WCHAR * name
Definition: actctx.c:405
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
xmlParserInputPtr xmlNewInputStream(xmlParserCtxtPtr ctxt)
unsigned char xmlChar
Definition: xmlstring.h:28
XMLPUBFUN xmlParserInputPtr XMLCALL xmlLoadExternalEntity(const char *URL, const char *ID, xmlParserCtxtPtr ctxt)
GLenum GLenum GLenum input
Definition: glext.h:9031
XMLPUBVAR int xmlParserDebugEntities
Definition: globals.h:432
#define NULL
Definition: types.h:112
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:66
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

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 1526 of file parserInternals.c.

1526  {
1528  xmlParserInputPtr inputStream;
1529  char *directory = NULL;
1530  xmlChar *URI = NULL;
1531 
1534  "new input from file: %s\n", filename);
1535  if (ctxt == NULL) return(NULL);
1537  if (buf == NULL) {
1538  if (filename == NULL)
1539  __xmlLoaderErr(ctxt,
1540  "failed to load external entity: NULL filename \n",
1541  NULL);
1542  else
1543  __xmlLoaderErr(ctxt, "failed to load external entity \"%s\"\n",
1544  (const char *) filename);
1545  return(NULL);
1546  }
1547 
1548  inputStream = xmlNewInputStream(ctxt);
1549  if (inputStream == NULL)
1550  return(NULL);
1551 
1552  inputStream->buf = buf;
1553  inputStream = xmlCheckHTTPInput(ctxt, inputStream);
1554  if (inputStream == NULL)
1555  return(NULL);
1556 
1557  if (inputStream->filename == NULL)
1558  URI = xmlStrdup((xmlChar *) filename);
1559  else
1560  URI = xmlStrdup((xmlChar *) inputStream->filename);
1561  directory = xmlParserGetDirectory((const char *) URI);
1562  if (inputStream->filename != NULL) xmlFree((char *)inputStream->filename);
1563  inputStream->filename = (char *) xmlCanonicPath((const xmlChar *) URI);
1564  if (URI != NULL) xmlFree((char *) URI);
1565  inputStream->directory = directory;
1566 
1567  xmlBufResetInput(inputStream->buf->buffer, inputStream);
1568  if ((ctxt->directory == NULL) && (directory != NULL))
1569  ctxt->directory = (char *) xmlStrdup((const xmlChar *) directory);
1570  return(inputStream);
1571 }
void __xmlLoaderErr(void *ctx, const char *msg, const char *filename) LIBXML_ATTR_FORMAT(2
XMLPUBFUN char *XMLCALL xmlParserGetDirectory(const char *filename)
int xmlBufResetInput(xmlBufPtr buf, xmlParserInputPtr input)
Definition: buf.c:1283
const char * filename
Definition: ioapi.h:135
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
XMLPUBFUN xmlChar *XMLCALL xmlCanonicPath(const xmlChar *path)
Definition: uri.c:2372
xmlBufPtr buffer
Definition: xmlIO.h:132
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc)
xmlParserInputPtr xmlNewInputStream(xmlParserCtxtPtr ctxt)
unsigned char xmlChar
Definition: xmlstring.h:28
XMLPUBFUN xmlParserInputPtr XMLCALL xmlCheckHTTPInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr ret)
xmlParserInputBufferPtr buf
Definition: parser.h:56
const char * filename
Definition: parser.h:58
XMLPUBVAR int xmlParserDebugEntities
Definition: globals.h:432
#define NULL
Definition: types.h:112
char * directory
Definition: parser.h:226
const char * directory
Definition: parser.h:59
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:66
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

◆ 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 1362 of file parserInternals.c.

1362  {
1364 
1366  if (input == NULL) {
1367  xmlErrMemory(ctxt, "couldn't allocate a new input stream\n");
1368  return(NULL);
1369  }
1370  memset(input, 0, sizeof(xmlParserInput));
1371  input->line = 1;
1372  input->col = 1;
1373  input->standalone = -1;
1374 
1375  /*
1376  * If the context is NULL the id cannot be initialized, but that
1377  * should not happen while parsing which is the situation where
1378  * the id is actually needed.
1379  */
1380  if (ctxt != NULL)
1381  input->id = ctxt->input_id++;
1382 
1383  return(input);
1384 }
xmlParserInput * xmlParserInputPtr
Definition: tree.h:36
int input_id
Definition: parser.h:312
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
GLenum GLenum GLenum input
Definition: glext.h:9031
#define NULL
Definition: types.h:112
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
#define memset(x, y, z)
Definition: compat.h:39

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 1493 of file parserInternals.c.

1493  {
1495 
1496  if (buffer == NULL) {
1497  xmlErrInternal(ctxt, "xmlNewStringInputStream string = NULL\n",
1498  NULL);
1499  return(NULL);
1500  }
1503  "new fixed input: %.30s\n", buffer);
1504  input = xmlNewInputStream(ctxt);
1505  if (input == NULL) {
1506  xmlErrMemory(ctxt, "couldn't allocate a new input stream\n");
1507  return(NULL);
1508  }
1509  input->base = buffer;
1510  input->cur = buffer;
1511  input->length = xmlStrlen(buffer);
1512  input->end = &buffer[input->length];
1513  return(input);
1514 }
XMLPUBFUN int XMLCALL xmlStrlen(const xmlChar *str)
Definition: xmlstring.c:422
GLuint buffer
Definition: glext.h:5915
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
xmlParserInputPtr xmlNewInputStream(xmlParserCtxtPtr ctxt)
GLenum GLenum GLenum input
Definition: glext.h:9031
XMLPUBVAR int xmlParserDebugEntities
Definition: globals.h:432
#define NULL
Definition: types.h:112
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

Referenced by xmlCtxtReadDoc().

◆ xmlNextChar()

XMLPUBFUN void XMLCALL xmlNextChar ( xmlParserCtxtPtr  ctxt)

xmlNextChar: @ctxt: the XML parser context

Skip to the next char input char.

Definition at line 423 of file parserInternals.c.

424 {
425  if ((ctxt == NULL) || (ctxt->instate == XML_PARSER_EOF) ||
426  (ctxt->input == NULL))
427  return;
428 
429  if (!(VALID_CTXT(ctxt))) {
430  xmlErrInternal(ctxt, "Parser input data memory error\n", NULL);
432  xmlStopParser(ctxt);
433  return;
434  }
435 
436  if ((*ctxt->input->cur == 0) &&
437  (xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0)) {
438  return;
439  }
440 
441  if (ctxt->charset == XML_CHAR_ENCODING_UTF8) {
442  const unsigned char *cur;
443  unsigned char c;
444 
445  /*
446  * 2.11 End-of-Line Handling
447  * the literal two-character sequence "#xD#xA" or a standalone
448  * literal #xD, an XML processor must pass to the application
449  * the single character #xA.
450  */
451  if (*(ctxt->input->cur) == '\n') {
452  ctxt->input->line++; ctxt->input->col = 1;
453  } else
454  ctxt->input->col++;
455 
456  /*
457  * We are supposed to handle UTF8, check it's valid
458  * From rfc2044: encoding of the Unicode values on UTF-8:
459  *
460  * UCS-4 range (hex.) UTF-8 octet sequence (binary)
461  * 0000 0000-0000 007F 0xxxxxxx
462  * 0000 0080-0000 07FF 110xxxxx 10xxxxxx
463  * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx
464  *
465  * Check for the 0x110000 limit too
466  */
467  cur = ctxt->input->cur;
468 
469  c = *cur;
470  if (c & 0x80) {
471  if (c == 0xC0)
472  goto encoding_error;
473  if (cur[1] == 0) {
475  cur = ctxt->input->cur;
476  }
477  if ((cur[1] & 0xc0) != 0x80)
478  goto encoding_error;
479  if ((c & 0xe0) == 0xe0) {
480  unsigned int val;
481 
482  if (cur[2] == 0) {
484  cur = ctxt->input->cur;
485  }
486  if ((cur[2] & 0xc0) != 0x80)
487  goto encoding_error;
488  if ((c & 0xf0) == 0xf0) {
489  if (cur[3] == 0) {
491  cur = ctxt->input->cur;
492  }
493  if (((c & 0xf8) != 0xf0) ||
494  ((cur[3] & 0xc0) != 0x80))
495  goto encoding_error;
496  /* 4-byte code */
497  ctxt->input->cur += 4;
498  val = (cur[0] & 0x7) << 18;
499  val |= (cur[1] & 0x3f) << 12;
500  val |= (cur[2] & 0x3f) << 6;
501  val |= cur[3] & 0x3f;
502  } else {
503  /* 3-byte code */
504  ctxt->input->cur += 3;
505  val = (cur[0] & 0xf) << 12;
506  val |= (cur[1] & 0x3f) << 6;
507  val |= cur[2] & 0x3f;
508  }
509  if (((val > 0xd7ff) && (val < 0xe000)) ||
510  ((val > 0xfffd) && (val < 0x10000)) ||
511  (val >= 0x110000)) {
512  xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR,
513  "Char 0x%X out of allowed range\n",
514  val);
515  }
516  } else
517  /* 2-byte code */
518  ctxt->input->cur += 2;
519  } else
520  /* 1-byte code */
521  ctxt->input->cur++;
522 
523  ctxt->nbChars++;
524  } else {
525  /*
526  * Assume it's a fixed length encoding (1) with
527  * a compatible encoding for the ASCII set, since
528  * XML constructs only use < 128 chars
529  */
530 
531  if (*(ctxt->input->cur) == '\n') {
532  ctxt->input->line++; ctxt->input->col = 1;
533  } else
534  ctxt->input->col++;
535  ctxt->input->cur++;
536  ctxt->nbChars++;
537  }
538  if (*ctxt->input->cur == 0)
540  return;
541 encoding_error:
542  /*
543  * If we detect an UTF8 error that probably mean that the
544  * input encoding didn't get properly advertised in the
545  * declaration header. Report the error and switch the encoding
546  * to ISO-Latin-1 (if you don't like this policy, just declare the
547  * encoding !)
548  */
549  if ((ctxt == NULL) || (ctxt->input == NULL) ||
550  (ctxt->input->end - ctxt->input->cur < 4)) {
552  "Input is not proper UTF-8, indicate encoding !\n",
553  NULL, NULL);
554  } else {
555  char buffer[150];
556 
557  snprintf(buffer, 149, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
558  ctxt->input->cur[0], ctxt->input->cur[1],
559  ctxt->input->cur[2], ctxt->input->cur[3]);
561  "Input is not proper UTF-8, indicate encoding !\n%s",
562  BAD_CAST buffer, NULL);
563  }
565  ctxt->input->cur++;
566  return;
567 }
xmlParserInputState instate
Definition: parser.h:223
#define VALID_CTXT(ctxt)
const xmlChar * cur
Definition: parser.h:61
#define snprintf
Definition: wintirpc.h:48
GLuint buffer
Definition: glext.h:5915
XMLPUBFUN void XMLCALL xmlStopParser(xmlParserCtxtPtr ctxt)
Definition: parser.c:12512
long nbChars
Definition: parser.h:234
xmlParserInputPtr input
Definition: parser.h:199
#define BAD_CAST
Definition: xmlstring.h:35
GLuint GLfloat * val
Definition: glext.h:7180
const GLubyte * c
Definition: glext.h:8905
void __xmlErrEncoding(xmlParserCtxtPtr ctxt, xmlParserErrors xmlerr, const char *msg, const xmlChar *str1, const xmlChar *str2)
#define INPUT_CHUNK
FxCollectionEntry * cur
#define NULL
Definition: types.h:112
int xmlParserInputGrow(xmlParserInputPtr in, int len)
#define c
Definition: ke_i.h:80
const xmlChar * end
Definition: parser.h:62

◆ 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 5926 of file parser.c.

5926  {
5927  const xmlChar *elemName;
5928  const xmlChar *attrName;
5930 
5931  if (CMP9(CUR_PTR, '<', '!', 'A', 'T', 'T', 'L', 'I', 'S', 'T')) {
5932  int inputid = ctxt->input->id;
5933 
5934  SKIP(9);
5935  if (SKIP_BLANKS == 0) {
5936  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5937  "Space required after '<!ATTLIST'\n");
5938  }
5939  elemName = xmlParseName(ctxt);
5940  if (elemName == NULL) {
5941  xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
5942  "ATTLIST: no name for Element\n");
5943  return;
5944  }
5945  SKIP_BLANKS;
5946  GROW;
5947  while ((RAW != '>') && (ctxt->instate != XML_PARSER_EOF)) {
5948  int type;
5949  int def;
5950  xmlChar *defaultValue = NULL;
5951 
5952  GROW;
5953  tree = NULL;
5954  attrName = xmlParseName(ctxt);
5955  if (attrName == NULL) {
5956  xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
5957  "ATTLIST: no name for Attribute\n");
5958  break;
5959  }
5960  GROW;
5961  if (SKIP_BLANKS == 0) {
5962  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5963  "Space required after the attribute name\n");
5964  break;
5965  }
5966 
5967  type = xmlParseAttributeType(ctxt, &tree);
5968  if (type <= 0) {
5969  break;
5970  }
5971 
5972  GROW;
5973  if (SKIP_BLANKS == 0) {
5974  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5975  "Space required after the attribute type\n");
5976  if (tree != NULL)
5978  break;
5979  }
5980 
5981  def = xmlParseDefaultDecl(ctxt, &defaultValue);
5982  if (def <= 0) {
5983  if (defaultValue != NULL)
5984  xmlFree(defaultValue);
5985  if (tree != NULL)
5987  break;
5988  }
5989  if ((type != XML_ATTRIBUTE_CDATA) && (defaultValue != NULL))
5990  xmlAttrNormalizeSpace(defaultValue, defaultValue);
5991 
5992  GROW;
5993  if (RAW != '>') {
5994  if (SKIP_BLANKS == 0) {
5995  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5996  "Space required after the attribute default value\n");
5997  if (defaultValue != NULL)
5998  xmlFree(defaultValue);
5999  if (tree != NULL)
6001  break;
6002  }
6003  }
6004  if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
6005  (ctxt->sax->attributeDecl != NULL))
6006  ctxt->sax->attributeDecl(ctxt->userData, elemName, attrName,
6007  type, def, defaultValue, tree);
6008  else if (tree != NULL)
6010 
6011  if ((ctxt->sax2) && (defaultValue != NULL) &&
6012  (def != XML_ATTRIBUTE_IMPLIED) &&
6013  (def != XML_ATTRIBUTE_REQUIRED)) {
6014  xmlAddDefAttrs(ctxt, elemName, attrName, defaultValue);
6015  }
6016  if (ctxt->sax2) {
6017  xmlAddSpecialAttr(ctxt, elemName, attrName, type);
6018  }
6019  if (defaultValue != NULL)
6020  xmlFree(defaultValue);
6021  GROW;
6022  }
6023  if (RAW == '>') {
6024  if (inputid != ctxt->input->id) {
6025  xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
6026  "Attribute list declaration doesn't start and"
6027  " stop in the same entity\n");
6028  }
6029  NEXT;
6030  }
6031  }
6032 }
static void xmlAddDefAttrs(xmlParserCtxtPtr ctxt, const xmlChar *fullname, const xmlChar *fullattr, const xmlChar *value)
Definition: parser.c:1215
int xmlParseDefaultDecl(xmlParserCtxtPtr ctxt, xmlChar **value)
Definition: parser.c:5632
xmlParserInputState instate
Definition: parser.h:223
#define GROW
Definition: parser.c:2087
struct _tree tree
#define CMP9(s, c1, c2, c3, c4, c5, c6, c7, c8, c9)
Definition: parser.c:2050
#define SKIP_BLANKS
Definition: parser.c:2115
int xmlParseAttributeType(xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree)
Definition: parser.c:5884
xmlParserInputPtr input
Definition: parser.h:199
int disableSAX
Definition: parser.h:237
const xmlChar * xmlParseName(xmlParserCtxtPtr ctxt)
Definition: parser.c:3301
static xmlChar * xmlAttrNormalizeSpace(const xmlChar *src, xmlChar *dst)
Definition: parser.c:1125
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
#define NEXT
Definition: parser.c:2117
unsigned char xmlChar
Definition: xmlstring.h:28
struct _xmlSAXHandler * sax
Definition: parser.h:185
#define SKIP(val)
Definition: parser.c:2057
static void xmlAddSpecialAttr(xmlParserCtxtPtr ctxt, const xmlChar *fullname, const xmlChar *fullattr, int type)
Definition: parser.c:1326
#define NULL
Definition: types.h:112
#define CUR_PTR
Definition: parser.c:2036
#define RAW
Definition: parser.c:2033
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
void * userData
Definition: parser.h:186
XMLPUBFUN void XMLCALL xmlFreeEnumeration(xmlEnumerationPtr cur)
Definition: valid.c:1831

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 5884 of file parser.c.

5884  {
5885  SHRINK;
5886  if (CMP5(CUR_PTR, 'C', 'D', 'A', 'T', 'A')) {
5887  SKIP(5);
5888  return(XML_ATTRIBUTE_CDATA);
5889  } else if (CMP6(CUR_PTR, 'I', 'D', 'R', 'E', 'F', 'S')) {
5890  SKIP(6);
5891  return(XML_ATTRIBUTE_IDREFS);
5892  } else if (CMP5(CUR_PTR, 'I', 'D', 'R', 'E', 'F')) {
5893  SKIP(5);
5894  return(XML_ATTRIBUTE_IDREF);
5895  } else if ((RAW == 'I') && (NXT(1) == 'D')) {
5896  SKIP(2);
5897  return(XML_ATTRIBUTE_ID);
5898  } else if (CMP6(CUR_PTR, 'E', 'N', 'T', 'I', 'T', 'Y')) {
5899  SKIP(6);
5900  return(XML_ATTRIBUTE_ENTITY);
5901  } else if (CMP8(CUR_PTR, 'E', 'N', 'T', 'I', 'T', 'I', 'E', 'S')) {
5902  SKIP(8);
5903  return(XML_ATTRIBUTE_ENTITIES);
5904  } else if (CMP8(CUR_PTR, 'N', 'M', 'T', 'O', 'K', 'E', 'N', 'S')) {
5905  SKIP(8);
5906  return(XML_ATTRIBUTE_NMTOKENS);
5907  } else if (CMP7(CUR_PTR, 'N', 'M', 'T', 'O', 'K', 'E', 'N')) {
5908  SKIP(7);
5909  return(XML_ATTRIBUTE_NMTOKEN);
5910  }
5911  return(xmlParseEnumeratedType(ctxt, tree));
5912 }
#define NXT(val)
Definition: parser.c:2035
#define CMP5(s, c1, c2, c3, c4, c5)
Definition: parser.c:2042
#define CMP6(s, c1, c2, c3, c4, c5, c6)
Definition: parser.c:2044
int xmlParseEnumeratedType(xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree)
Definition: parser.c:5821
#define SKIP(val)
Definition: parser.c:2057
#define CMP7(s, c1, c2, c3, c4, c5, c6, c7)
Definition: parser.c:2046
#define CUR_PTR
Definition: parser.c:2036
#define RAW
Definition: parser.c:2033
#define SHRINK
Definition: parser.c:2076
#define CMP8(s, c1, c2, c3, c4, c5, c6, c7, c8)
Definition: parser.c:2048

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 4141 of file parser.c.

4141  {
4142  if ((ctxt == NULL) || (ctxt->input == NULL)) return(NULL);
4143  return(xmlParseAttValueInternal(ctxt, NULL, NULL, 0));
4144 }
xmlParserInputPtr input
Definition: parser.h:199
#define NULL
Definition: types.h:112
static xmlChar * xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc, int normalize)
Definition: parser.c:8885

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 9712 of file parser.c.

9712  {
9713  xmlChar *buf = NULL;
9714  int len = 0;
9716  int r, rl;
9717  int s, sl;
9718  int cur, l;
9719  int count = 0;
9720 
9721  /* Check 2.6.0 was NXT(0) not RAW */
9722  if (CMP9(CUR_PTR, '<', '!', '[', 'C', 'D', 'A', 'T', 'A', '[')) {
9723  SKIP(9);
9724  } else
9725  return;
9726 
9728  r = CUR_CHAR(rl);
9729  if (!IS_CHAR(r)) {
9731  ctxt->instate = XML_PARSER_CONTENT;
9732  return;
9733  }
9734  NEXTL(rl);
9735  s = CUR_CHAR(sl);
9736  if (!IS_CHAR(s)) {
9738  ctxt->instate = XML_PARSER_CONTENT;
9739  return;
9740  }
9741  NEXTL(sl);
9742  cur = CUR_CHAR(l);
9743  buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
9744  if (buf == NULL) {
9745  xmlErrMemory(ctxt, NULL);
9746  return;
9747  }
9748  while (IS_CHAR(cur) &&
9749  ((r != ']') || (s != ']') || (cur != '>'))) {
9750  if (len + 5 >= size) {
9751  xmlChar *tmp;
9752 
9753  if ((size > XML_MAX_TEXT_LENGTH) &&
9754  ((ctxt->options & XML_PARSE_HUGE) == 0)) {
9755  xmlFatalErrMsgStr(ctxt, XML_ERR_CDATA_NOT_FINISHED,
9756  "CData section too big found", NULL);
9757  xmlFree (buf);
9758  return;
9759  }
9760  tmp = (xmlChar *) xmlRealloc(buf, size * 2 * sizeof(xmlChar));
9761  if (tmp == NULL) {
9762  xmlFree(buf);
9763  xmlErrMemory(ctxt, NULL);
9764  return;
9765  }
9766  buf = tmp;
9767  size *= 2;
9768  }
9769  COPY_BUF(rl,buf,len,r);
9770  r = s;
9771  rl = sl;
9772  s = cur;
9773  sl = l;
9774  count++;
9775  if (count > 50) {
9776  GROW;
9777  if (ctxt->instate == XML_PARSER_EOF) {
9778  xmlFree(buf);
9779  return;
9780  }
9781  count = 0;
9782  }
9783  NEXTL(l);
9784  cur = CUR_CHAR(l);
9785  }
9786  buf[len] = 0;
9787  ctxt->instate = XML_PARSER_CONTENT;
9788  if (cur != '>') {
9789  xmlFatalErrMsgStr(ctxt, XML_ERR_CDATA_NOT_FINISHED,
9790  "CData section not finished\n%.50s\n", buf);
9791  xmlFree(buf);
9792  return;
9793  }
9794  NEXTL(l);
9795 
9796  /*
9797  * OK the buffer is to be consumed as cdata.
9798  */
9799  if ((ctxt->sax != NULL) && (!ctxt->disableSAX)) {
9800  if (ctxt->sax->cdataBlock != NULL)
9801  ctxt->sax->cdataBlock(ctxt->userData, buf, len);
9802  else if (ctxt->sax->characters != NULL)
9803  ctxt->sax->characters(ctxt->userData, buf, len);
9804  }
9805  xmlFree(buf);
9806 }
#define COPY_BUF(l, b, i, v)
Definition: parser.c:2137
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:359
XMLPUBVAR xmlMallocFunc xmlMallocAtomic
Definition: globals.h:248
xmlParserInputState instate
Definition: parser.h:223
#define GROW
Definition: parser.c:2087
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define XML_MAX_TEXT_LENGTH
#define CMP9(s, c1, c2, c3, c4, c5, c6, c7, c8, c9)
Definition: parser.c:2050
int disableSAX
Definition: parser.h:237
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define XML_PARSER_BUFFER_SIZE
Definition: parser.c:257
#define IS_CHAR(c)
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:249
r l[0]
Definition: byte_order.h:167
GLsizeiptr size
Definition: glext.h:5919
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
#define CUR_CHAR(l)
Definition: parser.c:2134
unsigned char xmlChar
Definition: xmlstring.h:28
GLenum GLsizei len
Definition: glext.h:6722
GLdouble s
Definition: gl.h:2039
struct _xmlSAXHandler * sax
Definition: parser.h:185
#define NEXTL(l)
Definition: parser.c:2127
FxCollectionEntry * cur
#define SKIP(val)
Definition: parser.c:2057
#define NULL
Definition: types.h:112
#define CUR_PTR
Definition: parser.c:2036
void * userData
Definition: parser.h:186

Referenced by xmlParseContent().

◆ 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 4378 of file parser.c.

4378  {
4379  const xmlChar *in;
4380  int nbchar = 0;
4381  int line = ctxt->input->line;
4382  int col = ctxt->input->col;
4383  int ccol;
4384 
4385  SHRINK;
4386  GROW;
4387  /*
4388  * Accelerated common case where input don't need to be
4389  * modified before passing it to the handler.
4390  */
4391  if (!cdata) {
4392  in = ctxt->input->cur;
4393  do {
4394 get_more_space:
4395  while (*in == 0x20) { in++; ctxt->input->col++; }
4396  if (*in == 0xA) {
4397  do {
4398  ctxt->input->line++; ctxt->input->col = 1;
4399  in++;
4400  } while (*in == 0xA);
4401  goto get_more_space;
4402  }
4403  if (*in == '<') {
4404  nbchar = in - ctxt->input->cur;
4405  if (nbchar > 0) {
4406  const xmlChar *tmp = ctxt->input->cur;
4407  ctxt->input->cur = in;
4408 
4409  if ((ctxt->sax != NULL) &&
4410  (ctxt->sax->ignorableWhitespace !=
4411  ctxt->sax->characters)) {
4412  if (areBlanks(ctxt, tmp, nbchar, 1)) {
4413  if (ctxt->sax->ignorableWhitespace != NULL)
4414  ctxt->sax->ignorableWhitespace(ctxt->userData,
4415  tmp, nbchar);
4416  } else {
4417  if (ctxt->sax->characters != NULL)
4418  ctxt->sax->characters(ctxt->userData,
4419  tmp, nbchar);
4420  if (*ctxt->space == -1)
4421  *ctxt->space = -2;
4422  }
4423  } else if ((ctxt->sax != NULL) &&
4424  (ctxt->sax->characters != NULL)) {
4425  ctxt->sax->characters(ctxt->userData,
4426  tmp, nbchar);
4427  }
4428  }
4429  return;
4430  }
4431 
4432 get_more:
4433  ccol = ctxt->input->col;
4434  while (test_char_data[*in]) {
4435  in++;
4436  ccol++;
4437  }
4438  ctxt->input->col = ccol;
4439  if (*in == 0xA) {
4440  do {
4441  ctxt->input->line++; ctxt->input->col = 1;
4442  in++;
4443  } while (*in == 0xA);
4444  goto get_more;
4445  }
4446  if (*in == ']') {
4447  if ((in[1] == ']') && (in[2] == '>')) {
4449  ctxt->input->cur = in + 1;
4450  return;
4451  }
4452  in++;
4453  ctxt->input->col++;
4454  goto get_more;
4455  }
4456  nbchar = in - ctxt->input->cur;
4457  if (nbchar > 0) {
4458  if ((ctxt->sax != NULL) &&
4459  (ctxt->sax->ignorableWhitespace !=
4460  ctxt->sax->characters) &&
4461  (IS_BLANK_CH(*ctxt->input->cur))) {
4462  const xmlChar *tmp = ctxt->input->cur;
4463  ctxt->input->cur = in;
4464 
4465  if (areBlanks(ctxt, tmp, nbchar, 0)) {
4466  if (ctxt->sax->ignorableWhitespace != NULL)
4467  ctxt->sax->ignorableWhitespace(ctxt->userData,
4468  tmp, nbchar);
4469  } else {
4470  if (ctxt->sax->characters != NULL)
4471  ctxt->sax->characters(ctxt->userData,
4472  tmp, nbchar);
4473  if (*ctxt->space == -1)
4474  *ctxt->space = -2;
4475  }
4476  line = ctxt->input->line;
4477  col = ctxt->input->col;
4478  } else if (ctxt->sax != NULL) {
4479  if (ctxt->sax->characters != NULL)
4480  ctxt->sax->characters(ctxt->userData,
4481  ctxt->input->cur, nbchar);
4482  line = ctxt->input->line;
4483  col = ctxt->input->col;
4484  }
4485  /* something really bad happened in the SAX callback */
4486  if (ctxt->instate != XML_PARSER_CONTENT)
4487  return;
4488  }
4489  ctxt->input->cur = in;
4490  if (*in == 0xD) {
4491  in++;
4492  if (*in == 0xA) {
4493  ctxt->input->cur = in;
4494  in++;
4495  ctxt->input->line++; ctxt->input->col = 1;
4496  continue; /* while */
4497  }
4498  in--;
4499  }
4500  if (*in == '<') {
4501  return;
4502  }
4503  if (*in == '&') {
4504  return;
4505  }
4506  SHRINK;
4507  GROW;
4508  if (ctxt->instate == XML_PARSER_EOF)
4509  return;
4510  in = ctxt->input->cur;
4511  } while (((*in >= 0x20) && (*in <= 0x7F)) || (*in == 0x09));
4512  nbchar = 0;
4513  }
4514  ctxt->input->line = line;
4515  ctxt->input->col = col;
4516  xmlParseCharDataComplex(ctxt, cdata);
4517 }
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:359
xmlParserInputState instate
Definition: parser.h:223
#define GROW
Definition: parser.c:2087
const xmlChar * cur
Definition: parser.h:61
static void xmlParseCharDataComplex(xmlParserCtxtPtr ctxt, int cdata)
Definition: parser.c:4529
xmlParserInputPtr input
Definition: parser.h:199
#define IS_BLANK_CH(c)
Definition: parser.c:48
static const unsigned char test_char_data[256]
Definition: parser.c:4326
char line[200]
Definition: main.c:97
unsigned char xmlChar
Definition: xmlstring.h:28
struct _xmlSAXHandler * sax
Definition: parser.h:185
GLuint in
Definition: glext.h:9616
#define NULL
Definition: types.h:112
static int areBlanks(xmlParserCtxtPtr ctxt, const xmlChar *str, int len, int blank_chars)
Definition: parser.c:2825
#define SHRINK
Definition: parser.c:2076
int * space
Definition: parser.h:244
void * userData
Definition: parser.h:186

Referenced by xmlParseContent().

◆ 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 2297 of file parser.c.

2297  {
2298  int val = 0;
2299  int count = 0;
2300 
2301  /*
2302  * Using RAW/CUR/NEXT is okay since we are working on ASCII range here
2303  */
2304  if ((RAW == '&') && (NXT(1) == '#') &&
2305  (NXT(2) == 'x')) {
2306  SKIP(3);
2307  GROW;
2308  while (RAW != ';') { /* loop blocked by count */
2309  if (count++ > 20) {
2310  count = 0;
2311  GROW;
2312  if (ctxt->instate == XML_PARSER_EOF)
2313  return(0);
2314  }
2315  if ((RAW >= '0') && (RAW <= '9'))
2316  val = val * 16 + (CUR - '0');
2317  else if ((RAW >= 'a') && (RAW <= 'f') && (count < 20))
2318  val = val * 16 + (CUR - 'a') + 10;
2319  else if ((RAW >= 'A') && (RAW <= 'F') && (count < 20))
2320  val = val * 16 + (CUR - 'A') + 10;
2321  else {
2323  val = 0;
2324  break;
2325  }
2326  if (val > 0x110000)
2327  val = 0x110000;
2328 
2329  NEXT;
2330  count++;
2331  }
2332  if (RAW == ';') {
2333  /* on purpose to avoid reentrancy problems with NEXT and SKIP */
2334  ctxt->input->col++;
2335  ctxt->nbChars ++;
2336  ctxt->input->cur++;
2337  }
2338  } else if ((RAW == '&') && (NXT(1) == '#')) {
2339  SKIP(2);
2340  GROW;
2341  while (RAW != ';') { /* loop blocked by count */
2342  if (count++ > 20) {
2343  count = 0;
2344  GROW;
2345  if (ctxt->instate == XML_PARSER_EOF)
2346  return(0);
2347  }
2348  if ((RAW >= '0') && (RAW <= '9'))
2349  val = val * 10 + (CUR - '0');
2350  else {
2352  val = 0;
2353  break;
2354  }
2355  if (val > 0x110000)
2356  val = 0x110000;
2357 
2358  NEXT;
2359  count++;
2360  }
2361  if (RAW == ';') {
2362  /* on purpose to avoid reentrancy problems with NEXT and SKIP */
2363  ctxt->input->col++;
2364  ctxt->nbChars ++;
2365  ctxt->input->cur++;
2366  }
2367  } else {
2369  }
2370 
2371  /*
2372  * [ WFC: Legal Character ]
2373  * Characters referred to using character references must match the
2374  * production for Char.
2375  */
2376  if (val >= 0x110000) {
2377  xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR,
2378  "xmlParseCharRef: character reference out of bounds\n",
2379  val);
2380  } else if (IS_CHAR(val)) {
2381  return(val);
2382  } else {
2383  xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR,
2384  "xmlParseCharRef: invalid xmlChar value %d\n",
2385  val);
2386  }
2387  return(0);
2388 }
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:359
xmlParserInputState instate
Definition: parser.h:223
#define GROW
Definition: parser.c:2087
#define NXT(val)
Definition: parser.c:2035
GLuint GLuint GLsizei count
Definition: gl.h:1545
const xmlChar * cur
Definition: parser.h:61
long nbChars
Definition: parser.h:234
xmlParserInputPtr input
Definition: parser.h:199
#define IS_CHAR(c)
GLuint GLfloat * val
Definition: glext.h:7180
#define NEXT
Definition: parser.c:2117
#define SKIP(val)
Definition: parser.c:2057
#define CUR
Definition: parser.c:2034
#define NULL
Definition: types.h:112
#define RAW
Definition: parser.c:2033

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 4835 of file parser.c.

4835  {
4836  xmlChar *buf = NULL;
4837  size_t size = XML_PARSER_BUFFER_SIZE;
4838  size_t len = 0;
4840  const xmlChar *in;
4841  size_t nbchar = 0;
4842  int ccol;
4843  int inputid;
4844 
4845  /*
4846  * Check that there is a comment right here.
4847  */
4848  if ((RAW != '<') || (NXT(1) != '!') ||
4849  (NXT(2) != '-') || (NXT(3) != '-')) return;
4850  state = ctxt->instate;
4851  ctxt->instate = XML_PARSER_COMMENT;
4852  inputid = ctxt->input->id;
4853  SKIP(4);
4854  SHRINK;
4855  GROW;
4856 
4857  /*
4858  * Accelerated common case where input don't need to be
4859  * modified before passing it to the handler.
4860  */
4861  in = ctxt->input->cur;
4862  do {
4863  if (*in == 0xA) {
4864  do {
4865  ctxt->input->line++; ctxt->input->col = 1;
4866  in++;
4867  } while (*in == 0xA);
4868  }
4869 get_more:
4870  ccol = ctxt->input->col;
4871  while (((*in > '-') && (*in <= 0x7F)) ||
4872  ((*in >= 0x20) && (*in < '-')) ||
4873  (*in == 0x09)) {
4874  in++;
4875  ccol++;
4876  }
4877  ctxt->input->col = ccol;
4878  if (*in == 0xA) {
4879  do {
4880  ctxt->input->line++; ctxt->input->col = 1;
4881  in++;
4882  } while (*in == 0xA);
4883  goto get_more;
4884  }
4885  nbchar = in - ctxt->input->cur;
4886  /*
4887  * save current set of data
4888  */
4889  if (nbchar > 0) {
4890  if ((ctxt->sax != NULL) &&
4891  (ctxt->sax->comment != NULL)) {
4892  if (buf == NULL) {
4893  if ((*in == '-') && (in[1] == '-'))
4894  size = nbchar + 1;
4895  else
4896  size = XML_PARSER_BUFFER_SIZE + nbchar;
4897  buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
4898  if (buf == NULL) {
4899  xmlErrMemory(ctxt, NULL);
4900  ctxt->instate = state;
4901  return;
4902  }
4903  len = 0;
4904  } else if (len + nbchar + 1 >= size) {
4905  xmlChar *new_buf;
4906  size += len + nbchar + XML_PARSER_BUFFER_SIZE;
4907  new_buf = (xmlChar *) xmlRealloc(buf,
4908  size * sizeof(xmlChar));
4909  if (new_buf == NULL) {
4910  xmlFree (buf);
4911  xmlErrMemory(ctxt, NULL);
4912  ctxt->instate = state;
4913  return;
4914  }
4915  buf = new_buf;
4916  }
4917  memcpy(&buf[len], ctxt->input->cur, nbchar);
4918  len += nbchar;
4919  buf[len] = 0;
4920  }
4921  }
4922  if ((len > XML_MAX_TEXT_LENGTH) &&
4923  ((ctxt->options & XML_PARSE_HUGE) == 0)) {
4924  xmlFatalErrMsgStr(ctxt, XML_ERR_COMMENT_NOT_FINISHED,
4925  "Comment too big found", NULL);
4926  xmlFree (buf);
4927  return;
4928  }
4929  ctxt->input->cur = in;
4930  if (*in == 0xA) {
4931  in++;
4932  ctxt->input->line++; ctxt->input->col = 1;
4933  }
4934  if (*in == 0xD) {
4935  in++;
4936  if (*in == 0xA) {
4937  ctxt->input->cur = in;
4938  in++;
4939  ctxt->input->line++; ctxt->input->col = 1;
4940  continue; /* while */
4941  }
4942  in--;
4943  }
4944  SHRINK;
4945  GROW;
4946  if (ctxt->instate == XML_PARSER_EOF) {
4947  xmlFree(buf);
4948  return;
4949  }
4950  in = ctxt->input->cur;
4951  if (*in == '-') {
4952  if (in[1] == '-') {
4953  if (in[2] == '>') {
4954  if (ctxt->input->id != inputid) {
4955  xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
4956  "comment doesn't start and stop in the"
4957  " same entity\n");
4958  }
4959  SKIP(3);
4960  if ((ctxt->sax != NULL) && (ctxt->sax->comment != NULL) &&
4961  (!ctxt->disableSAX)) {
4962  if (buf != NULL)
4963  ctxt->sax->comment(ctxt->userData, buf);
4964  else
4965  ctxt->sax->comment(ctxt->userData, BAD_CAST "");
4966  }
4967  if (buf != NULL)
4968  xmlFree(buf);
4969  if (ctxt->instate != XML_PARSER_EOF)
4970  ctxt->instate = state;
4971  return;
4972  }
4973  if (buf != NULL) {
4974  xmlFatalErrMsgStr(ctxt, XML_ERR_HYPHEN_IN_COMMENT,
4975  "Double hyphen within comment: "
4976  "<!--%.50s\n",
4977  buf);
4978  } else
4979  xmlFatalErrMsgStr(ctxt, XML_ERR_HYPHEN_IN_COMMENT,
4980  "Double hyphen within comment\n", NULL);
4981  if (ctxt->instate == XML_PARSER_EOF) {
4982  xmlFree(buf);
4983  return;
4984  }
4985  in++;
4986  ctxt->input->col++;
4987  }
4988  in++;
4989  ctxt->input->col++;
4990  goto get_more;
4991  }
4992  } while (((*in >= 0x20) && (*in <= 0x7F)) || (*in == 0x09));
4994  ctxt->instate = state;
4995  return;
4996 }
XMLPUBVAR xmlMallocFunc xmlMallocAtomic
Definition: globals.h:248
xmlParserInputState instate
Definition: parser.h:223
#define GROW
Definition: parser.c:2087
#define NXT(val)
Definition: parser.c:2035
const xmlChar * cur
Definition: parser.h:61
#define XML_MAX_TEXT_LENGTH
xmlParserInputPtr input
Definition: parser.h:199
int disableSAX
Definition: parser.h:237
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define XML_PARSER_BUFFER_SIZE
Definition: parser.c:257
xmlParserInputState
Definition: parser.h:112
#define BAD_CAST
Definition: xmlstring.h:35
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:249
GLsizeiptr size
Definition: glext.h:5919
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
static int state
Definition: maze.c:121
unsigned char xmlChar
Definition: xmlstring.h:28
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
struct _xmlSAXHandler * sax
Definition: parser.h:185
#define SKIP(val)
Definition: parser.c:2057
GLuint in
Definition: glext.h:9616
static void xmlParseCommentComplex(xmlParserCtxtPtr ctxt, xmlChar *buf, size_t len, size_t size)
Definition: parser.c:4701
#define NULL
Definition: types.h:112
#define RAW
Definition: parser.c:2033
#define SHRINK
Definition: parser.c:2076
void * userData
Definition: parser.h:186

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

◆ xmlParseContent()

XMLPUBFUN void XMLCALL xmlParseContent ( xmlParserCtxtPtr  ctxt)

xmlParseContent: @ctxt: an XML parser context

Parse a content:

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

Definition at line 9818 of file parser.c.

9818  {
9819  int nameNr = ctxt->nameNr;
9820 
9821  GROW;
9822  while ((RAW != 0) &&
9823  (ctxt->instate != XML_PARSER_EOF)) {
9824  const xmlChar *test = CUR_PTR;
9825  unsigned int cons = ctxt->input->consumed;
9826  const xmlChar *cur = ctxt->input->cur;
9827 
9828  /*
9829  * First case : a Processing Instruction.
9830  */
9831  if ((*cur == '<') && (cur[1] == '?')) {
9832  xmlParsePI(ctxt);
9833  }
9834 
9835  /*
9836  * Second case : a CDSection
9837  */
9838  /* 2.6.0 test was *cur not RAW */
9839  else if (CMP9(CUR_PTR, '<', '!', '[', 'C', 'D', 'A', 'T', 'A', '[')) {
9840  xmlParseCDSect(ctxt);
9841  }
9842 
9843  /*
9844  * Third case : a comment
9845  */
9846  else if ((*cur == '<') && (NXT(1) == '!') &&
9847  (NXT(2) == '-') && (NXT(3) == '-')) {
9848  xmlParseComment(ctxt);
9849  ctxt->instate = XML_PARSER_CONTENT;
9850  }
9851 
9852  /*
9853  * Fourth case : a sub-element.
9854  */
9855  else if (*cur == '<') {
9856  if (NXT(1) == '/') {
9857  if (ctxt->nameNr <= nameNr)
9858  break;
9859  xmlParseElementEnd(ctxt);
9860  } else {
9861  xmlParseElementStart(ctxt);
9862  }
9863  }
9864 
9865  /*
9866  * Fifth case : a reference. If if has not been resolved,
9867  * parsing returns it's Name, create the node
9868  */
9869 
9870  else if (*cur == '&') {
9871  xmlParseReference(ctxt);
9872  }
9873 
9874  /*
9875  * Last case, text. Note that References are handled directly.
9876  */
9877  else {
9878  xmlParseCharData(ctxt, 0);
9879  }
9880 
9881  GROW;
9882  SHRINK;
9883 
9884  if ((cons == ctxt->input->consumed) && (test == CUR_PTR)) {
9886  "detected an error in element content\n");
9887  xmlHaltParser(ctxt);
9888  break;
9889  }
9890  }
9891 }
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:359
xmlParserInputState instate
Definition: parser.h:223
#define GROW
Definition: parser.c:2087
#define NXT(val)
Definition: parser.c:2035
const xmlChar * cur
Definition: parser.h:61
#define test
Definition: rosglue.h:37
#define CMP9(s, c1, c2, c3, c4, c5, c6, c7, c8, c9)
Definition: parser.c:2050
void xmlParseCDSect(xmlParserCtxtPtr ctxt)
Definition: parser.c:9712
xmlParserInputPtr input
Definition: parser.h:199
void xmlParseReference(xmlParserCtxtPtr ctxt)
Definition: parser.c:7007
unsigned long consumed
Definition: parser.h:71
void xmlParsePI(xmlParserCtxtPtr ctxt)
Definition: parser.c:5119
pair cons(caddr_t car, pair cdr)
Definition: tree.c:57
unsigned char xmlChar
Definition: xmlstring.h:28
FxCollectionEntry * cur
#define CUR_PTR
Definition: parser.c:2036
#define RAW
Definition: parser.c:2033
void xmlParseCharData(xmlParserCtxtPtr ctxt, int cdata)
Definition: parser.c:4378
static void xmlHaltParser(xmlParserCtxtPtr ctxt)
Definition: parser.c:12478
#define SHRINK
Definition: parser.c:2076
static void xmlParseElementEnd(xmlParserCtxtPtr ctxt)
Definition: parser.c:10059
static int xmlParseElementStart(xmlParserCtxtPtr ctxt)
Definition: parser.c:9925
void xmlParseComment(xmlParserCtxtPtr ctxt)
Definition: parser.c:4835

Referenced by xmlParseBalancedChunkMemoryInternal(), xmlParseCtxtExternalEntity(), xmlParseElement(), 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 5632 of file parser.c.

5632  {
5633  int val;
5634  xmlChar *ret;
5635 
5636  *value = NULL;
5637  if (CMP9(CUR_PTR, '#', 'R', 'E', 'Q', 'U', 'I', 'R', 'E', 'D')) {
5638  SKIP(9);
5639  return(XML_ATTRIBUTE_REQUIRED);
5640  }
5641  if (CMP8(CUR_PTR, '#', 'I', 'M', 'P', 'L', 'I', 'E', 'D')) {
5642  SKIP(8);
5643  return(XML_ATTRIBUTE_IMPLIED);
5644  }
5646  if (CMP6(CUR_PTR, '#', 'F', 'I', 'X', 'E', 'D')) {
5647  SKIP(6);
5649  if (SKIP_BLANKS == 0) {
5650  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5651  "Space required after '#FIXED'\n");
5652  }
5653  }
5654  ret = xmlParseAttValue(ctxt);
5655  ctxt->instate = XML_PARSER_DTD;
5656  if (ret == NULL) {
5657  xmlFatalErrMsg(ctxt, (xmlParserErrors)ctxt->errNo,
5658  "Attribute default value declaration error\n");
5659  } else
5660  *value = ret;
5661  return(val);
5662 }
xmlParserInputState instate
Definition: parser.h:223
#define CMP9(s, c1, c2, c3, c4, c5, c6, c7, c8, c9)
Definition: parser.c:2050
#define SKIP_BLANKS
Definition: parser.c:2115
#define CMP6(s, c1, c2, c3, c4, c5, c6)
Definition: parser.c:2044
GLuint GLfloat * val
Definition: glext.h:7180
xmlParserErrors
Definition: xmlerror.h:99
int ret
unsigned char xmlChar
Definition: xmlstring.h:28
#define SKIP(val)
Definition: parser.c:2057
#define NULL
Definition: types.h:112
#define CUR_PTR
Definition: parser.c:2036
#define CMP8(s, c1, c2, c3, c4, c5, c6, c7, c8)
Definition: parser.c:2048
xmlChar * xmlParseAttValue(xmlParserCtxtPtr ctxt)
Definition: parser.c:4141

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 8208 of file parser.c.

8208  {
8209  const xmlChar *name = NULL;
8210  xmlChar *ExternalID = NULL;
8211  xmlChar *URI = NULL;
8212 
8213  /*
8214  * We know that '<!DOCTYPE' has been detected.
8215  */
8216  SKIP(9);
8217 
8218  SKIP_BLANKS;
8219 
8220  /*
8221  * Parse the DOCTYPE name.
8222  */
8223  name = xmlParseName(ctxt);
8224  if (name == NULL) {
8225  xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
8226  "xmlParseDocTypeDecl : no DOCTYPE name !\n");
8227  }
8228  ctxt->intSubName = name;
8229 
8230  SKIP_BLANKS;
8231 
8232  /*
8233  * Check for SystemID and ExternalID
8234  */
8235  URI = xmlParseExternalID(ctxt, &ExternalID, 1);
8236 
8237  if ((URI != NULL) || (ExternalID != NULL)) {
8238  ctxt->hasExternalSubset = 1;
8239  }
8240  ctxt->extSubURI = URI;
8241  ctxt->extSubSystem = ExternalID;
8242 
8243  SKIP_BLANKS;
8244 
8245  /*
8246  * Create and update the internal subset.
8247  */
8248  if ((ctxt->sax != NULL) && (ctxt->sax->internalSubset != NULL) &&
8249  (!ctxt->disableSAX))
8250  ctxt->sax->internalSubset(ctxt->userData, name, ExternalID, URI);
8251  if (ctxt->instate == XML_PARSER_EOF)
8252  return;
8253 
8254  /*
8255  * Is there any internal subset declarations ?
8256  * they are handled separately in xmlParseInternalSubset()
8257  */
8258  if (RAW == '[')
8259  return;
8260 
8261  /*
8262  * We should be at the end of the DOCTYPE declaration.
8263  */
8264  if (RAW != '>') {
8266  }
8267  NEXT;
8268 }
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:359
xmlParserInputState instate
Definition: parser.h:223
xmlChar * extSubURI
Definition: parser.h:240
xmlChar * xmlParseExternalID(xmlParserCtxtPtr ctxt, xmlChar **publicID, int strict)
Definition: parser.c:4634
#define SKIP_BLANKS
Definition: parser.c:2115
int disableSAX
Definition: parser.h:237
xmlChar * extSubSystem
Definition: parser.h:241
const xmlChar * intSubName
Definition: parser.h:239
const xmlChar * xmlParseName(xmlParserCtxtPtr ctxt)
Definition: parser.c:3301
#define NEXT
Definition: parser.c:2117
unsigned char xmlChar
Definition: xmlstring.h:28
struct _xmlSAXHandler * sax
Definition: parser.h:185
int hasExternalSubset
Definition: parser.h:215
#define SKIP(val)
Definition: parser.c:2057
#define NULL
Definition: types.h:112
Definition: name.c:38
#define RAW
Definition: parser.c:2033
void * userData
Definition: parser.h:186
GLuint const GLchar * name
Definition: glext.h:6031

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 9908 of file parser.c.

9908  {
9909  if (xmlParseElementStart(ctxt) != 0)
9910  return;
9911  xmlParseContent(ctxt);
9912  if (ctxt->instate == XML_PARSER_EOF)
9913  return;
9914  xmlParseElementEnd(ctxt);
9915 }
xmlParserInputState instate
Definition: parser.h:223
void xmlParseContent(xmlParserCtxtPtr ctxt)
Definition: parser.c:9818
static void xmlParseElementEnd(xmlParserCtxtPtr ctxt)
Definition: parser.c:10059
static int xmlParseElementStart(xmlParserCtxtPtr ctxt)
Definition: parser.c:9925

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 6470 of file parser.c.

6470  {
6471  /* stub left for API/ABI compat */
6472  return(xmlParseElementChildrenContentDeclPriv(ctxt, inputchk, 1));
6473 }
static xmlElementContentPtr xmlParseElementChildrenContentDeclPriv(xmlParserCtxtPtr ctxt, int inputchk, int depth)
Definition: parser.c:6174

◆ xmlParseElementContentDecl()

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

Definition at line 6490 of file parser.c.

6491  {
6492 
6494  int inputid = ctxt->input->id;
6495  int res;
6496 
6497  *result = NULL;
6498 
6499  if (RAW != '(') {
6500  xmlFatalErrMsgStr(ctxt, XML_ERR_ELEMCONTENT_NOT_STARTED,
6501  "xmlParseElementContentDecl : %s '(' expected\n", name);
6502  return(-1);
6503  }
6504  NEXT;
6505  GROW;
6506  if (ctxt->instate == XML_PARSER_EOF)
6507  return(-1);
6508  SKIP_BLANKS;
6509  if (CMP7(CUR_PTR, '#', 'P', 'C', 'D', 'A', 'T', 'A')) {
6510  tree = xmlParseElementMixedContentDecl(ctxt, inputid);
6512  } else {
6513  tree = xmlParseElementChildrenContentDeclPriv(ctxt, inputid, 1);
6515  }
6516  SKIP_BLANKS;
6517  *result = tree;
6518  return(res);
6519 }
xmlParserInputState instate
Definition: parser.h:223
#define GROW
Definition: parser.c:2087
GLuint64EXT * result
Definition: glext.h:11304
struct _tree tree
#define SKIP_BLANKS
Definition: parser.c:2115
xmlParserInputPtr input
Definition: parser.h:199
xmlElementContentPtr xmlParseElementMixedContentDecl(xmlParserCtxtPtr ctxt, int inputchk)
Definition: parser.c:6054
static xmlElementContentPtr xmlParseElementChildrenContentDeclPriv(xmlParserCtxtPtr ctxt, int inputchk, int depth)
Definition: parser.c:6174
#define NEXT
Definition: parser.c:2117
#define NULL
Definition: types.h:112
Definition: name.c:38
GLuint res
Definition: glext.h:9613
#define CMP7(s, c1, c2, c3, c4, c5, c6, c7)
Definition: parser.c:2046
#define CUR_PTR
Definition: parser.c:2036
#define RAW
Definition: parser.c:2033

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 6535 of file parser.c.

6535  {
6536  const xmlChar *name;
6537  int ret = -1;
6539 
6540  /* GROW; done in the caller */
6541  if (CMP9(CUR_PTR, '<', '!', 'E', 'L', 'E', 'M', 'E', 'N', 'T')) {
6542  int inputid = ctxt->input->id;
6543 
6544  SKIP(9);
6545  if (SKIP_BLANKS == 0) {
6546  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
6547  "Space required after 'ELEMENT'\n");
6548  return(-1);
6549  }
6550  name = xmlParseName(ctxt);
6551  if (name == NULL) {
6552  xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
6553  "xmlParseElementDecl: no name for Element\n");
6554  return(-1);
6555  }
6556  if (SKIP_BLANKS == 0) {
6557  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
6558  "Space required after the element name\n");
6559  }
6560  if (CMP5(CUR_PTR, 'E', 'M', 'P', 'T', 'Y')) {
6561  SKIP(5);
6562  /*
6563  * Element must always be empty.
6564  */
6566  } else if ((RAW == 'A') && (NXT(1) == 'N') &&
6567  (NXT(2) == 'Y')) {
6568  SKIP(3);
6569  /*
6570  * Element is a generic container.
6571  */
6573  } else if (RAW == '(') {
6575  } else {
6576  /*
6577  * [ WFC: PEs in Internal Subset ] error handling.
6578  */
6579  if ((RAW == '%') && (ctxt->external == 0) &&
6580  (ctxt->inputNr == 1)) {
6581  xmlFatalErrMsg(ctxt, XML_ERR_PEREF_IN_INT_SUBSET,
6582  "PEReference: forbidden within markup decl in internal subset\n");
6583  } else {
6584  xmlFatalErrMsg(ctxt, XML_ERR_ELEMCONTENT_NOT_STARTED,
6585  "xmlParseElementDecl: 'EMPTY', 'ANY' or '(' expected\n");
6586  }
6587  return(-1);
6588  }
6589 
6590  SKIP_BLANKS;
6591 
6592  if (RAW != '>') {
6594  if (content != NULL) {
6596  }
6597  } else {
6598  if (inputid != ctxt->input->id) {
6599  xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
6600  "Element declaration doesn't start and stop in"
6601  " the same entity\n");
6602  }
6603 
6604  NEXT;
6605  if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
6606  (ctxt->sax->elementDecl != NULL)) {
6607  if (content != NULL)
6608  content->parent = NULL;
6609  ctxt->sax->elementDecl(ctxt->userData, name, ret,
6610  content);
6611  if ((content != NULL) && (content->parent == NULL)) {
6612  /*
6613  * this is a trick: if xmlAddElementDecl is called,
6614  * instead of copying the full tree it is plugged directly
6615  * if called from the parser. Avoid duplicating the
6616  * interfaces or change the API/ABI
6617  */
6619  }
6620  } else if (content != NULL) {
6622  }
6623  }
6624  }
6625  return(ret);
6626 }
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:359
#define NXT(val)
Definition: parser.c:2035
#define CMP5(s, c1, c2, c3, c4, c5)
Definition: parser.c:2042
#define CMP9(s, c1, c2, c3, c4, c5, c6, c7, c8, c9)
Definition: parser.c:2050
int external
Definition: parser.h:217
#define SKIP_BLANKS
Definition: parser.c:2115
int xmlParseElementContentDecl(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlElementContentPtr *result)
Definition: parser.c:6490
xmlParserInputPtr input
Definition: parser.h:199
int disableSAX
Definition: parser.h:237
content
Definition: atl_ax.c:993
const xmlChar * xmlParseName(xmlParserCtxtPtr ctxt)
Definition: parser.c:3301
XMLPUBFUN void XMLCALL xmlFreeDocElementContent(xmlDocPtr doc, xmlElementContentPtr cur)
Definition: valid.c:1101
#define NEXT
Definition: parser.c:2117
int ret
xmlDocPtr myDoc
Definition: parser.h:187
unsigned char xmlChar
Definition: xmlstring.h:28
struct _xmlSAXHandler * sax
Definition: parser.h:185
#define SKIP(val)
Definition: parser.c:2057
#define NULL
Definition: types.h:112
Definition: name.c:38
#define CUR_PTR
Definition: parser.c:2036
#define RAW
Definition: parser.c:2033
void * userData
Definition: parser.h:186
GLuint const GLchar * name
Definition: glext.h:6031

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 6054 of file parser.c.

6054  {
6056  const xmlChar *elem = NULL;
6057 
6058  GROW;
6059  if (CMP7(CUR_PTR, '#', 'P', 'C', 'D', 'A', 'T', 'A')) {
6060  SKIP(7);
6061  SKIP_BLANKS;
6062  SHRINK;
6063  if (RAW == ')') {
6064  if (ctxt->input->id != inputchk) {
6065  xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
6066  "Element content declaration doesn't start and"
6067  " stop in the same entity\n");
6068  }
6069  NEXT;
6071  if (ret == NULL)
6072  return(NULL);
6073  if (RAW == '*') {
6074  ret->ocur = XML_ELEMENT_CONTENT_MULT;
6075  NEXT;
6076  }
6077  return(ret);
6078  }
6079  if ((RAW == '(') || (RAW == '|')) {
6081  if (ret == NULL) return(NULL);
6082  }
6083  while ((RAW == '|') && (ctxt->instate != XML_PARSER_EOF)) {
6084  NEXT;
6085  if (elem == NULL) {
6087  if (ret == NULL) return(NULL);
6088  ret->c1 = cur;
6089  if (cur != NULL)
6090  cur->parent = ret;
6091  cur = ret;
6092  } else {
6094  if (n == NULL) return(NULL);
6096  if (n->c1 != NULL)
6097  n->c1->parent = n;
6098  cur->c2 = n;
6099  if (n != NULL)
6100  n->parent = cur;
6101  cur = n;
6102  }
6103  SKIP_BLANKS;
6104  elem = xmlParseName(ctxt);
6105  if (elem == NULL) {
6106  xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
6107  "xmlParseElementMixedContentDecl : Name expected\n");
6109  return(NULL);
6110  }
6111  SKIP_BLANKS;
6112  GROW;
6113  }
6114  if ((RAW == ')') && (NXT(1) == '*')) {
6115  if (elem != NULL) {
6116  cur->c2 = xmlNewDocElementContent(ctxt->myDoc, elem,
6118  if (cur->c2 != NULL)
6119  cur->c2->parent = cur;
6120  }
6121  if (ret != NULL)
6122  ret->ocur = XML_ELEMENT_CONTENT_MULT;
6123  if (ctxt->input->id != inputchk) {
6124  xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
6125  "Element content declaration doesn't start and"
6126  " stop in the same entity\n");
6127  }
6128  SKIP(2);
6129  } else {
6132  return(NULL);
6133  }
6134 
6135  } else {
6137  }
6138  return(ret);
6139 }
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:359
xmlParserInputState instate
Definition: parser.h:223
#define GROW
Definition: parser.c:2087
#define NXT(val)
Definition: parser.c:2035
GLdouble n
Definition: glext.h:7729
XMLPUBFUN xmlElementContentPtr XMLCALL xmlNewDocElementContent(xmlDocPtr doc, const xmlChar *name, xmlElementContentType type)
Definition: valid.c:921
#define SKIP_BLANKS
Definition: parser.c:2115
xmlParserInputPtr input
Definition: parser.h:199
static size_t elem
Definition: string.c:68
const xmlChar * xmlParseName(xmlParserCtxtPtr ctxt)
Definition: parser.c:3301
XMLPUBFUN void XMLCALL xmlFreeDocElementContent(xmlDocPtr doc, xmlElementContentPtr cur)
Definition: valid.c:1101
#define NEXT
Definition: parser.c:2117
int ret
xmlDocPtr myDoc
Definition: parser.h:187
unsigned char xmlChar
Definition: xmlstring.h:28
FxCollectionEntry * cur
#define SKIP(val)
Definition: parser.c:2057
#define NULL
Definition: types.h:112
#define CMP7(s, c1, c2, c3, c4, c5, c6, c7)
Definition: parser.c:2046
#define CUR_PTR
Definition: parser.c:2036
#define RAW
Definition: parser.c:2033
#define SHRINK
Definition: parser.c:2076

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*

Returns the encoding name value or NULL

Definition at line 10211 of file parser.c.

10211  {
10212  xmlChar *buf = NULL;
10213  int len = 0;
10214  int size = 10;
10215  xmlChar cur;
10216 
10217  cur = CUR;
10218  if (((cur >= 'a') && (cur <= 'z')) ||
10219  ((cur >= 'A') && (cur <= 'Z'))) {
10220  buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
10221  if (buf == NULL) {
10222  xmlErrMemory(ctxt, NULL);
10223  return(NULL);
10224  }
10225 
10226  buf[len++] = cur;
10227  NEXT;
10228  cur = CUR;
10229  while (((cur >= 'a') && (cur <= 'z')) ||
10230  ((cur >= 'A') && (cur <= 'Z')) ||
10231  ((cur >= '0') && (cur <= '9')) ||
10232  (cur == '.') || (cur == '_') ||
10233  (cur == '-')) {
10234  if (len + 1 >= size) {
10235  xmlChar *tmp;
10236 
10237  size *= 2;
10238  tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
10239  if (tmp == NULL) {
10240  xmlErrMemory(ctxt, NULL);
10241  xmlFree(buf);
10242  return(NULL);
10243  }
10244  buf = tmp;
10245  }
10246  buf[len++] = cur;
10247  NEXT;
10248  cur = CUR;
10249  if (cur == 0) {
10250  SHRINK;
10251  GROW;
10252  cur = CUR;
10253  }
10254  }
10255  buf[len] = 0;
10256  } else {
10258  }
10259  return(buf);
10260 }
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:359
XMLPUBVAR xmlMallocFunc xmlMallocAtomic
Definition: globals.h:248
#define GROW
Definition: parser.c:2087
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:249
GLsizeiptr size
Definition: glext.h:5919
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
#define NEXT
Definition: parser.c:2117
unsigned char xmlChar
Definition: xmlstring.h:28
GLenum GLsizei len
Definition: glext.h:6722
FxCollectionEntry * cur
#define CUR
Definition: parser.c:2034
#define NULL
Definition: types.h:112
#define SHRINK
Definition: parser.c:2076

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 10276 of file parser.c.

10276  {
10277  xmlChar *encoding = NULL;
10278 
10279  SKIP_BLANKS;
10280  if (CMP8(CUR_PTR, 'e', 'n', 'c', 'o', 'd', 'i', 'n', 'g')) {
10281  SKIP(8);
10282  SKIP_BLANKS;
10283  if (RAW != '=') {
10285  return(NULL);
10286  }
10287  NEXT;
10288  SKIP_BLANKS;
10289  if (RAW == '"') {
10290  NEXT;
10291  encoding = xmlParseEncName(ctxt);
10292  if (RAW != '"') {
10294  xmlFree((xmlChar *) encoding);
10295  return(NULL);
10296  } else
10297  NEXT;
10298  } else if (RAW == '\''){
10299  NEXT;
10300  encoding = xmlParseEncName(ctxt);
10301  if (RAW != '\'') {
10303  xmlFree((xmlChar *) encoding);
10304  return(NULL);
10305  } else
10306  NEXT;
10307  } else {
10309  }
10310 
10311  /*
10312  * Non standard parsing, allowing the user to ignore encoding
10313  */
10314  if (ctxt->options & XML_PARSE_IGNORE_ENC) {
10315  xmlFree((xmlChar *) encoding);
10316  return(NULL);
10317  }
10318 
10319  /*
10320  * UTF-16 encoding switch has already taken place at this stage,
10321  * more over the little-endian/big-endian selection is already done
10322  */
10323  if ((encoding != NULL) &&
10324  ((!xmlStrcasecmp(encoding, BAD_CAST "UTF-16")) ||
10325  (!xmlStrcasecmp(encoding, BAD_CAST "UTF16")))) {
10326  /*
10327  * If no encoding was passed to the parser, that we are
10328  * using UTF-16 and no decoder is present i.e. the
10329  * document is apparently UTF-8 compatible, then raise an
10330  * encoding mismatch fatal error
10331  */
10332  if ((ctxt->encoding == NULL) &&
10333  (ctxt->input->buf != NULL) &&
10334  (ctxt->input->buf->encoder == NULL)) {
10335  xmlFatalErrMsg(ctxt, XML_ERR_INVALID_ENCODING,
10336  "Document labelled UTF-16 but has UTF-8 content\n");
10337  }
10338  if (ctxt->encoding != NULL)
10339  xmlFree((xmlChar *) ctxt->encoding);
10340  ctxt->encoding = encoding;
10341  }
10342  /*
10343  * UTF-8 encoding is handled natively
10344  */
10345  else if ((encoding != NULL) &&
10346  ((!xmlStrcasecmp(encoding, BAD_CAST "UTF-8")) ||
10347  (!xmlStrcasecmp(encoding, BAD_CAST "UTF8")))) {
10348  if (ctxt->encoding != NULL)
10349  xmlFree((xmlChar *) ctxt->encoding);
10350  ctxt->encoding = encoding;
10351  }
10352  else if (encoding != NULL) {
10354 
10355  if (ctxt->input->encoding != NULL)
10356  xmlFree((xmlChar *) ctxt->input->encoding);
10357  ctxt->input->encoding = encoding;
10358 
10359  handler = xmlFindCharEncodingHandler((const char *) encoding);
10360  if (handler != NULL) {
10361  if (xmlSwitchToEncoding(ctxt, handler) < 0) {
10362  /* failed to convert */
10364  return(NULL);
10365  }
10366  } else {
10367  xmlFatalErrMsgStr(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
10368  "Unsupported encoding %s\n", encoding);
10369  return(NULL);
10370  }
10371  }
10372  }
10373  return(encoding);
10374 }
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:359
XMLPUBFUN int XMLCALL xmlSwitchToEncoding(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler)
xmlChar * xmlParseEncName(xmlParserCtxtPtr ctxt)
Definition: parser.c:10211
#define SKIP_BLANKS
Definition: parser.c:2115
xmlParserInputPtr input
Definition: parser.h:199
#define BAD_CAST
Definition: xmlstring.h:35
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
#define NEXT
Definition: parser.c:2117
XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL xmlFindCharEncodingHandler(const char *name)
Definition: encoding.c:1641
const xmlChar * encoding
Definition: parser.h:191
unsigned char xmlChar
Definition: xmlstring.h:28
ed encoding
Definition: write.c:2825
xmlCharEncodingHandlerPtr encoder
Definition: xmlIO.h:130
#define SKIP(val)
Definition: parser.c:2057
xmlParserInputBufferPtr buf
Definition: parser.h:56
#define NULL
Definition: types.h:112
const xmlChar * encoding
Definition: parser.h:73
#define CUR_PTR
Definition: parser.c:2036
#define RAW
Definition: parser.c:2033
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7786
XMLPUBFUN int XMLCALL xmlStrcasecmp(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:271
#define CMP8(s, c1, c2, c3, c4, c5, c6, c7, c8)
Definition: parser.c:2048

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 5359 of file parser.c.

5359  {
5360  const xmlChar *name = NULL;
5361  xmlChar *value = NULL;
5362  xmlChar *URI = NULL, *literal = NULL;
5363  const xmlChar *ndata = NULL;
5364  int isParameter = 0;
5365  xmlChar *orig = NULL;
5366 
5367  /* GROW; done in the caller */
5368  if (CMP8(CUR_PTR, '<', '!', 'E', 'N', 'T', 'I', 'T', 'Y')) {
5369  int inputid = ctxt->input->id;
5370  SHRINK;
5371  SKIP(8);
5372  if (SKIP_BLANKS == 0) {
5373  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5374  "Space required after '<!ENTITY'\n");
5375  }
5376 
5377  if (RAW == '%') {
5378  NEXT;
5379  if (SKIP_BLANKS == 0) {
5380  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5381  "Space required after '%%'\n");
5382  }
5383  isParameter = 1;
5384  }
5385 
5386  name = xmlParseName(ctxt);
5387  if (name == NULL) {
5388  xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
5389  "xmlParseEntityDecl: no name\n");
5390  return;
5391  }
5392  if (xmlStrchr(name, ':') != NULL) {
5393  xmlNsErr(ctxt, XML_NS_ERR_COLON,
5394  "colons are forbidden from entities names '%s'\n",
5395  name, NULL, NULL);
5396  }
5397  if (SKIP_BLANKS == 0) {
5398  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5399  "Space required after the entity name\n");
5400  }
5401 
5403  /*
5404  * handle the various case of definitions...
5405  */
5406  if (isParameter) {
5407  if ((RAW == '"') || (RAW == '\'')) {
5408  value = xmlParseEntityValue(ctxt, &orig);
5409  if (value) {
5410  if ((ctxt->sax != NULL) &&
5411  (!ctxt->disableSAX) && (ctxt->sax->entityDecl != NULL))
5412  ctxt->sax->entityDecl(ctxt->userData, name,
5414  NULL, NULL, value);
5415  }
5416  } else {
5417  URI = xmlParseExternalID(ctxt, &literal, 1);
5418  if ((URI == NULL) && (literal == NULL)) {
5420  }
5421  if (URI) {
5422  xmlURIPtr uri;
5423 
5424  uri = xmlParseURI((const char *) URI);
5425  if (uri == NULL) {
5426  xmlErrMsgStr(ctxt, XML_ERR_INVALID_URI,
5427  "Invalid URI: %s\n", URI);
5428  /*
5429  * This really ought to be a well formedness error
5430  * but the XML Core WG decided otherwise c.f. issue
5431  * E26 of the XML erratas.
5432  */
5433  } else {
5434  if (uri->fragment != NULL) {
5435  /*
5436  * Okay this is foolish to block those but not
5437  * invalid URIs.
5438  */
5440  } else {
5441  if ((ctxt->sax != NULL) &&
5442  (!ctxt->disableSAX) &&
5443  (ctxt->sax->entityDecl != NULL))
5444  ctxt->sax->entityDecl(ctxt->userData, name,
5446  literal, URI, NULL);
5447  }
5448  xmlFreeURI(uri);
5449  }
5450  }
5451  }
5452  } else {
5453  if ((RAW == '"') || (RAW == '\'')) {
5454  value = xmlParseEntityValue(ctxt, &orig);
5455  if ((ctxt->sax != NULL) &&
5456  (!ctxt->disableSAX) && (ctxt->sax->entityDecl != NULL))
5457  ctxt->sax->entityDecl(ctxt->userData, name,
5459  NULL, NULL, value);
5460  /*
5461  * For expat compatibility in SAX mode.
5462  */
5463  if ((ctxt->myDoc == NULL) ||
5465  if (ctxt->myDoc == NULL) {
5466  ctxt->myDoc = xmlNewDoc(SAX_COMPAT_MODE);
5467  if (ctxt->myDoc == NULL) {
5468  xmlErrMemory(ctxt, "New Doc failed");
5469  return;
5470  }
5472  }
5473  if (ctxt->myDoc->intSubset == NULL)
5474  ctxt->myDoc->intSubset = xmlNewDtd(ctxt->myDoc,
5475  BAD_CAST "fake", NULL, NULL);
5476 
5478  NULL, NULL, value);
5479  }
5480  } else {
5481  URI = xmlParseExternalID(ctxt, &literal, 1);
5482  if ((URI == NULL) && (literal == NULL)) {
5484  }
5485  if (URI) {
5486  xmlURIPtr uri;
5487 
5488  uri = xmlParseURI((const char *)URI);
5489  if (uri == NULL) {
5490  xmlErrMsgStr(ctxt, XML_ERR_INVALID_URI,
5491  "Invalid URI: %s\n", URI);
5492  /*
5493  * This really ought to be a well formedness error
5494  * but the XML Core WG decided otherwise c.f. issue
5495  * E26 of the XML erratas.
5496  */
5497  } else {
5498  if (uri->fragment != NULL) {
5499  /*
5500  * Okay this is foolish to block those but not
5501  * invalid URIs.
5502  */
5504  }
5505  xmlFreeURI(uri);
5506  }
5507  }
5508  if ((RAW != '>') && (SKIP_BLANKS == 0)) {
5509  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5510  "Space required before 'NDATA'\n");
5511  }
5512  if (CMP5(CUR_PTR, 'N', 'D', 'A', 'T', 'A')) {
5513  SKIP(5);
5514  if (SKIP_BLANKS == 0) {
5515  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5516  "Space required after 'NDATA'\n");
5517  }
5518  ndata = xmlParseName(ctxt);
5519  if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
5520  (ctxt->sax->unparsedEntityDecl != NULL))
5521  ctxt->sax->unparsedEntityDecl(ctxt->userData, name,
5522  literal, URI, ndata);
5523  } else {
5524  if ((ctxt->sax != NULL) &&
5525  (!ctxt->disableSAX) && (ctxt->sax->entityDecl != NULL))
5526  ctxt->sax->entityDecl(ctxt->userData, name,
5528  literal, URI, NULL);
5529  /*
5530  * For expat compatibility in SAX mode.
5531  * assuming the entity replacement was asked for
5532  */
5533  if ((ctxt->replaceEntities != 0) &&
5534  ((ctxt->myDoc == NULL) ||
5535  (xmlStrEqual(ctxt->myDoc->version, SAX_COMPAT_MODE)))) {
5536  if (ctxt->myDoc == NULL) {
5537  ctxt->myDoc = xmlNewDoc(SAX_COMPAT_MODE);
5538  if (ctxt->myDoc == NULL) {
5539  xmlErrMemory(ctxt, "New Doc failed");
5540  return;
5541  }
5543  }
5544 
5545  if (ctxt->myDoc->intSubset == NULL)
5546  ctxt->myDoc->intSubset = xmlNewDtd(ctxt->myDoc,
5547  BAD_CAST "fake", NULL, NULL);
5548  xmlSAX2EntityDecl(ctxt, name,
5550  literal, URI, NULL);
5551  }
5552  }
5553  }
5554  }
5555  if (ctxt->instate == XML_PARSER_EOF)
5556  goto done;
5557  SKIP_BLANKS;
5558  if (RAW != '>') {
5559  xmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_NOT_FINISHED,
5560  "xmlParseEntityDecl: entity %s not terminated\n", name);
5561  xmlHaltParser(ctxt);
5562  } else {
5563  if (inputid != ctxt->input->id) {
5564  xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
5565  "Entity declaration doesn't start and stop in"
5566  " the same entity\n");
5567  }
5568  NEXT;
5569  }
5570  if (orig != NULL) {
5571  /*
5572  * Ugly mechanism to save the raw entity value.
5573  */
5574  xmlEntityPtr cur = NULL;
5575 
5576  if (isParameter) {
5577  if ((ctxt->sax != NULL) &&
5578  (ctxt->sax->getParameterEntity != NULL))
5579  cur = ctxt->sax->getParameterEntity(ctxt->userData, name);
5580  } else {
5581  if ((ctxt->sax != NULL) &&
5582  (ctxt->sax->getEntity != NULL))
5583  cur = ctxt->sax->getEntity(ctxt->userData, name);
5584  if ((cur == NULL) && (ctxt->userData==ctxt)) {
5585  cur = xmlSAX2GetEntity(ctxt, name);
5586  }
5587  }
5588  if ((cur != NULL) && (cur->orig == NULL)) {
5589  cur->orig = orig;
5590  orig = NULL;
5591  }
5592  }
5593 
5594 done:
5595  if (value != NULL) xmlFree(value);
5596  if (URI != NULL) xmlFree(URI);
5597  if (literal != NULL) xmlFree(literal);
5598  if (orig != NULL) xmlFree(orig);
5599  }
5600 }
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:359
xmlParserInputState instate
Definition: parser.h:223
XMLPUBFUN xmlDtdPtr XMLCALL xmlNewDtd(xmlDocPtr doc, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID)
int properties
Definition: tree.h:584
const xmlChar * version
Definition: tree.h:573
struct _xmlDtd * intSubset
Definition: tree.h:570
const char * uri
Definition: sec_mgr.c:1588
#define CMP5(s, c1, c2, c3, c4, c5)
Definition: parser.c:2042
xmlChar * xmlParseExternalID(xmlParserCtxtPtr ctxt, xmlChar **publicID, int strict)
Definition: parser.c:4634
XMLPUBFUN xmlURIPtr XMLCALL xmlParseURI(const char *str)
Definition: uri.c:934
XMLPUBFUN void XMLCALL xmlSAX2EntityDecl(void *ctx, const xmlChar *name, int type, const xmlChar *publicId, const xmlChar *systemId, xmlChar *content)
Definition: SAX2.c:664
XMLPUBFUN const xmlChar *XMLCALL xmlStrchr(const xmlChar *str, xmlChar val)
Definition: xmlstring.c:321
#define SKIP_BLANKS
Definition: parser.c:2115
xmlParserInputPtr input
Definition: parser.h:199
int disableSAX
Definition: parser.h:237
int replaceEntities
Definition: parser.h:189
xmlChar * xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig)
Definition: parser.c:3722
#define BAD_CAST
Definition: xmlstring.h:35
const xmlChar * xmlParseName(xmlParserCtxtPtr ctxt)
Definition: parser.c:3301
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
#define NEXT
Definition: parser.c:2117
xmlDocPtr myDoc
Definition: parser.h:187
unsigned char xmlChar
Definition: xmlstring.h:28
struct _xmlSAXHandler * sax
Definition: parser.h:185
FxCollectionEntry * cur