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

📄 xmlschemas.c

📁 xml开源解析代码.版本为libxml2-2.6.29,可支持GB3212.网络消息发送XML时很有用.
💻 C
📖 第 1 页 / 共 5 页
字号:
	case XML_SCHEMA_TYPE_GROUP:	    return (((xmlSchemaModelGroupDefPtr) item)->name);	case XML_SCHEMA_TYPE_IDC_KEY:	case XML_SCHEMA_TYPE_IDC_UNIQUE:	case XML_SCHEMA_TYPE_IDC_KEYREF:	    return (((xmlSchemaIDCPtr) item)->name);	case XML_SCHEMA_TYPE_ATTRIBUTE_USE:	    if (WXS_ATTRUSE_DECL(item) != NULL) {		return(xmlSchemaGetComponentName(		    WXS_BASIC_CAST WXS_ATTRUSE_DECL(item)));	    } else		return(NULL);	case XML_SCHEMA_EXTRA_QNAMEREF:	    return (((xmlSchemaQNameRefPtr) item)->name);	case XML_SCHEMA_TYPE_NOTATION:	    return (((xmlSchemaNotationPtr) item)->name);	default:	    /*	    * Other components cannot have names.	    */	    break;    }    return (NULL);}#define xmlSchemaGetQNameRefName(r) (WXS_QNAME_CAST (r))->name#define xmlSchemaGetQNameRefTargetNs(r) (WXS_QNAME_CAST (r))->targetNamespace/*static const xmlChar *xmlSchemaGetQNameRefName(void *ref){    return(((xmlSchemaQNameRefPtr) ref)->name);}static const xmlChar *xmlSchemaGetQNameRefTargetNs(void *ref){    return(((xmlSchemaQNameRefPtr) ref)->targetNamespace);}*/static const xmlChar *xmlSchemaGetComponentTargetNs(xmlSchemaBasicItemPtr item){    switch (item->type) {	case XML_SCHEMA_TYPE_ELEMENT:	    return (((xmlSchemaElementPtr) item)->targetNamespace);	case XML_SCHEMA_TYPE_ATTRIBUTE:	    return (((xmlSchemaAttributePtr) item)->targetNamespace);	case XML_SCHEMA_TYPE_ATTRIBUTEGROUP:	    return (((xmlSchemaAttributeGroupPtr) item)->targetNamespace);	case XML_SCHEMA_TYPE_BASIC:	    return (BAD_CAST "http://www.w3.org/2001/XMLSchema");	case XML_SCHEMA_TYPE_SIMPLE:	case XML_SCHEMA_TYPE_COMPLEX:	    return (((xmlSchemaTypePtr) item)->targetNamespace);	case XML_SCHEMA_TYPE_GROUP:	    return (((xmlSchemaModelGroupDefPtr) item)->targetNamespace);	case XML_SCHEMA_TYPE_IDC_KEY:	case XML_SCHEMA_TYPE_IDC_UNIQUE:	case XML_SCHEMA_TYPE_IDC_KEYREF:	    return (((xmlSchemaIDCPtr) item)->targetNamespace);	case XML_SCHEMA_TYPE_ATTRIBUTE_USE:	    if (WXS_ATTRUSE_DECL(item) != NULL) {		return(xmlSchemaGetComponentTargetNs(		    WXS_BASIC_CAST WXS_ATTRUSE_DECL(item)));	    }	    /* TODO: Will returning NULL break something? */	    break;	case XML_SCHEMA_EXTRA_QNAMEREF:	    return (((xmlSchemaQNameRefPtr) item)->targetNamespace);	case XML_SCHEMA_TYPE_NOTATION:	    return (((xmlSchemaNotationPtr) item)->targetNamespace);	default:	    /*	    * Other components cannot have names.	    */	    break;    }    return (NULL);}static const xmlChar*xmlSchemaGetComponentQName(xmlChar **buf,			   void *item){    return (xmlSchemaFormatQName(buf,	xmlSchemaGetComponentTargetNs((xmlSchemaBasicItemPtr) item),	xmlSchemaGetComponentName((xmlSchemaBasicItemPtr) item)));}static const xmlChar*xmlSchemaGetComponentDesignation(xmlChar **buf, void *item){    xmlChar *str = NULL;    *buf = xmlStrcat(*buf, WXS_ITEM_TYPE_NAME(item));    *buf = xmlStrcat(*buf, BAD_CAST " '");    *buf = xmlStrcat(*buf, xmlSchemaGetComponentQName(&str,	(xmlSchemaBasicItemPtr) item));    *buf = xmlStrcat(*buf, BAD_CAST "'");    FREE_AND_NULL(str);    return(*buf);}static const xmlChar*xmlSchemaGetIDCDesignation(xmlChar **buf, xmlSchemaIDCPtr idc){    return(xmlSchemaGetComponentDesignation(buf, idc));}/** * xmlSchemaWildcardPCToString: * @pc: the type of processContents * * Returns a string representation of the type of * processContents. */static const xmlChar *xmlSchemaWildcardPCToString(int pc){    switch (pc) {	case XML_SCHEMAS_ANY_SKIP:	    return (BAD_CAST "skip");	case XML_SCHEMAS_ANY_LAX:	    return (BAD_CAST "lax");	case XML_SCHEMAS_ANY_STRICT:	    return (BAD_CAST "strict");	default:	    return (BAD_CAST "invalid process contents");    }}/** * xmlSchemaGetCanonValueWhtspExt: * @val: the precomputed value * @retValue: the returned value * @ws: the whitespace type of the value * * Get a the cononical representation of the value. * The caller has to free the returned retValue. * * Returns 0 if the value could be built and -1 in case of *         API errors or if the value type is not supported yet. */static intxmlSchemaGetCanonValueWhtspExt(xmlSchemaValPtr val,			       xmlSchemaWhitespaceValueType ws,			       xmlChar **retValue){    int list;    xmlSchemaValType valType;    const xmlChar *value, *value2 = NULL;        if ((retValue == NULL) || (val == NULL))	return (-1);    list = xmlSchemaValueGetNext(val) ? 1 : 0;    *retValue = NULL;    do {	value = NULL;		valType = xmlSchemaGetValType(val);    	switch (valType) {	    	    case XML_SCHEMAS_STRING:	    case XML_SCHEMAS_NORMSTRING:	    case XML_SCHEMAS_ANYSIMPLETYPE:		value = xmlSchemaValueGetAsString(val);		if (value != NULL) {		    if (ws == XML_SCHEMA_WHITESPACE_COLLAPSE)			value2 = xmlSchemaCollapseString(value);		    else if (ws == XML_SCHEMA_WHITESPACE_REPLACE)			value2 = xmlSchemaWhiteSpaceReplace(value);		    if (value2 != NULL)			value = value2;		}		break;	   	    default:		if (xmlSchemaGetCanonValue(val, &value2) == -1) {		    if (value2 != NULL)			xmlFree((xmlChar *) value2);		    goto internal_error;		}		value = value2;	}	if (*retValue == NULL)	    if (value == NULL) {		if (! list)		    *retValue = xmlStrdup(BAD_CAST "");	    } else		*retValue = xmlStrdup(value);	else if (value != NULL) {	    /* List. */	    *retValue = xmlStrcat((xmlChar *) *retValue, BAD_CAST " ");	    *retValue = xmlStrcat((xmlChar *) *retValue, value);	}	FREE_AND_NULL(value2)	val = xmlSchemaValueGetNext(val);    } while (val != NULL);    return (0);internal_error:    if (*retValue != NULL)	xmlFree((xmlChar *) (*retValue));    if (value2 != NULL)	xmlFree((xmlChar *) value2);    return (-1);}/** * xmlSchemaFormatItemForReport: * @buf: the string buffer * @itemDes: the designation of the item * @itemName: the name of the item * @item: the item as an object  * @itemNode: the node of the item * @local: the local name * @parsing: if the function is used during the parse * * Returns a representation of the given item used * for error reports.  * * The following order is used to build the resulting  * designation if the arguments are not NULL: * 1a. If itemDes not NULL -> itemDes * 1b. If (itemDes not NULL) and (itemName not NULL) *     -> itemDes + itemName * 2. If the preceding was NULL and (item not NULL) -> item * 3. If the preceding was NULL and (itemNode not NULL) -> itemNode *  * If the itemNode is an attribute node, the name of the attribute * will be appended to the result. * * Returns the formatted string and sets @buf to the resulting value. */  static xmlChar*   xmlSchemaFormatItemForReport(xmlChar **buf,		     		     const xmlChar *itemDes,		     xmlSchemaBasicItemPtr item,		     xmlNodePtr itemNode){    xmlChar *str = NULL;    int named = 1;    if (*buf != NULL) {	xmlFree(*buf);	*buf = NULL;    }                if (itemDes != NULL) {	*buf = xmlStrdup(itemDes);	    } else if (item != NULL) {	switch (item->type) {	case XML_SCHEMA_TYPE_BASIC: {	    xmlSchemaTypePtr type = WXS_TYPE_CAST item;	    if (WXS_IS_ATOMIC(type))		*buf = xmlStrdup(BAD_CAST "atomic type 'xs:");	    else if (WXS_IS_LIST(type))		*buf = xmlStrdup(BAD_CAST "list type 'xs:");	    else if (WXS_IS_UNION(type))		*buf = xmlStrdup(BAD_CAST "union type 'xs:");	    else		*buf = xmlStrdup(BAD_CAST "simple type 'xs:");	    *buf = xmlStrcat(*buf, type->name);	    *buf = xmlStrcat(*buf, BAD_CAST "'");	    }	    break;	case XML_SCHEMA_TYPE_SIMPLE: {	    xmlSchemaTypePtr type = WXS_TYPE_CAST item;	    if (type->flags & XML_SCHEMAS_TYPE_GLOBAL) {		*buf = xmlStrdup(BAD_CAST"");	    } else {		*buf = xmlStrdup(BAD_CAST "local ");	    }	    if (WXS_IS_ATOMIC(type))		*buf = xmlStrcat(*buf, BAD_CAST "atomic type");	    else if (WXS_IS_LIST(type))		*buf = xmlStrcat(*buf, BAD_CAST "list type");	    else if (WXS_IS_UNION(type))		*buf = xmlStrcat(*buf, BAD_CAST "union type");	    else		*buf = xmlStrcat(*buf, BAD_CAST "simple type");	    if (type->flags & XML_SCHEMAS_TYPE_GLOBAL) {		*buf = xmlStrcat(*buf, BAD_CAST " '");		*buf = xmlStrcat(*buf, type->name);		*buf = xmlStrcat(*buf, BAD_CAST "'");	    }	    }	    break;	case XML_SCHEMA_TYPE_COMPLEX: {	    xmlSchemaTypePtr type = WXS_TYPE_CAST item;	    if (type->flags & XML_SCHEMAS_TYPE_GLOBAL)		*buf = xmlStrdup(BAD_CAST "");	    else		*buf = xmlStrdup(BAD_CAST "local ");	    *buf = xmlStrcat(*buf, BAD_CAST "complex type");	    if (type->flags & XML_SCHEMAS_TYPE_GLOBAL) {		*buf = xmlStrcat(*buf, BAD_CAST " '");		*buf = xmlStrcat(*buf, type->name);		*buf = xmlStrcat(*buf, BAD_CAST "'");	    }	    }	    break;	case XML_SCHEMA_TYPE_ATTRIBUTE_USE: {		xmlSchemaAttributeUsePtr ause;	    		ause = WXS_ATTR_USE_CAST item;		*buf = xmlStrdup(BAD_CAST "attribute use ");		if (WXS_ATTRUSE_DECL(ause) != NULL) {		    *buf = xmlStrcat(*buf, BAD_CAST "'");		    *buf = xmlStrcat(*buf,			xmlSchemaGetComponentQName(&str, WXS_ATTRUSE_DECL(ause)));		    FREE_AND_NULL(str)			*buf = xmlStrcat(*buf, BAD_CAST "'");		} else {		    *buf = xmlStrcat(*buf, BAD_CAST "(unknown)");		}	    }	    break;	case XML_SCHEMA_TYPE_ATTRIBUTE: {		xmlSchemaAttributePtr attr;	    		attr = (xmlSchemaAttributePtr) item;		*buf = xmlStrdup(BAD_CAST "attribute decl.");		*buf = xmlStrcat(*buf, BAD_CAST " '");		*buf = xmlStrcat(*buf, xmlSchemaFormatQName(&str,		    attr->targetNamespace, attr->name));		FREE_AND_NULL(str)		    *buf = xmlStrcat(*buf, BAD_CAST "'");	    }	    break;	case XML_SCHEMA_TYPE_ATTRIBUTEGROUP:	    xmlSchemaGetComponentDesignation(buf, item);	    break;	case XML_SCHEMA_TYPE_ELEMENT: {		xmlSchemaElementPtr elem;		elem = (xmlSchemaElementPtr) item;	    		*buf = xmlStrdup(BAD_CAST "element decl.");		*buf = xmlStrcat(*buf, BAD_CAST " '");		*buf = xmlStrcat(*buf, xmlSchemaFormatQName(&str,		    elem->targetNamespace, elem->name));		*buf = xmlStrcat(*buf, BAD_CAST "'");	    }	    break;	case XML_SCHEMA_TYPE_IDC_UNIQUE:	case XML_SCHEMA_TYPE_IDC_KEY:	case XML_SCHEMA_TYPE_IDC_KEYREF:			    if (item->type == XML_SCHEMA_TYPE_IDC_UNIQUE)		*buf = xmlStrdup(BAD_CAST "unique '");	    else if (item->type == XML_SCHEMA_TYPE_IDC_KEY)		*buf = xmlStrdup(BAD_CAST "key '");	    else		*buf = xmlStrdup(BAD_CAST "keyRef '");	    *buf = xmlStrcat(*buf, ((xmlSchemaIDCPtr) item)->name);	    *buf = xmlStrcat(*buf, BAD_CAST "'");	    break;	case XML_SCHEMA_TYPE_ANY:	case XML_SCHEMA_TYPE_ANY_ATTRIBUTE:	    *buf = xmlStrdup(xmlSchemaWildcardPCToString(		    ((xmlSchemaWildcardPtr) item)->processContents));	    *buf = xmlStrcat(*buf, BAD_CAST " wildcard");	    break;	case XML_SCHEMA_FACET_MININCLUSIVE:	case XML_SCHEMA_FACET_MINEXCLUSIVE:	case XML_SCHEMA_FACET_MAXINCLUSIVE:	case XML_SCHEMA_FACET_MAXEXCLUSIVE:	case XML_SCHEMA_FACET_TOTALDIGITS:	case XML_SCHEMA_FACET_FRACTIONDIGITS:	case XML_SCHEMA_FACET_PATTERN:	case XML_SCHEMA_FACET_ENUMERATION:	case XML_SCHEMA_FACET_WHITESPACE:	case XML_SCHEMA_FACET_LENGTH:	case XML_SCHEMA_FACET_MAXLENGTH:	case XML_SCHEMA_FACET_MINLENGTH:	    *buf = xmlStrdup(BAD_CAST "facet '");	    *buf = xmlStrcat(*buf, xmlSchemaFacetTypeToString(item->type));	    *buf = xmlStrcat(*buf, BAD_CAST "'");	    break;	case XML_SCHEMA_TYPE_GROUP: {		*buf = xmlStrdup(BAD_CAST "model group def.");		*buf = xmlStrcat(*buf, BAD_CAST " '");		*buf = xmlStrcat(*buf, xmlSchemaGetComponentQName(&str, item));		*buf = xmlStrcat(*buf, BAD_CAST "'");		FREE_AND_NULL(str)	    }	    break;	case XML_SCHEMA_TYPE_SEQUENCE:	case XML_SCHEMA_TYPE_CHOICE:	case XML_SCHEMA_TYPE_ALL:	case XML_SCHEMA_TYPE_PARTICLE:	    *buf = xmlStrdup(WXS_ITEM_TYPE_NAME(item));	    break;	case XML_SCHEMA_TYPE_NOTATION: {		*buf = xmlStrdup(WXS_ITEM_TYPE_NAME(item));		*buf = xmlStrcat(*buf, BAD_CAST " '");		*buf = xmlStrcat(*buf, xmlSchemaGetComponentQName(&str, item));		*buf = xmlStrcat(*buf, BAD_CAST "'");		FREE_AND_NULL(str);	    }	default:	    named = 0;	}    } else 	named = 0;    if ((named == 0) && (itemNode != NULL)) {	xmlNodePtr elem;	if (itemNode->type == XML_ATTRIBUTE_NODE)	    elem = itemNode->parent;	else 	    elem = itemNode;	*buf = xmlStrdup(BAD_CAST "Element '");	if (elem->ns != NULL) {	    *buf = xmlStrcat(*buf,		xmlSchemaFormatQName(&str, elem->ns->href, elem->name));	    FREE_AND_NULL(str)	} else	    *buf = xmlStrcat(*buf, elem->name);	*buf = xmlStrcat(*buf, BAD_CAST "'");	    }    if ((itemNode != NULL) && (itemNode->type == XML_ATTRIBUTE_NODE)) {	*buf = xmlStrcat(*buf, BAD_CAST ", attribute '");	if (itemNode->ns != NULL) {	    *buf = xmlStrcat(*buf, xmlSchemaFormatQName(&str,		itemNode->ns->href, itemNode->name));	    FREE_AND_NULL(str)	} else	    *buf = xmlStrcat(*buf, itemNode->name);	*buf = xmlStrcat(*buf, BAD_CAST "'");    }    FREE_AND_NULL(str)        return (*buf);}/** * xmlSchemaFormatFacetEnumSet: * @buf: the string buffer

⌨️ 快捷键说明

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