⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xmlschemas.c

📁 libxml,在UNIX/LINUX下非常重要的一个库,为XML相关应用提供方便.目前上载的是最新版本,若要取得最新版本,请参考里面的readme.
💻 C
📖 第 1 页 / 共 5 页
字号:
{    xmlChar *str = NULL, *msg = NULL;        xmlSchemaFormatItemForReport(&msg, NULL,  NULL, node, 0);    /* Specify the complex type only if it is global. */    if ((type != NULL) && (type->flags & XML_SCHEMAS_TYPE_GLOBAL)) {	msg = xmlStrcat(msg, BAD_CAST " [");	msg = xmlStrcat(msg, xmlSchemaFormatItemForReport(&str, NULL, type, NULL, 0));	msg = xmlStrcat(msg, BAD_CAST "]");    }    msg = xmlStrcat(msg, BAD_CAST ": %s.\n");       xmlSchemaVErr(ctxt, node, error, (const char *) msg,	(const xmlChar *) message, NULL);    FREE_AND_NULL(str)	    xmlFree(msg);}/** * xmlSchemaVComplexTypeElemErr: * @ctxt:  the schema validation context * @error: the error code * @node: the node containing the validated value * @type: the complex type used for validation * @message: the error message * * Reports a complex type validation error. */static voidxmlSchemaVComplexTypeElemErr(xmlSchemaValidCtxtPtr ctxt, 			xmlParserErrors error,			xmlNodePtr node,			xmlSchemaTypePtr type,						const char *message,			int nbval,			int nbneg,			xmlChar **values){    xmlChar *str = NULL, *msg = NULL;    xmlChar *localName, *nsName;    const xmlChar *cur, *end;    int i;        xmlSchemaFormatItemForReport(&msg, NULL,  NULL, node, 0);    /* Specify the complex type only if it is global. */    if ((type != NULL) && (type->flags & XML_SCHEMAS_TYPE_GLOBAL)) {	msg = xmlStrcat(msg, BAD_CAST " [");	msg = xmlStrcat(msg, xmlSchemaFormatItemForReport(&str, NULL, type, NULL, 0));	msg = xmlStrcat(msg, BAD_CAST "]");	FREE_AND_NULL(str)    }    msg = xmlStrcat(msg, BAD_CAST ": ");    msg = xmlStrcat(msg, (const xmlChar *) message);    /*    * Note that is does not make sense to report that we have a    * wildcard here, since the wildcard might be unfolded into    * multiple transitions.    */    if (nbval + nbneg > 0) {	if (nbval + nbneg > 1) {	    str = xmlStrdup(BAD_CAST ". Expected is one of ( ");	} else	    str = xmlStrdup(BAD_CAST ". Expected is ( ");	nsName = NULL;    	    	for (i = 0; i < nbval + nbneg; i++) {	    cur = values[i];	    /*	    * Get the local name.	    */	    localName = NULL;	    	    end = cur;	    if (*end == '*') {		localName = xmlStrdup(BAD_CAST "*");		*end++;	    } else {		while ((*end != 0) && (*end != '|'))		    end++;		localName = xmlStrncat(localName, BAD_CAST cur, end - cur);	    }			    if (*end != 0) {		    		*end++;		/*		* Skip "*|*" if they come with negated expressions, since		* they represent the same negated wildcard.		*/		if ((nbneg == 0) || (*end != '*') || (*localName != '*')) {		    /*		    * Get the namespace name.		    */		    cur = end;		    if (*end == '*') {			nsName = xmlStrdup(BAD_CAST "{*}");		    } else {			while (*end != 0)			    end++;						if (i >= nbval)			    nsName = xmlStrdup(BAD_CAST "{##other:");			else			    nsName = xmlStrdup(BAD_CAST "{");						nsName = xmlStrncat(nsName, BAD_CAST cur, end - cur);			nsName = xmlStrcat(nsName, BAD_CAST "}");		    }		    str = xmlStrcat(str, BAD_CAST nsName);		    FREE_AND_NULL(nsName)		} else {		    FREE_AND_NULL(localName);		    continue;		}	    }	        	    str = xmlStrcat(str, BAD_CAST localName);	    FREE_AND_NULL(localName);			    if (i < nbval + nbneg -1)		str = xmlStrcat(str, BAD_CAST ", ");	}		str = xmlStrcat(str, BAD_CAST " )");	msg = xmlStrcat(msg, BAD_CAST str);	FREE_AND_NULL(str)    }        msg = xmlStrcat(msg, BAD_CAST ".\n");    xmlSchemaVErr(ctxt, node, error, (const char *) msg, NULL, NULL);    	    xmlFree(msg);}/** * xmlSchemaPMissingAttrErr: * @ctxt: the schema validation context * @ownerDes: the designation of  the owner * @ownerName: the name of the owner * @ownerItem: the owner as a schema object * @ownerElem: the owner as an element node * @node: the parent element node of the missing attribute node * @type: the corresponding type of the attribute node * * Reports an illegal attribute. */static voidxmlSchemaPMissingAttrErr(xmlSchemaParserCtxtPtr ctxt,			 xmlParserErrors error,			 			 xmlChar **ownerDes,			 xmlSchemaTypePtr ownerItem,			 xmlNodePtr ownerElem,			 const char *name,			 const char *message){    xmlChar *des = NULL;    if (ownerDes == NULL)	xmlSchemaFormatItemForReport(&des, NULL, ownerItem, ownerElem, 1);    else if (*ownerDes == NULL) {	xmlSchemaFormatItemForReport(ownerDes, NULL, ownerItem, ownerElem, 1);	des = *ownerDes;    } else 	des = *ownerDes;          if (message != NULL)	xmlSchemaPErr(ctxt, ownerElem, error, "%s: %s.\n", BAD_CAST des, BAD_CAST message);    else		xmlSchemaPErr(ctxt, ownerElem, error, 	    "%s: The attribute '%s' is required but missing.\n", 	    BAD_CAST des, BAD_CAST name);    if (ownerDes == NULL)	FREE_AND_NULL(des);}/** * xmlSchemaCompTypeToString: * @type: the type of the schema item * * Returns the component name of a schema item. */static const xmlChar *xmlSchemaCompTypeToString(xmlSchemaTypeType type){    switch (type) {	case XML_SCHEMA_TYPE_SIMPLE:	    return(BAD_CAST "simple type definition");	case XML_SCHEMA_TYPE_COMPLEX:	    return(BAD_CAST "complex type definition");	case XML_SCHEMA_TYPE_ELEMENT:	    return(BAD_CAST "element declaration");	case XML_SCHEMA_TYPE_ATTRIBUTE:	    return(BAD_CAST "attribute declaration");	case XML_SCHEMA_TYPE_GROUP:	    return(BAD_CAST "model group definition");	case XML_SCHEMA_TYPE_ATTRIBUTEGROUP:	    return(BAD_CAST "attribute group definition");	case XML_SCHEMA_TYPE_NOTATION:	    return(BAD_CAST "notation declaration");	case XML_SCHEMA_TYPE_SEQUENCE:	    return(BAD_CAST "model group (sequence)");	case XML_SCHEMA_TYPE_CHOICE:	    return(BAD_CAST "model group (choice)");	case XML_SCHEMA_TYPE_ALL:	    return(BAD_CAST "model group (all)");	case XML_SCHEMA_TYPE_PARTICLE:	    return(BAD_CAST "particle");	default:	    return(BAD_CAST "Not a schema component");    }}/** * xmlSchemaPResCompAttrErr: * @ctxt: the schema validation context * @error: the error code * @ownerDes: the designation of  the owner * @ownerItem: the owner as a schema object * @ownerElem: the owner as an element node * @name: the name of the attribute holding the QName  * @refName: the referenced local name * @refURI: the referenced namespace URI * @message: optional message * * Used to report QName attribute values that failed to resolve * to schema components. */static voidxmlSchemaPResCompAttrErr(xmlSchemaParserCtxtPtr ctxt,			 xmlParserErrors error,			 			 xmlChar **ownerDes,			 xmlSchemaTypePtr ownerItem,			 xmlNodePtr ownerElem,			 const char *name,			 const xmlChar *refName,			 const xmlChar *refURI,			 xmlSchemaTypeType refType,			 const char *refTypeStr){    xmlChar *des = NULL, *strA = NULL;    if (ownerDes == NULL)	xmlSchemaFormatItemForReport(&des, NULL, ownerItem, ownerElem, 1);    else if (*ownerDes == NULL) {	xmlSchemaFormatItemForReport(ownerDes, NULL, ownerItem, ownerElem, 1);	des = *ownerDes;    } else	des = *ownerDes;    if (refTypeStr == NULL)	refTypeStr = (const char *) xmlSchemaCompTypeToString(refType);    	xmlSchemaPErrExt(ctxt, ownerElem, error, 	    NULL, NULL, NULL,	    "%s, attribute '%s': The QName value %s does not resolve to a(n) "	    "%s.\n", BAD_CAST des, BAD_CAST name, 	    xmlSchemaFormatNsUriLocal(&strA, refURI, refName), 	    BAD_CAST refTypeStr, NULL);    if (ownerDes == NULL)	FREE_AND_NULL(des)    FREE_AND_NULL(strA)}/** * xmlSchemaPCustomAttrErr: * @ctxt: the schema parser context * @error: the error code * @ownerDes: the designation of the owner * @ownerItem: the owner as a schema object * @attr: the illegal attribute node  * * Reports an illegal attribute during the parse. */static voidxmlSchemaPCustomAttrErr(xmlSchemaParserCtxtPtr ctxt,			xmlParserErrors error,				xmlChar **ownerDes,			xmlSchemaTypePtr ownerItem,			xmlAttrPtr attr,			const char *msg){    xmlChar *des = NULL;    if (ownerDes == NULL)	xmlSchemaFormatItemForReport(&des, NULL, ownerItem, attr->parent, 1);    else if (*ownerDes == NULL) {	xmlSchemaFormatItemForReport(ownerDes, NULL, ownerItem, attr->parent, 1);	des = *ownerDes;    } else 	des = *ownerDes;        xmlSchemaPErrExt(ctxt, (xmlNodePtr) attr, error, NULL, NULL, NULL,	"%s, attribute '%s': %s.\n", 	BAD_CAST des, attr->name, (const xmlChar *) msg, NULL, NULL);    if (ownerDes == NULL)	FREE_AND_NULL(des);}/** * xmlSchemaPIllegalAttrErr: * @ctxt: the schema parser context * @error: the error code * @ownerDes: the designation of the attribute's owner * @ownerItem: the attribute's owner item * @attr: the illegal attribute node  * * Reports an illegal attribute during the parse. */static voidxmlSchemaPIllegalAttrErr(xmlSchemaParserCtxtPtr ctxt,			 xmlParserErrors error,				 xmlChar **ownerDes,			 xmlSchemaTypePtr ownerItem,			 xmlAttrPtr attr){    xmlChar *des = NULL, *strA = NULL;    if (ownerDes == NULL)	xmlSchemaFormatItemForReport(&des, NULL, ownerItem, attr->parent, 1);    else if (*ownerDes == NULL) {	xmlSchemaFormatItemForReport(ownerDes, NULL, ownerItem, attr->parent, 1);	des = *ownerDes;    } else 	des = *ownerDes;        xmlSchemaPErr(ctxt, (xmlNodePtr) attr, error, 	"%s: The attribute '%s' is not allowed.\n", BAD_CAST des, 	xmlSchemaFormatNsPrefixLocal(&strA, attr->ns, attr->name));    if (ownerDes == NULL)	FREE_AND_NULL(des);    FREE_AND_NULL(strA);}/** * xmlSchemaPAquireDes: * @des: the first designation  * @itemDes: the second designation * @item: the schema item  * @itemElem: the node of the schema item * * Creates a designation for an item. */static voidxmlSchemaPAquireDes(xmlChar **des,		    xmlChar **itemDes, 		    xmlSchemaTypePtr item,		    xmlNodePtr itemElem){    if (itemDes == NULL)	xmlSchemaFormatItemForReport(des, NULL, item, itemElem, 1);    else if (*itemDes == NULL) {	xmlSchemaFormatItemForReport(itemDes, NULL, item, itemElem, 1);	*des = *itemDes;    } else 	*des = *itemDes;  }/** * xmlSchemaPCustomErr: * @ctxt: the schema parser context * @error: the error code * @itemDes: the designation of the schema item * @item: the schema item * @itemElem: the node of the schema item * @message: the error message * @str1: an optional param for the error message * @str2: an optional param for the error message * @str3: an optional param for the error message * * Reports an error during parsing. */static voidxmlSchemaPCustomErrExt(xmlSchemaParserCtxtPtr ctxt,		    xmlParserErrors error,			    xmlChar **itemDes,		    xmlSchemaTypePtr item,		    xmlNodePtr itemElem,		    const char *message,		    const xmlChar *str1,		    const xmlChar *str2,		    const xmlChar *str3){    xmlChar *des = NULL, *msg = NULL;    xmlSchemaPAquireDes(&des, itemDes, item, itemElem);       msg = xmlStrdup(BAD_CAST "%s: ");    msg = xmlStrcat(msg, (const xmlChar *) message);    msg = xmlStrcat(msg, BAD_CAST ".\n");    if ((itemElem == NULL) && (item != NULL))	itemElem = item->node;    xmlSchemaPErrExt(ctxt, itemElem, error, NULL, NULL, NULL, 	(const char *) msg, BAD_CAST des, str1, str2, str3, NULL);    if (itemDes == NULL)	FREE_AND_NULL(des);    FREE_AND_NULL(msg);}/** * xmlSchemaPCustomErr: * @ctxt: the schema parser context * @error: the error code * @itemDes: the designation of the schema item * @item: the schema item * @itemElem: the node of the schema item * @message: the error message * @str1: the optional param for the error message * * Reports an error during parsing. */static voidxmlSchemaPCustomErr(xmlSchemaParserCtxtPtr ctxt,		    xmlParserErrors error,			    xmlChar **itemDes,		    xmlSchemaTypePtr item,		    xmlNodePtr itemElem,		    const char *message,		    const xmlChar *str1){    xmlSchemaPCustomErrExt(ctxt, error, itemDes, item, itemElem, message,	str1, NULL, NULL);}/** * xmlSchemaPAttrUseErr: * @ctxt: the schema parser context * @error: the error code * @itemDes: the designation of the schema type * @item: the schema type * @itemElem: the node of the schema type * @attr: the invalid schema attribute * @message: the error message * @str1: the optional param for the error message * * Reports an attribute use error during parsing. */static voidxmlSchemaPAttrUseErr(xmlSchemaParserCtxtPtr ctxt,		    xmlParserErrors error,			    xmlChar **itemDes,		    xmlSchemaTypePtr item,		    xmlNodePtr itemElem,		    const xmlSchemaAttributePtr attr,		    const char *message,		    const xmlChar *str1){    xmlChar *des = NULL, *strA = NULL, *msg = NULL;    xmlSchemaPAquireDes(&des, itemDes, item, itemElem);    xmlSchemaFormatNsUriLocal(&strA, xmlSchemaGetAttrTargetNsURI(attr), 	xmlSchemaGetAttrName(attr));    msg = xmlStrdup(BAD_CAST "%s, attr. use %s: ");    msg = xmlStrcat(msg, (const xmlChar *) message);    msg = xmlStrcat(ms

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -