Gnome XML Library Reference Manual | ||
---|---|---|
Prev |
xmlParserCtxtPtr xmlCreateFileParserCtxt (const char *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.
filename : | the filename |
Returns : | the new parser context or NULL |
xmlParserCtxtPtr xmlCreateMemoryParserCtxt (char *buffer, int size); |
Create a parser context for an XML in-memory document.
buffer : | an pointer to a char array |
size : | the siwe of the array |
Returns : | the new parser context or NULL |
void xmlFreeParserCtxt (xmlParserCtxtPtr ctxt); |
Free all the memory used by a parser context. However the parsed document in ctxt->doc is not freed.
ctxt : | an XML parser context |
void xmlHandleEntity (xmlParserCtxtPtr ctxt, xmlEntityPtr entity); |
Default handling of defined entities, when should we define a new input stream ? When do we just handle that as a set of chars ? TODO: we should call the SAX handler here and have it resolve the issue
ctxt : | an XML parser context |
entity : | an XML entity pointer. |
xmlParserInputPtr xmlNewEntityInputStream (xmlParserCtxtPtr ctxt, xmlEntityPtr entity); |
Create a new input stream based on a memory buffer.
ctxt : | |
entity : | |
Returns : |
void xmlPushInput (xmlParserCtxtPtr ctxt, xmlParserInputPtr input); |
xmlPushInput: switch to a new input stream which is stacked on top of the previous one(s).
ctxt : | an XML parser context |
input : | an XML parser input fragment (entity, XML fragment ...). |
CHAR xmlPopInput (xmlParserCtxtPtr ctxt); |
xmlPopInput: the current input pointed by ctxt->input came to an end pop it and return the next char.
TODO A deallocation of the popped Input structure is needed
ctxt : | an XML parser context |
Returns : | the current CHAR in the parser context |
void xmlFreeInputStream (xmlParserInputPtr input); |
Free up an input stream.
input : | an xmlParserInputPtr |
CHAR* xmlNamespaceParseNCName (xmlParserCtxtPtr ctxt); |
parse an XML namespace name.
[NS 3] NCName ::= (Letter | '_') (NCNameChar)*
[NS 4] NCNameChar ::= Letter | Digit | '.' | '-' | '_' | CombiningChar | Extender
ctxt : | an XML parser context |
Returns : | the namespace name or NULL |
CHAR* xmlNamespaceParseQName (xmlParserCtxtPtr ctxt, CHAR **prefix); |
parse an XML qualified name
[NS 5] QName ::= (Prefix ':')? LocalPart
[NS 6] Prefix ::= NCName
[NS 7] LocalPart ::= NCName
ctxt : | an XML parser context |
prefix : | a CHAR ** |
Returns : | the function returns the local part, and prefix is updated to get the Prefix if any. |
CHAR* xmlNamespaceParseNSDef (xmlParserCtxtPtr ctxt); |
parse a namespace prefix declaration
[NS 1] NSDef ::= PrefixDef Eq SystemLiteral
[NS 2] PrefixDef ::= 'xmlns' (':' NCName)?
ctxt : | an XML parser context |
Returns : | the namespace name |
CHAR* xmlParseQuotedString (xmlParserCtxtPtr ctxt); |
[OLD] Parse and return a string between quotes or doublequotes
ctxt : | an XML parser context |
Returns : | the string parser or NULL. |
void xmlParseNamespace (xmlParserCtxtPtr ctxt); |
[OLD] xmlParseNamespace: parse specific PI '<?namespace ...' constructs.
This is what the older xml-name Working Draft specified, a bunch of other stuff may still rely on it, so support is still here as if ot was declared on the root of the Tree:-(
ctxt : | an XML parser context |
CHAR* xmlParseName (xmlParserCtxtPtr ctxt); |
parse an XML name.
[4] NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender
[5] Name ::= (Letter | '_' | ':') (NameChar)*
[6] Names ::= Name (S Name)*
ctxt : | an XML parser context |
Returns : | the Name parsed or NULL |
CHAR* xmlParseNmtoken (xmlParserCtxtPtr ctxt); |
parse an XML Nmtoken.
[7] Nmtoken ::= (NameChar)+
[8] Nmtokens ::= Nmtoken (S Nmtoken)*
ctxt : | an XML parser context |
Returns : | the Nmtoken parsed or NULL |
CHAR* xmlParseEntityValue (xmlParserCtxtPtr ctxt); |
parse a value for ENTITY decl.
[9] EntityValue ::= '"' ([^%&"] | PEReference | Reference)* '"' | "'" ([^%&'] | PEReference | Reference)* "'"
ctxt : | an XML parser context |
Returns : | the EntityValue parsed or NULL |
CHAR* xmlParseAttValue (xmlParserCtxtPtr ctxt); |
parse a value for an attribute
[10] AttValue ::= '"' ([^<&"] | Reference)* '"' | "'" ([^<&'] | Reference)* "'"
ctxt : | an XML parser context |
Returns : | the AttValue parsed or NULL. |
CHAR* xmlParseSystemLiteral (xmlParserCtxtPtr ctxt); |
parse an XML Literal
[11] SystemLiteral ::= ('"' [^"]* '"') | ("'" [^']* "'")
ctxt : | an XML parser context |
Returns : | the SystemLiteral parsed or NULL |
CHAR* xmlParsePubidLiteral (xmlParserCtxtPtr ctxt); |
parse an XML public literal
[12] PubidLiteral ::= '"' PubidChar* '"' | "'" (PubidChar - "'")* "'"
ctxt : | an XML parser context |
Returns : | the PubidLiteral parsed or NULL. |
void xmlParseCharData (xmlParserCtxtPtr ctxt, int cdata); |
parse a CharData section. if we are within a CDATA section ']]>' marks an end of section.
[14] CharData ::= [^<&]* - ([^<&]* ']]>' [^<&]*)
ctxt : | an XML parser context |
cdata : | int indicating whether we are within a CDATA section |
CHAR* xmlParseExternalID (xmlParserCtxtPtr ctxt, CHAR **publicID, int strict); |
Parse an External ID or a Public ID
NOTE: Productions [75] and [83] interract badly since [75] can generate 'PUBLIC' S PubidLiteral S SystemLiteral
[75] ExternalID ::= 'SYSTEM' S SystemLiteral | 'PUBLIC' S PubidLiteral S SystemLiteral
[83] PublicID ::= 'PUBLIC' S PubidLiteral
ctxt : | an XML parser context |
publicID : | a CHAR** receiving PubidLiteral |
strict : | indicate whether we should restrict parsing to only production [75], see NOTE below |
Returns : | the function returns SystemLiteral and in the second case publicID receives PubidLiteral, is strict is off it is possible to return NULL and have publicID set. |
xmlNodePtr xmlParseComment (xmlParserCtxtPtr ctxt, int create); |
Skip an XML (SGML) comment <!-- .... --> This may or may not create a node (depending on the context) The spec says that "For compatibility, the string "--" (double-hyphen) must not occur within comments. "
[15] Comment ::= '<!--' ((Char - '-') | ('-' (Char - '-')))* '-->'
TODO: this should call a SAX function which will handle (or not) the creation of the comment !
ctxt : | an XML parser context |
create : | should we create a node, or just skip the content |
Returns : | the comment node, or NULL |
CHAR* xmlParsePITarget (xmlParserCtxtPtr ctxt); |
parse the name of a PI
[17] PITarget ::= Name - (('X' | 'x') ('M' | 'm') ('L' | 'l'))
ctxt : | an XML parser context |
Returns : | the PITarget name or NULL |
void xmlParsePI (xmlParserCtxtPtr ctxt); |
parse an XML Processing Instruction.
[16] PI ::= '<?' PITarget (S (Char* - (Char* '?>' Char*)))? '?>'
The processing is transfered to SAX once parsed.
ctxt : | an XML parser context |
void xmlParseNotationDecl (xmlParserCtxtPtr ctxt); |
parse a notation declaration
[82] NotationDecl ::= '<!NOTATION' S Name S (ExternalID | PublicID) S? '>'
Hence there is actually 3 choices: 'PUBLIC' S PubidLiteral 'PUBLIC' S PubidLiteral S SystemLiteral and 'SYSTEM' S SystemLiteral
See the NOTE on xmlParseExternalID().
ctxt : | an XML parser context |
void xmlParseEntityDecl (xmlParserCtxtPtr ctxt); |
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
ctxt : | an XML parser context |
int xmlParseDefaultDecl (xmlParserCtxtPtr ctxt, CHAR **value); |
Parse an attribute default declaration
[60] DefaultDecl ::= '
ctxt : | an XML parser context |
value : | Receive a possible fixed default value for the attribute |
Returns : | XML_ATTRIBUTE_NONE, XML_ATTRIBUTE_REQUIRED, XML_ATTRIBUTE_IMPLIED or XML_ATTRIBUTE_FIXED. |
xmlEnumerationPtr xmlParseNotationType (xmlParserCtxtPtr ctxt); |
parse an Notation attribute type.
[58] NotationType ::= 'NOTATION' S '(' S? Name (S? '|' S? Name)* S? ')'
Note: the leading 'NOTATION' S part has already being parsed...
ctxt : | an XML parser context |
Returns : | the notation attribute tree built while parsing |
xmlEnumerationPtr xmlParseEnumerationType (xmlParserCtxtPtr ctxt); |
parse an Enumeration attribute type.
[59] Enumeration ::= '(' S? Nmtoken (S? '|' S? Nmtoken)* S? ')'
ctxt : | an XML parser context |
Returns : | the enumeration attribute tree built while parsing |
int xmlParseEnumeratedType (xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree); |
parse an Enumerated attribute type.
[57] EnumeratedType ::= NotationType | Enumeration
[58] NotationType ::= 'NOTATION' S '(' S? Name (S? '|' S? Name)* S? ')'
ctxt : | an XML parser context |
tree : | the enumeration tree built while parsing |
Returns : | XML_ATTRIBUTE_ENUMERATION or XML_ATTRIBUTE_NOTATION |
int xmlParseAttributeType (xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree); |
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'
ctxt : | an XML parser context |
tree : | the enumeration tree built while parsing |
Returns : | the attribute type |
void xmlParseAttributeListDecl (xmlParserCtxtPtr ctxt); |
: parse the Attribute list def for an element
[52] AttlistDecl ::= '<!ATTLIST' S Name AttDef* S? '>'
[53] AttDef ::= S Name S AttType S DefaultDecl
ctxt : | an XML parser context |
xmlElementContentPtr xmlParseElementMixedContentDecl (xmlParserCtxtPtr ctxt); |
parse the declaration for a Mixed Element content The leading '(' and spaces have been skipped in xmlParseElementContentDecl
[51] Mixed ::= '(' S? '
ctxt : | an XML parser context |
Returns : | the list of the xmlElementContentPtr describing the element choices |
xmlElementContentPtr xmlParseElementChildrenContentDecl (xmlParserCtxtPtr ctxt); |
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? ')'
ctxt : | an XML parser context |
Returns : | the tree of xmlElementContentPtr describing the element hierarchy. |
int xmlParseElementContentDecl (xmlParserCtxtPtr ctxt, CHAR *name, xmlElementContentPtr *result); |
parse the declaration for an Element content either Mixed or Children, the cases EMPTY and ANY are handled directly in xmlParseElementDecl
[46] contentspec ::= 'EMPTY' | 'ANY' | Mixed | children
ctxt : | an XML parser context |
name : | the name of the element being defined. |
result : | the Element Content pointer will be stored here if any |
Returns : | the type of element content XML_ELEMENT_TYPE_xxx |
int xmlParseElementDecl (xmlParserCtxtPtr ctxt); |
parse an Element declaration.
[45] elementdecl ::= '<!ELEMENT' S Name S contentspec S? '>'
TODO There is a check [ VC: Unique Element Type Declaration ]
ctxt : | an XML parser context |
Returns : | the type of the element, or -1 in case of error |
void xmlParseMarkupDecl (xmlParserCtxtPtr ctxt); |
parse Markup declarations
[29] markupdecl ::= elementdecl | AttlistDecl | EntityDecl | NotationDecl | PI | Comment
TODO There is a check [ VC: Proper Declaration/PE Nesting ]
ctxt : | an XML parser context |
CHAR* xmlParseCharRef (xmlParserCtxtPtr ctxt); |
parse Reference declarations
[66] CharRef ::= '&#' [0-9]+ ';' |
'&
ctxt : | an XML parser context |
Returns : | the value parsed |
CHAR* xmlParseEntityRef (xmlParserCtxtPtr ctxt); |
parse ENTITY references declarations
[68] EntityRef ::= '&' Name ';'
ctxt : | an XML parser context |
Returns : | the entity ref string or NULL if directly as input stream. |
CHAR* xmlParseReference (xmlParserCtxtPtr ctxt); |
parse Reference declarations
[67] Reference ::= EntityRef | CharRef
ctxt : | an XML parser context |
Returns : | the entity string or NULL if handled directly by pushing the entity value as the input. |
CHAR* xmlParsePEReference (xmlParserCtxtPtr ctxt); |
parse PEReference declarations
[69] PEReference ::= '%' Name ';'
ctxt : | an XML parser context |
Returns : | the entity content or NULL if handled directly. |
void xmlParseDocTypeDecl (xmlParserCtxtPtr ctxt); |
parse a DOCTYPE declaration
[28] doctypedecl ::= '<!DOCTYPE' S Name (S ExternalID)? S? ('[' (markupdecl | PEReference | S)* ']' S?)? '>'
ctxt : | an XML parser context |
xmlAttrPtr xmlParseAttribute (xmlParserCtxtPtr ctxt, xmlNodePtr node); |
parse an attribute
[41] Attribute ::= Name Eq AttValue
[25] Eq ::= S? '=' S?
With namespace:
[NS 11] Attribute ::= QName Eq AttValue
Also the case QName == xmlns:??? is handled independently as a namespace definition.
ctxt : | an XML parser context |
node : | the node carrying the attribute |
Returns : | the attribute just parsed of NULL in case of error. |
xmlNodePtr xmlParseStartTag (xmlParserCtxtPtr ctxt); |
parse a start of tag either for rule element or EmptyElement. In both case we don't parse the tag closing chars.
[40] STag ::= '<' Name (S Attribute)* S? '>'
[44] EmptyElemTag ::= '<' Name (S Attribute)* S? '/>'
With namespace:
[NS 8] STag ::= '<' QName (S Attribute)* S? '>'
[NS 10] EmptyElement ::= '<' QName (S Attribute)* S? '/>'
ctxt : | an XML parser context |
Returns : | the XML new node or NULL. |
void xmlParseEndTag (xmlParserCtxtPtr ctxt, xmlNsPtr *nsPtr, CHAR **tagPtr); |
parse an end of tag
[42] ETag ::= '</' Name S? '>'
With namespace
[9] ETag ::= '</' QName S? '>'
tagPtr receive the tag name just read
ctxt : | an XML parser context |
nsPtr : | the current node namespace definition |
tagPtr : | CHAR** receive the tag value |
void xmlParseCDSect (xmlParserCtxtPtr ctxt); |
Parse escaped pure raw content.
[18] CDSect ::= CDStart CData CDEnd
[19] CDStart ::= '<![CDATA['
[20] Data ::= (Char* - (Char* ']]>' Char*))
[21] CDEnd ::= ']]>'
ctxt : | an XML parser context |
void xmlParseContent (xmlParserCtxtPtr ctxt); |
Parse a content:
[43] content ::= (element | CharData | Reference | CDSect | PI | Comment)*
ctxt : | an XML parser context |
xmlNodePtr xmlParseElement (xmlParserCtxtPtr ctxt); |
parse an XML element, this is highly recursive
[39] element ::= EmptyElemTag | STag content ETag
[41] Attribute ::= Name Eq AttValue
ctxt : | an XML parser context |
Returns : | the XML new node or NULL |
CHAR* xmlParseVersionNum (xmlParserCtxtPtr ctxt); |
parse the XML version value.
[26] VersionNum ::= ([a-zA-Z0-9_.:] | '-')+
ctxt : | an XML parser context |
Returns : | the string giving the XML version number, or NULL |
CHAR* xmlParseVersionInfo (xmlParserCtxtPtr ctxt); |
parse the XML version.
[24] VersionInfo ::= S 'version' Eq (' VersionNum ' | " VersionNum ")
[25] Eq ::= S? '=' S?
ctxt : | an XML parser context |
Returns : | the version string, e.g. "1.0" |
CHAR* xmlParseEncName (xmlParserCtxtPtr ctxt); |
parse the XML encoding name
[81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')*
ctxt : | an XML parser context |
Returns : | the encoding name value or NULL |
CHAR* xmlParseEncodingDecl (xmlParserCtxtPtr ctxt); |
parse the XML encoding declaration
[80] EncodingDecl ::= S 'encoding' Eq ('"' EncName '"' | "'" EncName "'")
TODO: this should setup the conversion filters.
ctxt : | an XML parser context |
Returns : | the encoding value or NULL |
int xmlParseSDDecl (xmlParserCtxtPtr ctxt); |
parse the XML standalone declaration
[32] SDDecl ::= S 'standalone' Eq (("'" ('yes' | 'no') "'") | ('"' ('yes' | 'no')'"'))
ctxt : | an XML parser context |
Returns : | 1 if standalone, 0 otherwise |
void xmlParseXMLDecl (xmlParserCtxtPtr ctxt); |
parse an XML declaration header
[23] XMLDecl ::= '<?xml' VersionInfo EncodingDecl? SDDecl? S? '?>'
ctxt : | an XML parser context |
void xmlParseMisc (xmlParserCtxtPtr ctxt); |
parse an XML Misc* optionnal field.
[27] Misc ::= Comment | PI | S
ctxt : | an XML parser context |