![]() | ![]() | ![]() | Gnome XML Library Reference Manual | ![]() |
---|
void (*xmlValidityErrorFunc) (void *ctx, const char *msg, ...); void (*xmlValidityWarningFunc) (void *ctx, const char *msg, ...); struct xmlValidCtxt; typedef xmlValidCtxtPtr; #define XML_MIN_NOTATION_TABLE struct xmlNotationTable; typedef xmlNotationTablePtr; #define XML_MIN_ELEMENT_TABLE struct xmlElementTable; typedef xmlElementTablePtr; #define XML_MIN_ATTRIBUTE_TABLE struct xmlAttributeTable; typedef xmlAttributeTablePtr; #define XML_MIN_ID_TABLE struct xmlIDTable; typedef xmlIDTablePtr; #define XML_MIN_REF_TABLE struct xmlRefTable; typedef xmlRefTablePtr; xmlNotationPtr xmlAddNotationDecl (xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, const xmlChar *name, const xmlChar *PublicID, const xmlChar *SystemID); xmlNotationTablePtr xmlCopyNotationTable (xmlNotationTablePtr table); void xmlFreeNotationTable (xmlNotationTablePtr table); void xmlDumpNotationTable (xmlBufferPtr buf, xmlNotationTablePtr table); xmlElementContentPtr xmlNewElementContent (xmlChar *name, xmlElementContentType type); xmlElementContentPtr xmlCopyElementContent (xmlElementContentPtr content); void xmlFreeElementContent (xmlElementContentPtr cur); xmlElementPtr xmlAddElementDecl (xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, const xmlChar *name, xmlElementTypeVal type, xmlElementContentPtr content); xmlElementTablePtr xmlCopyElementTable (xmlElementTablePtr table); void xmlFreeElementTable (xmlElementTablePtr table); void xmlDumpElementTable (xmlBufferPtr buf, xmlElementTablePtr table); xmlEnumerationPtr xmlCreateEnumeration (xmlChar *name); void xmlFreeEnumeration (xmlEnumerationPtr cur); xmlEnumerationPtr xmlCopyEnumeration (xmlEnumerationPtr cur); xmlAttributePtr xmlAddAttributeDecl (xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, const xmlChar *elem, const xmlChar *name, xmlAttributeType type, xmlAttributeDefault def, const xmlChar *defaultValue, xmlEnumerationPtr tree); xmlAttributeTablePtr xmlCopyAttributeTable (xmlAttributeTablePtr table); void xmlFreeAttributeTable (xmlAttributeTablePtr table); void xmlDumpAttributeTable (xmlBufferPtr buf, xmlAttributeTablePtr table); xmlIDPtr xmlAddID (xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value, xmlAttrPtr attr); xmlIDTablePtr xmlCopyIDTable (xmlIDTablePtr table); void xmlFreeIDTable (xmlIDTablePtr table); xmlAttrPtr xmlGetID (xmlDocPtr doc, const xmlChar *ID); int xmlIsID (xmlDocPtr doc, xmlNodePtr elem, xmlAttrPtr attr); int xmlRemoveID (xmlDocPtr doc, xmlAttrPtr attr); xmlRefPtr xmlAddRef (xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value, xmlAttrPtr attr); xmlRefTablePtr xmlCopyRefTable (xmlRefTablePtr table); void xmlFreeRefTable (xmlRefTablePtr table); int xmlIsRef (xmlDocPtr doc, xmlNodePtr elem, xmlAttrPtr attr); int xmlRemoveRef (xmlDocPtr doc, xmlAttrPtr attr); int xmlValidateRoot (xmlValidCtxtPtr ctxt, xmlDocPtr doc); int xmlValidateElementDecl (xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlElementPtr elem); int xmlValidateAttributeDecl (xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlAttributePtr attr); int xmlValidateAttributeValue (xmlAttributeType type, const xmlChar *value); int xmlValidateNotationDecl (xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlNotationPtr nota); int xmlValidateDtd (xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlDtdPtr dtd); int xmlValidateDocument (xmlValidCtxtPtr ctxt, xmlDocPtr doc); int xmlValidateElement (xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr elem); int xmlValidateOneElement (xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr elem); int xmlValidateOneAttribute (xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr elem, xmlAttrPtr attr, const xmlChar *value); int xmlValidateDocumentFinal (xmlValidCtxtPtr ctxt, xmlDocPtr doc); int xmlValidateNotationUse (xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *notationName); int xmlIsMixedElement (xmlDocPtr doc, const xmlChar *name); xmlAttributePtr xmlGetDtdAttrDesc (xmlDtdPtr dtd, const xmlChar *elem, const xmlChar *name); xmlNotationPtr xmlGetDtdNotationDesc (xmlDtdPtr dtd, const xmlChar *name); xmlElementPtr xmlGetDtdElementDesc (xmlDtdPtr dtd, const xmlChar *name); int xmlValidGetValidElements (xmlNode *prev, xmlNode *next, const xmlChar **list, int max); int xmlValidGetPotentialChildren (xmlElementContent *ctree, const xmlChar **list, int *len, int max);
void (*xmlValidityErrorFunc) (void *ctx, const char *msg, ...);
ctx : | |
msg : | |
... : |
|
void (*xmlValidityWarningFunc) (void *ctx, const char *msg, ...);
ctx : | |
msg : | |
... : |
|
struct xmlValidCtxt { void *userData; /* user specific data block */ xmlValidityErrorFunc error; /* the callback in case of errors */ xmlValidityWarningFunc warning; /* the callback in case of warning */ };
struct xmlNotationTable { int nb_notations; /* number of notations stored */ int max_notations; /* maximum number of notations */ xmlNotationPtr *table; /* the table of attributes */ };
struct xmlElementTable { int nb_elements; /* number of elements stored */ int max_elements; /* maximum number of elements */ xmlElementPtr *table; /* the table of elements */ };
struct xmlAttributeTable { int nb_attributes; /* number of attributes stored */ int max_attributes; /* maximum number of attributes */ xmlAttributePtr *table; /* the table of attributes */ };
struct xmlIDTable { int nb_ids; /* number of ids stored */ int max_ids; /* maximum number of ids */ xmlIDPtr *table; /* the table of ids */ };
struct xmlRefTable { int nb_refs; /* number of refs stored */ int max_refs; /* maximum number of refs */ xmlRefPtr *table; /* the table of refs */ };
xmlNotationPtr xmlAddNotationDecl (xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, const xmlChar *name, const xmlChar *PublicID, const xmlChar *SystemID);
Register a new notation declaration
ctxt : | the validation context |
dtd : | pointer to the DTD |
name : | the entity name |
PublicID : | the public identifier or NULL |
SystemID : | the system identifier or NULL |
Returns : | NULL if not, othervise the entity |
xmlNotationTablePtr xmlCopyNotationTable (xmlNotationTablePtr table);
Build a copy of a notation table.
table : | A notation table |
Returns : | the new xmlNotationTablePtr or NULL in case of error. |
void xmlFreeNotationTable (xmlNotationTablePtr table);
Deallocate the memory used by an entities hash table.
table : | An notation table |
void xmlDumpNotationTable (xmlBufferPtr buf, xmlNotationTablePtr table);
This will dump the content of the notation table as an XML DTD definition
buf : | the XML buffer output |
table : | A notation table |
xmlElementContentPtr xmlNewElementContent (xmlChar *name, xmlElementContentType type);
Allocate an element content structure.
name : | the subelement name or NULL |
type : | the type of element content decl |
Returns : | NULL if not, othervise the new element content structure |
xmlElementContentPtr xmlCopyElementContent (xmlElementContentPtr content);
Build a copy of an element content description.
content : | An element content pointer. |
Returns : | the new xmlElementContentPtr or NULL in case of error. |
void xmlFreeElementContent (xmlElementContentPtr cur);
Free an element content structure. This is a recursive call !
cur : | the element content tree to free |
xmlElementPtr xmlAddElementDecl (xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, const xmlChar *name, xmlElementTypeVal type, xmlElementContentPtr content);
Register a new element declaration
ctxt : | the validation context |
dtd : | pointer to the DTD |
name : | the entity name |
type : | the element type |
content : | the element content tree or NULL |
Returns : | NULL if not, othervise the entity |
xmlElementTablePtr xmlCopyElementTable (xmlElementTablePtr table);
Build a copy of an element table.
table : | An element table |
Returns : | the new xmlElementTablePtr or NULL in case of error. |
void xmlFreeElementTable (xmlElementTablePtr table);
Deallocate the memory used by an element hash table.
table : | An element table |
void xmlDumpElementTable (xmlBufferPtr buf, xmlElementTablePtr table);
This will dump the content of the element table as an XML DTD definition
buf : | the XML buffer output |
table : | An element table |
xmlEnumerationPtr xmlCreateEnumeration (xmlChar *name);
create and initialize an enumeration attribute node.
name : | the enumeration name or NULL |
Returns : | the xmlEnumerationPtr just created or NULL in case of error. |
void xmlFreeEnumeration (xmlEnumerationPtr cur);
free an enumeration attribute node (recursive).
cur : | the tree to free. |
xmlEnumerationPtr xmlCopyEnumeration (xmlEnumerationPtr cur);
Copy an enumeration attribute node (recursive).
cur : | the tree to copy. |
Returns : | the xmlEnumerationPtr just created or NULL in case of error. |
xmlAttributePtr xmlAddAttributeDecl (xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, const xmlChar *elem, const xmlChar *name, xmlAttributeType type, xmlAttributeDefault def, const xmlChar *defaultValue, xmlEnumerationPtr tree);
Register a new attribute declaration
ctxt : | the validation context |
dtd : | pointer to the DTD |
elem : | the element name |
name : | the attribute name |
type : | the attribute type |
def : | the attribute default type |
defaultValue : | the attribute default value |
tree : | if it's an enumeration, the associated list |
Returns : | NULL if not, othervise the entity |
xmlAttributeTablePtr xmlCopyAttributeTable (xmlAttributeTablePtr table);
Build a copy of an attribute table.
table : | An attribute table |
Returns : | the new xmlAttributeTablePtr or NULL in case of error. |
void xmlFreeAttributeTable (xmlAttributeTablePtr table);
Deallocate the memory used by an entities hash table.
table : | An attribute table |
void xmlDumpAttributeTable (xmlBufferPtr buf, xmlAttributeTablePtr table);
This will dump the content of the attribute table as an XML DTD definition
buf : | the XML buffer output |
table : | An attribute table |
xmlIDPtr xmlAddID (xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value, xmlAttrPtr attr);
Register a new id declaration
ctxt : | the validation context |
doc : | pointer to the document |
value : | the value name |
attr : | the attribute holding the ID |
Returns : | NULL if not, othervise the new xmlIDPtr |
void xmlFreeIDTable (xmlIDTablePtr table);
Deallocate the memory used by an ID hash table.
table : | An id table |
xmlAttrPtr xmlGetID (xmlDocPtr doc, const xmlChar *ID);
Search the attribute declaring the given ID
doc : | pointer to the document |
ID : | the ID value |
Returns : | NULL if not found, otherwise the xmlAttrPtr defining the ID |
int xmlIsID (xmlDocPtr doc, xmlNodePtr elem, xmlAttrPtr attr);
Determine whether an attribute is of type ID. In case we have Dtd(s) then this is simple, otherwise we use an heuristic: name ID (upper or lowercase).
doc : | the document |
elem : | the element carrying the attribute |
attr : | the attribute |
Returns : | 0 or 1 depending on the lookup result |
int xmlRemoveID (xmlDocPtr doc, xmlAttrPtr attr);
Remove the given attribute from the ID table maintained internally.
doc : | the document |
attr : | the attribute |
Returns : | -1 if the lookup failed and 0 otherwise |
xmlRefPtr xmlAddRef (xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value, xmlAttrPtr attr);
Register a new ref declaration
ctxt : | the validation context |
doc : | pointer to the document |
value : | the value name |
attr : | the attribute holding the Ref |
Returns : | NULL if not, othervise the new xmlRefPtr |
void xmlFreeRefTable (xmlRefTablePtr table);
Deallocate the memory used by an Ref hash table.
table : | An ref table |
int xmlIsRef (xmlDocPtr doc, xmlNodePtr elem, xmlAttrPtr attr);
Determine whether an attribute is of type Ref. In case we have Dtd(s) then this is simple, otherwise we use an heuristic: name Ref (upper or lowercase).
doc : | the document |
elem : | the element carrying the attribute |
attr : | the attribute |
Returns : | 0 or 1 depending on the lookup result |
int xmlRemoveRef (xmlDocPtr doc, xmlAttrPtr attr);
Remove the given attribute from the Ref table maintained internally.
doc : | the document |
attr : | the attribute |
Returns : | -1 if the lookup failed and 0 otherwise |
int xmlValidateRoot (xmlValidCtxtPtr ctxt, xmlDocPtr doc);
Try to validate a the root element basically it does the following check as described by the XML-1.0 recommendation: - [ VC: Root Element Type ] it doesn't try to recurse or apply other check to the element
ctxt : | the validation context |
doc : | a document instance |
Returns : | 1 if valid or 0 otherwise |
int xmlValidateElementDecl (xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlElementPtr elem);
Try to validate a single element definition basically it does the following checks as described by the XML-1.0 recommendation: - [ VC: One ID per Element Type ] - [ VC: No Duplicate Types ] - [ VC: Unique Element Type Declaration ]
ctxt : | the validation context |
doc : | a document instance |
elem : | an element definition |
Returns : | 1 if valid or 0 otherwise |
int xmlValidateAttributeDecl (xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlAttributePtr attr);
Try to validate a single attribute definition basically it does the following checks as described by the XML-1.0 recommendation: - [ VC: Attribute Default Legal ] - [ VC: Enumeration ] - [ VC: ID Attribute Default ]
The ID/IDREF uniqueness and matching are done separately
ctxt : | the validation context |
doc : | a document instance |
attr : | an attribute definition |
Returns : | 1 if valid or 0 otherwise |
int xmlValidateAttributeValue (xmlAttributeType type, const xmlChar *value);
Validate that the given attribute value match the proper production
[ VC: ID ] Values of type ID must match the Name production....
[ VC: IDREF ] Values of type IDREF must match the Name production, and values of type IDREFS must match Names ...
[ VC: Entity Name ] Values of type ENTITY must match the Name production, values of type ENTITIES must match Names ...
[ VC: Name Token ] Values of type NMTOKEN must match the Nmtoken production; values of type NMTOKENS must match Nmtokens.
type : | an attribute type |
value : | an attribute value |
Returns : | 1 if valid or 0 otherwise |
int xmlValidateNotationDecl (xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlNotationPtr nota);
Try to validate a single notation definition basically it does the following checks as described by the XML-1.0 recommendation: - it seems that no validity constraing exist on notation declarations But this function get called anyway ...
ctxt : | the validation context |
doc : | a document instance |
nota : | a notation definition |
Returns : | 1 if valid or 0 otherwise |
int xmlValidateDtd (xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlDtdPtr dtd);
Try to validate the document against the dtd instance
basically it does check all the definitions in the DtD.
ctxt : | the validation context |
doc : | a document instance |
dtd : | a dtd instance |
Returns : | 1 if valid or 0 otherwise |
int xmlValidateDocument (xmlValidCtxtPtr ctxt, xmlDocPtr doc);
Try to validate the document instance
basically it does the all the checks described by the XML Rec i.e. validates the internal and external subset (if present) and validate the document tree.
ctxt : | the validation context |
doc : | a document instance |
Returns : | 1 if valid or 0 otherwise |
int xmlValidateElement (xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr elem);
Try to validate the subtree under an element
ctxt : | the validation context |
doc : | a document instance |
elem : | an element instance |
Returns : | 1 if valid or 0 otherwise |
int xmlValidateOneElement (xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr elem);
Try to validate a single element and it's attributes, basically it does the following checks as described by the XML-1.0 recommendation: - [ VC: Element Valid ] - [ VC: Required Attribute ] Then call xmlValidateOneAttribute() for each attribute present.
The ID/IDREF checkings are done separately
ctxt : | the validation context |
doc : | a document instance |
elem : | an element instance |
Returns : | 1 if valid or 0 otherwise |
int xmlValidateOneAttribute (xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr elem, xmlAttrPtr attr, const xmlChar *value);
Try to validate a single attribute for an element basically it * does the following checks as described by the XML-1.0 recommendation: - [ VC: Attribute Value Type ] - [ VC: Fixed Attribute Default ] - [ VC: Entity Name ] - [ VC: Name Token ] - [ VC: ID ] - [ VC: IDREF ] - [ VC: Entity Name ] - [ VC: Notation Attributes ]
The ID/IDREF uniqueness and matching are done separately
ctxt : | the validation context |
doc : | a document instance |
elem : | an element instance |
attr : | an attribute instance |
value : | the attribute value (without entities processing) |
Returns : | 1 if valid or 0 otherwise |
int xmlValidateDocumentFinal (xmlValidCtxtPtr ctxt, xmlDocPtr doc);
Does the final step for the document validation once all the incremental validation steps have been completed
basically it does the following checks described by the XML Rec
ctxt : | the validation context |
doc : | a document instance |
Returns : | 1 if valid or 0 otherwise |
int xmlValidateNotationUse (xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *notationName);
Validate that the given mame match a notation declaration. - [ VC: Notation Declared ]
ctxt : | the validation context |
doc : | the document |
notationName : | the notation name to check |
Returns : | 1 if valid or 0 otherwise |
int xmlIsMixedElement (xmlDocPtr doc, const xmlChar *name);
Search in the DtDs whether an element accept Mixed content (or ANY) basically if it is supposed to accept text childs
doc : | the document |
name : | the element name |
Returns : | 0 if no, 1 if yes, and -1 if no element description is available |
xmlAttributePtr xmlGetDtdAttrDesc (xmlDtdPtr dtd, const xmlChar *elem, const xmlChar *name);
Search the Dtd for the description of this attribute on this element.
dtd : | a pointer to the DtD to search |
elem : | the element name |
name : | the attribute name |
Returns : | the xmlAttributePtr if found or NULL |
xmlNotationPtr xmlGetDtdNotationDesc (xmlDtdPtr dtd, const xmlChar *name);
Search the Dtd for the description of this notation
dtd : | a pointer to the DtD to search |
name : | the notation name |
Returns : | the xmlNotationPtr if found or NULL |
xmlElementPtr xmlGetDtdElementDesc (xmlDtdPtr dtd, const xmlChar *name);
Search the Dtd for the description of this element
dtd : | a pointer to the DtD to search |
name : | the element name |
Returns : | the xmlElementPtr if found or NULL |
int xmlValidGetValidElements (xmlNode *prev, xmlNode *next, const xmlChar **list, int max);
This function returns the list of authorized children to insert within an existing tree while respecting the validity constraints forced by the Dtd. The insertion point is defined using prev and next in the following ways: to insert before 'node': xmlValidGetValidElements(node->prev, node, ... to insert next 'node': xmlValidGetValidElements(node, node->next, ... to replace 'node': xmlValidGetValidElements(node->prev, node->next, ... to prepend a child to 'node': xmlValidGetValidElements(NULL, node->childs, to append a child to 'node': xmlValidGetValidElements(node->last, NULL, ...
pointers to the element names are inserted at the beginning of the array and do not need to be freed.
prev : | an element to insert after |
next : | an element to insert next |
list : | an array to store the list of child names |
max : | the size of the array |
Returns : | the number of element in the list, or -1 in case of error. If the function returns the value max the caller is invited to grow the receiving array and retry. |
int xmlValidGetPotentialChildren (xmlElementContent *ctree, const xmlChar **list, int *len, int max);
Build/extend a list of potential children allowed by the content tree
ctree : | an element content tree |
list : | an array to store the list of child names |
len : | a pointer to the number of element in the list |
max : | the size of the array |
Returns : | the number of element in the list, or -1 in case of error. |
<<< entities | xml-error >>> |