version 1.13, 1999/07/29 09:43:58
|
version 1.14, 1999/08/02 16:45:50
|
Line 1082 xmlDumpNotationTable(xmlBufferPtr buf, x
|
Line 1082 xmlDumpNotationTable(xmlBufferPtr buf, x
|
xmlBufferWriteChar(buf, " >\n"); |
xmlBufferWriteChar(buf, " >\n"); |
} |
} |
} |
} |
|
|
|
/************************************************************************ |
|
* * |
|
* Routines for validity checking * |
|
* * |
|
************************************************************************/ |
|
|
|
#define VERROR \ |
|
if ((ctxt != NULL) && (ctxt->error != NULL)) ctxt->error |
|
|
|
#define VWARNING \ |
|
if ((ctxt != NULL) && (ctxt->warning != NULL)) ctxt->warning |
|
|
|
#define CHECK_DTD \ |
|
if (doc == NULL) return(0); \ |
|
else if (doc->intSubset == NULL) return(0) |
|
|
|
/** |
|
* xmlGetDtdElementDesc: |
|
* @dtd: a pointer to the DtD to search |
|
* @name: the element name |
|
* |
|
* Search the Dtd for the description of this element |
|
* |
|
* returns the xmlElementPtr if found or NULL |
|
*/ |
|
|
|
xmlElementPtr |
|
xmlGetDtdElementDesc(xmlDtdPtr dtd, const CHAR *name) { |
|
xmlElementTablePtr table; |
|
xmlElementPtr cur; |
|
int i; |
|
|
|
if (dtd == NULL) return(NULL); |
|
if (dtd->elements == NULL) return(NULL); |
|
table = dtd->elements; |
|
|
|
for (i = 0;i < table->nb_elements;i++) { |
|
cur = &table->table[i]; |
|
if (!xmlStrcmp(cur->name, name)) |
|
return(cur); |
|
} |
|
return(NULL); |
|
} |
|
|
|
/** |
|
* xmlGetDtdAttrDesc: |
|
* @dtd: a pointer to the DtD to search |
|
* @name: the attribute name |
|
* |
|
* Search the Dtd for the description of this attribute |
|
* |
|
* returns the xmlAttributePtr if found or NULL |
|
*/ |
|
|
|
xmlAttributePtr |
|
xmlGetDtdAttrDesc(xmlDtdPtr dtd, const CHAR *name) { |
|
xmlAttributeTablePtr table; |
|
xmlAttributePtr cur; |
|
int i; |
|
|
|
if (dtd == NULL) return(NULL); |
|
if (dtd->attributes == NULL) return(NULL); |
|
table = dtd->attributes; |
|
|
|
for (i = 0;i < table->nb_attributes;i++) { |
|
cur = &table->table[i]; |
|
if (!xmlStrcmp(cur->name, name)) |
|
return(cur); |
|
} |
|
return(NULL); |
|
} |
|
|
|
/** |
|
* xmlGetDtdNotationDesc: |
|
* @dtd: a pointer to the DtD to search |
|
* @name: the notation name |
|
* |
|
* Search the Dtd for the description of this notation |
|
* |
|
* returns the xmlNotationPtr if found or NULL |
|
*/ |
|
|
|
xmlNotationPtr |
|
xmlGetDtdNotationDesc(xmlDtdPtr dtd, const CHAR *name) { |
|
xmlNotationTablePtr table; |
|
xmlNotationPtr cur; |
|
int i; |
|
|
|
if (dtd == NULL) return(NULL); |
|
if (dtd->notations == NULL) return(NULL); |
|
table = dtd->notations; |
|
|
|
for (i = 0;i < table->nb_notations;i++) { |
|
cur = &table->table[i]; |
|
if (!xmlStrcmp(cur->name, name)) |
|
return(cur); |
|
} |
|
return(NULL); |
|
} |
|
|
|
/** |
|
* xmlValidateAttributeDecl: |
|
* @doc: a document instance |
|
* @attr: an attribute definition |
|
* |
|
* 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: Notation Declared ] |
|
* - [ VC: Notation Attributes ] |
|
* - [ VC: Enumeration ] |
|
* - [ VC: ID Attribute Default ] |
|
* |
|
* The ID/IDREF uniqueness and matching are done separately |
|
* |
|
* returns 1 if valid or 0 otherwise |
|
*/ |
|
|
|
int |
|
xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc, |
|
xmlAttributePtr attr) { |
|
CHECK_DTD; |
|
|
|
return(1); |
|
} |
|
|
|
/** |
|
* xmlValidateElementDecl: |
|
* @ctxt: the validation context |
|
* @doc: a document instance |
|
* @elem: an element definition |
|
* |
|
* 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 ] |
|
* |
|
* returns 1 if valid or 0 otherwise |
|
*/ |
|
|
|
int |
|
xmlValidateElementDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlElementPtr elem) { |
|
CHECK_DTD; |
|
|
|
return(1); |
|
} |
|
|
|
/** |
|
* xmlValidateOneAttribute: |
|
* @ctxt: the validation context |
|
* @doc: a document instance |
|
* @elem: an element instance |
|
* @attr: an attribute instance |
|
* |
|
* Try to validate a single attribute for an element |
|
* basically it * does the following checks as described by the |
|
* XML-1.0 recommendation: |
|
* - [ VC: Entity Name ] |
|
* - [ VC: Name Token ] |
|
* - [ VC: Fixed Attribute Default ] |
|
* - [ VC: ID ] |
|
* - [ VC: IDREF ] |
|
* - [ VC: Entity Name ] |
|
* |
|
* The ID/IDREF uniqueness and matching are done separately |
|
* |
|
* returns 1 if valid or 0 otherwise |
|
*/ |
|
|
|
int |
|
xmlValidateOneAttribute(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlElementPtr elem, |
|
xmlAttributePtr attr) { |
|
CHECK_DTD; |
|
|
|
return(1); |
|
} |
|
|
|
/** |
|
* xmlValidateOneElement: |
|
* @ctxt: the validation context |
|
* @doc: a document instance |
|
* @elem: an element instance |
|
* |
|
* 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 |
|
* |
|
* returns 1 if valid or 0 otherwise |
|
*/ |
|
|
|
int |
|
xmlValidateOneElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlElementPtr elem) { |
|
CHECK_DTD; |
|
|
|
return(1); |
|
} |
|
|
|
/** |
|
* xmlValidateRoot: |
|
* @ctxt: the validation context |
|
* @doc: a document instance |
|
* |
|
* 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 |
|
* |
|
* returns 1 if valid or 0 otherwise |
|
*/ |
|
|
|
int |
|
xmlValidateRoot(xmlValidCtxtPtr ctxt, xmlDocPtr doc) { |
|
if (doc == NULL) return(0); |
|
|
|
if ((doc->intSubset == NULL) || |
|
(doc->intSubset->name == NULL)) { |
|
VERROR(ctxt->userData, "Not valid: no DtD found\n"); |
|
return(0); |
|
} |
|
if ((doc->root == NULL) || (doc->root->name == NULL)) { |
|
VERROR(ctxt->userData, "Not valid: no root element\n"); |
|
return(0); |
|
} |
|
if (xmlStrcmp(doc->intSubset->name, doc->root->name)) { |
|
VERROR(ctxt->userData, |
|
"Not valid: root and DtD name do not match %s and %s\n", |
|
doc->root->name, doc->intSubset->name); |
|
return(0); |
|
} |
|
return(1); |
|
} |
|
|
|
|
|
/** |
|
* xmlValidateElement: |
|
* @ctxt: the validation context |
|
* @doc: a document instance |
|
* @elem: an element instance |
|
* |
|
* Try to validate the subtree under an element |
|
* |
|
* returns 1 if valid or 0 otherwise |
|
*/ |
|
|
|
int |
|
xmlValidateElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlElementPtr elem) { |
|
CHECK_DTD; |
|
|
|
return(1); |
|
} |
|
|
|
/** |
|
* xmlValidateDtd: |
|
* @ctxt: the validation context |
|
* @doc: a document instance |
|
* @dtd: a dtd instance |
|
* |
|
* Try to validate the dtd instance |
|
* |
|
* basically it does check all the definitions in the DtD. |
|
* |
|
* returns 1 if valid or 0 otherwise |
|
*/ |
|
|
|
int |
|
xmlValidateDtd(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlDtdPtr dtd) { |
|
return(1); |
|
} |
|
|
|
/** |
|
* xmlValidateDocument: |
|
* @ctxt: the validation context |
|
* @doc: a document instance |
|
* |
|
* Try to validate the document instance |
|
* |
|
* basically it does the all the checks described by the |
|
* i.e. validates the internal and external subset (if present) |
|
* and validate the document tree. |
|
* |
|
* returns 1 if valid or 0 otherwise |
|
*/ |
|
|
|
int |
|
xmlValidateDocument(xmlValidCtxtPtr ctxt, xmlDocPtr doc) { |
|
if (!xmlValidateRoot(ctxt, doc)) return(0); |
|
|
|
return(1); |
|
} |
|
|