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

📄 xmlschemas.c.svn-base

📁 这是一个用于解析xml文件的类库。使用这个类库
💻 SVN-BASE
📖 第 1 页 / 共 5 页
字号:
 * xmlSchemaFreeImport: * @import:  a schema import structure * * Deallocate an import structure */static voidxmlSchemaFreeImport(xmlSchemaImportPtr import){    if (import == NULL)        return;    xmlSchemaFree(import->schema);    xmlFree(import);}/** * xmlSchemaFreeInclude: * @include:  a schema include structure * * Deallocate an include structure */static voidxmlSchemaFreeInclude(xmlSchemaIncludePtr include){    if (include == NULL)        return;    xmlFreeDoc(include->doc);    xmlFree(include);}/** * xmlSchemaFreeIncludeList: * @includes:  a schema include list * * Deallocate an include structure */static voidxmlSchemaFreeIncludeList(xmlSchemaIncludePtr includes){    xmlSchemaIncludePtr next;    while (includes != NULL) {        next = includes->next;	xmlSchemaFreeInclude(includes);	includes = next;    }}/** * xmlSchemaFreeNotation: * @schema:  a schema notation structure * * Deallocate a Schema Notation structure. */static voidxmlSchemaFreeNotation(xmlSchemaNotationPtr nota){    if (nota == NULL)        return;    xmlFree(nota);}/** * xmlSchemaFreeAttribute: * @schema:  a schema attribute structure * * Deallocate a Schema Attribute structure. */static voidxmlSchemaFreeAttribute(xmlSchemaAttributePtr attr){    if (attr == NULL)        return;    xmlFree(attr);}/** * xmlSchemaFreeAttributeGroup: * @schema:  a schema attribute group structure * * Deallocate a Schema Attribute Group structure. */static voidxmlSchemaFreeAttributeGroup(xmlSchemaAttributeGroupPtr attr){    if (attr == NULL)        return;    xmlFree(attr);}/** * xmlSchemaFreeElement: * @schema:  a schema element structure * * Deallocate a Schema Element structure. */static voidxmlSchemaFreeElement(xmlSchemaElementPtr elem){    if (elem == NULL)        return;    if (elem->annot != NULL)        xmlSchemaFreeAnnot(elem->annot);    if (elem->contModel != NULL)        xmlRegFreeRegexp(elem->contModel);    xmlFree(elem);}/** * xmlSchemaFreeFacet: * @facet:  a schema facet structure * * Deallocate a Schema Facet structure. */voidxmlSchemaFreeFacet(xmlSchemaFacetPtr facet){    if (facet == NULL)        return;    if (facet->val != NULL)        xmlSchemaFreeValue(facet->val);    if (facet->regexp != NULL)        xmlRegFreeRegexp(facet->regexp);    if (facet->annot != NULL)        xmlSchemaFreeAnnot(facet->annot);    xmlFree(facet);}/** * xmlSchemaFreeType: * @type:  a schema type structure * * Deallocate a Schema Type structure. */voidxmlSchemaFreeType(xmlSchemaTypePtr type){    if (type == NULL)        return;    if (type->annot != NULL)        xmlSchemaFreeAnnot(type->annot);    if (type->facets != NULL) {        xmlSchemaFacetPtr facet, next;        facet = type->facets;        while (facet != NULL) {            next = facet->next;            xmlSchemaFreeFacet(facet);            facet = next;        }    }    xmlFree(type);}/** * xmlSchemaFreeTypeList: * @type:  a schema type structure * * Deallocate a Schema Type structure. */static voidxmlSchemaFreeTypeList(xmlSchemaTypePtr type){    xmlSchemaTypePtr next;    while (type != NULL) {        next = type->redef;	xmlSchemaFreeType(type);	type = next;    }}/** * xmlSchemaFree: * @schema:  a schema structure * * Deallocate a Schema structure. */voidxmlSchemaFree(xmlSchemaPtr schema){    if (schema == NULL)        return;    if (schema->notaDecl != NULL)        xmlHashFree(schema->notaDecl,                    (xmlHashDeallocator) xmlSchemaFreeNotation);    if (schema->attrDecl != NULL)        xmlHashFree(schema->attrDecl,                    (xmlHashDeallocator) xmlSchemaFreeAttribute);    if (schema->attrgrpDecl != NULL)        xmlHashFree(schema->attrgrpDecl,                    (xmlHashDeallocator) xmlSchemaFreeAttributeGroup);    if (schema->elemDecl != NULL)        xmlHashFree(schema->elemDecl,                    (xmlHashDeallocator) xmlSchemaFreeElement);    if (schema->typeDecl != NULL)        xmlHashFree(schema->typeDecl,                    (xmlHashDeallocator) xmlSchemaFreeTypeList);    if (schema->groupDecl != NULL)        xmlHashFree(schema->groupDecl,                    (xmlHashDeallocator) xmlSchemaFreeType);    if (schema->schemasImports != NULL)	xmlHashFree(schema->schemasImports,		    (xmlHashDeallocator) xmlSchemaFreeImport);    if (schema->includes != NULL) {        xmlSchemaFreeIncludeList((xmlSchemaIncludePtr) schema->includes);    }    if (schema->annot != NULL)        xmlSchemaFreeAnnot(schema->annot);    if (schema->doc != NULL && !schema->preserve)        xmlFreeDoc(schema->doc);    xmlDictFree(schema->dict);    xmlFree(schema);}/************************************************************************ * 									* * 			Debug functions					* * 									* ************************************************************************/#ifdef LIBXML_OUTPUT_ENABLED/** * xmlSchemaElementDump: * @elem:  an element * @output:  the file output * * Dump the element */static voidxmlSchemaElementDump(xmlSchemaElementPtr elem, FILE * output,                     const xmlChar * name ATTRIBUTE_UNUSED,                     const xmlChar * context ATTRIBUTE_UNUSED,                     const xmlChar * namespace ATTRIBUTE_UNUSED){    if (elem == NULL)        return;    fprintf(output, "Element ");    if (elem->flags & XML_SCHEMAS_ELEM_TOPLEVEL)        fprintf(output, "toplevel ");    fprintf(output, ": %s ", elem->name);    if (namespace != NULL)        fprintf(output, "namespace '%s' ", namespace);    if (elem->flags & XML_SCHEMAS_ELEM_NILLABLE)        fprintf(output, "nillable ");    if (elem->flags & XML_SCHEMAS_ELEM_GLOBAL)        fprintf(output, "global ");    if (elem->flags & XML_SCHEMAS_ELEM_DEFAULT)        fprintf(output, "default ");    if (elem->flags & XML_SCHEMAS_ELEM_FIXED)        fprintf(output, "fixed ");    if (elem->flags & XML_SCHEMAS_ELEM_ABSTRACT)        fprintf(output, "abstract ");    if (elem->flags & XML_SCHEMAS_ELEM_REF)        fprintf(output, "ref '%s' ", elem->ref);    if (elem->id != NULL)        fprintf(output, "id '%s' ", elem->id);    fprintf(output, "\n");    if ((elem->minOccurs != 1) || (elem->maxOccurs != 1)) {        fprintf(output, "  ");        if (elem->minOccurs != 1)            fprintf(output, "min: %d ", elem->minOccurs);        if (elem->maxOccurs >= UNBOUNDED)            fprintf(output, "max: unbounded\n");        else if (elem->maxOccurs != 1)            fprintf(output, "max: %d\n", elem->maxOccurs);        else            fprintf(output, "\n");    }    if (elem->namedType != NULL) {        fprintf(output, "  type: %s", elem->namedType);        if (elem->namedTypeNs != NULL)            fprintf(output, " ns %s\n", elem->namedTypeNs);        else            fprintf(output, "\n");    }    if (elem->substGroup != NULL) {        fprintf(output, "  substitutionGroup: %s", elem->substGroup);        if (elem->substGroupNs != NULL)            fprintf(output, " ns %s\n", elem->substGroupNs);        else            fprintf(output, "\n");    }    if (elem->value != NULL)        fprintf(output, "  default: %s", elem->value);}/** * xmlSchemaAnnotDump: * @output:  the file output * @annot:  a annotation * * Dump the annotation */static voidxmlSchemaAnnotDump(FILE * output, xmlSchemaAnnotPtr annot){    xmlChar *content;    if (annot == NULL)        return;    content = xmlNodeGetContent(annot->content);    if (content != NULL) {        fprintf(output, "  Annot: %s\n", content);        xmlFree(content);    } else        fprintf(output, "  Annot: empty\n");}/** * xmlSchemaTypeDump: * @output:  the file output * @type:  a type structure * * Dump a SchemaType structure */static voidxmlSchemaTypeDump(xmlSchemaTypePtr type, FILE * output){    if (type == NULL) {        fprintf(output, "Type: NULL\n");        return;    }    fprintf(output, "Type: ");    if (type->name != NULL)        fprintf(output, "%s, ", type->name);    else        fprintf(output, "no name");    switch (type->type) {        case XML_SCHEMA_TYPE_BASIC:            fprintf(output, "basic ");            break;        case XML_SCHEMA_TYPE_SIMPLE:            fprintf(output, "simple ");            break;        case XML_SCHEMA_TYPE_COMPLEX:            fprintf(output, "complex ");            break;        case XML_SCHEMA_TYPE_SEQUENCE:            fprintf(output, "sequence ");            break;        case XML_SCHEMA_TYPE_CHOICE:            fprintf(output, "choice ");            break;        case XML_SCHEMA_TYPE_ALL:            fprintf(output, "all ");            break;        case XML_SCHEMA_TYPE_UR:            fprintf(output, "ur ");            break;        case XML_SCHEMA_TYPE_RESTRICTION:            fprintf(output, "restriction ");            break;        case XML_SCHEMA_TYPE_EXTENSION:            fprintf(output, "extension ");            break;        default:            fprintf(output, "unknowntype%d ", type->type);            break;    }    if (type->base != NULL) {        fprintf(output, "base %s, ", type->base);    }    switch (type->contentType) {        case XML_SCHEMA_CONTENT_UNKNOWN:            fprintf(output, "unknown ");            break;        case XML_SCHEMA_CONTENT_EMPTY:            fprintf(output, "empty ");            break;        case XML_SCHEMA_CONTENT_ELEMENTS:            fprintf(output, "element ");            break;        case XML_SCHEMA_CONTENT_MIXED:            fprintf(output, "mixed ");            break;        case XML_SCHEMA_CONTENT_MIXED_OR_ELEMENTS:            fprintf(output, "mixed_or_elems ");            break;        case XML_SCHEMA_CONTENT_BASIC:            fprintf(output, "basic ");            break;        case XML_SCHEMA_CONTENT_SIMPLE:            fprintf(output, "simple ");            break;        case XML_SCHEMA_CONTENT_ANY:            fprintf(output, "any ");            break;    }    fprintf(output, "\n");    if ((type->minOccurs != 1) || (type->maxOccurs != 1)) {        fprintf(output, "  ");        if (type->minOccurs != 1)            fprintf(output, "min: %d ", type->minOccurs);        if (type->maxOccurs >= UNBOUNDED)            fprintf(output, "max: unbounded\n");        else if (type->maxOccurs != 1)            fprintf(output, "max: %d\n", type->maxOccurs);        else            fprintf(output, "\n");    }    if (type->annot != NULL)        xmlSchemaAnnotDump(output, type->annot);    if (type->subtypes != NULL) {        xmlSchemaTypePtr sub = type->subtypes;        fprintf(output, "  subtypes: ");        while (sub != NULL) {            fprintf(output, "%s ", sub->name);            sub = sub->next;        }        fprintf(output, "\n");    }}/** * xmlSchemaDump: * @output:  the file output * @schema:  a schema structure * * Dump a Schema structure. */voidxmlSchemaDump(FILE * output, xmlSchemaPtr schema){    if (schema == NULL) {        fprintf(output, "Schemas: NULL\n");        return;    }    fprintf(output, "Schemas: ");    if (schema->name != NULL)        fprintf(output, "%s, ", schema->name);    else        fprintf(output, "no name, ");    if (schema->targetNamespace != NULL)        fprintf(output, "%s", (const char *) schema->targetNamespace);    else        fprintf(output, "no target namespace");    fprintf(output, "\n");    if (schema->annot != NULL)

⌨️ 快捷键说明

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