bool XSSimpleTypeDefinition::derivedFromType(const XSTypeDefinition * const ancestorType) { if (!ancestorType) return false; XSTypeDefinition* type; if (ancestorType->getTypeCategory() == XSTypeDefinition::COMPLEX_TYPE) { type = (XSTypeDefinition*) ancestorType; if (ancestorType == type->getBaseType()) { // ancestor is anytype return true; } return false; } type = this; XSTypeDefinition* lastType = 0; // anysimple type has a base type of anytype // anytype has a basetype of anytype so will have infinite loop... while (type && (type != ancestorType) && (type != lastType)) { lastType = type; type = type->getBaseType(); } return (type == ancestorType); }
void processElements(XSNamedMap<XSObject> *xsElements) { if (!xsElements || xsElements->getLength() == 0) { XERCES_STD_QUALIFIER cout << "no elements\n\n" << XERCES_STD_QUALIFIER endl; return; } for (XMLSize_t i=0; i < xsElements->getLength(); i++) { XSElementDeclaration *xsElement = (XSElementDeclaration *)xsElements->item(i); printBasic(xsElement, "Element"); // Content Model XSTypeDefinition *xsTypeDef = xsElement->getTypeDefinition(); XERCES_STD_QUALIFIER cout << "Content Model" << "\n"; XERCES_STD_QUALIFIER cout << "\tType:\t"; if (xsTypeDef->getTypeCategory() == XSTypeDefinition::SIMPLE_TYPE) { XERCES_STD_QUALIFIER cout << "Simple\n"; } else { XERCES_STD_QUALIFIER cout << "Complex\n"; } XERCES_STD_QUALIFIER cout << "\tName:\t" << StrX(xsTypeDef->getName()) << "\n"; XERCES_STD_QUALIFIER cout << "\n--------------------------------------------" << XERCES_STD_QUALIFIER endl; } }
void processSimpleTypeDefinition(XSSimpleTypeDefinition * xsSimpleTypeDef) { XSTypeDefinition *xsBaseTypeDef = xsSimpleTypeDef->getBaseType(); XERCES_STD_QUALIFIER cout << "Base:\t\t\t"; XERCES_STD_QUALIFIER cout << StrX(xsBaseTypeDef->getName()) << XERCES_STD_QUALIFIER endl; int facets = xsSimpleTypeDef->getDefinedFacets(); if (facets) { XERCES_STD_QUALIFIER cout << "Facets:\n"; if (facets & XSSimpleTypeDefinition::FACET_LENGTH) XERCES_STD_QUALIFIER cout << "\tLength:\t\t" << StrX(xsSimpleTypeDef->getLexicalFacetValue(XSSimpleTypeDefinition::FACET_LENGTH)) << XERCES_STD_QUALIFIER endl; if (facets & XSSimpleTypeDefinition::FACET_MINLENGTH) XERCES_STD_QUALIFIER cout << "\tMinLength:\t" << StrX(xsSimpleTypeDef->getLexicalFacetValue(XSSimpleTypeDefinition::FACET_MINLENGTH)) << XERCES_STD_QUALIFIER endl; if (facets & XSSimpleTypeDefinition::FACET_MAXLENGTH) XERCES_STD_QUALIFIER cout << "\tMaxLength:\t" << StrX(xsSimpleTypeDef->getLexicalFacetValue(XSSimpleTypeDefinition::FACET_MAXLENGTH)) << XERCES_STD_QUALIFIER endl; if (facets & XSSimpleTypeDefinition::FACET_PATTERN) { StringList *lexicalPatterns = xsSimpleTypeDef->getLexicalPattern(); if (lexicalPatterns && lexicalPatterns->size()) { XERCES_STD_QUALIFIER cout << "\tPattern:\t\t"; for (unsigned i = 0; i < lexicalPatterns->size(); i++) { XERCES_STD_QUALIFIER cout << StrX(lexicalPatterns->elementAt(i)); } XERCES_STD_QUALIFIER cout << XERCES_STD_QUALIFIER endl; } } if (facets & XSSimpleTypeDefinition::FACET_WHITESPACE) XERCES_STD_QUALIFIER cout << "\tWhitespace:\t\t" << StrX(xsSimpleTypeDef->getLexicalFacetValue(XSSimpleTypeDefinition::FACET_WHITESPACE)) << XERCES_STD_QUALIFIER endl; if (facets & XSSimpleTypeDefinition::FACET_MAXINCLUSIVE) XERCES_STD_QUALIFIER cout << "\tMaxInclusive:\t" << StrX(xsSimpleTypeDef->getLexicalFacetValue(XSSimpleTypeDefinition::FACET_MAXINCLUSIVE)) << XERCES_STD_QUALIFIER endl; if (facets & XSSimpleTypeDefinition::FACET_MAXEXCLUSIVE) XERCES_STD_QUALIFIER cout << "\tMaxExclusive:\t" << StrX(xsSimpleTypeDef->getLexicalFacetValue(XSSimpleTypeDefinition::FACET_MAXEXCLUSIVE)) << XERCES_STD_QUALIFIER endl; if (facets & XSSimpleTypeDefinition::FACET_MINEXCLUSIVE) XERCES_STD_QUALIFIER cout << "\tMinExclusive:\t" << StrX(xsSimpleTypeDef->getLexicalFacetValue(XSSimpleTypeDefinition::FACET_MINEXCLUSIVE)) << XERCES_STD_QUALIFIER endl; if (facets & XSSimpleTypeDefinition::FACET_MININCLUSIVE) XERCES_STD_QUALIFIER cout << "\tMinInclusive:\t" << StrX(xsSimpleTypeDef->getLexicalFacetValue(XSSimpleTypeDefinition::FACET_MININCLUSIVE)) << XERCES_STD_QUALIFIER endl; if (facets & XSSimpleTypeDefinition::FACET_TOTALDIGITS) XERCES_STD_QUALIFIER cout << "\tTotalDigits:\t" << StrX(xsSimpleTypeDef->getLexicalFacetValue(XSSimpleTypeDefinition::FACET_TOTALDIGITS)) << XERCES_STD_QUALIFIER endl; if (facets & XSSimpleTypeDefinition::FACET_FRACTIONDIGITS) XERCES_STD_QUALIFIER cout << "\tFractionDigits:\t" << StrX(xsSimpleTypeDef->getLexicalFacetValue(XSSimpleTypeDefinition::FACET_FRACTIONDIGITS)) << XERCES_STD_QUALIFIER endl; if (facets & XSSimpleTypeDefinition::FACET_ENUMERATION) { StringList *lexicalEnums = xsSimpleTypeDef->getLexicalEnumeration(); if (lexicalEnums && lexicalEnums->size()) { XERCES_STD_QUALIFIER cout << "\tEnumeration:\n"; for (unsigned i = 0; i < lexicalEnums->size(); i++) { XERCES_STD_QUALIFIER cout << "\t\t\t" << StrX(lexicalEnums->elementAt(i)) << "\n"; } XERCES_STD_QUALIFIER cout << XERCES_STD_QUALIFIER endl; } } } }
bool XSComplexTypeDefinition::derivedFromType(const XSTypeDefinition * const ancestorType) { if (!ancestorType) return false; XSTypeDefinition* type = this; while (type && (type != ancestorType)) { type = type->getBaseType(); } return (type == ancestorType); }
void processComplexTypeDefinition(XSComplexTypeDefinition *xsComplexTypeDef) { XSTypeDefinition *xsBaseTypeDef = xsComplexTypeDef->getBaseType(); if (xsBaseTypeDef) { XERCES_STD_QUALIFIER cout << "Base:\t\t\t"; XERCES_STD_QUALIFIER cout << StrX(xsBaseTypeDef->getName()) << "\n"; } XERCES_STD_QUALIFIER cout << "Content Model:\t"; XSComplexTypeDefinition::CONTENT_TYPE contentType = xsComplexTypeDef->getContentType(); if (contentType == XSComplexTypeDefinition::CONTENTTYPE_ELEMENT || contentType == XSComplexTypeDefinition::CONTENTTYPE_MIXED) { processParticle(xsComplexTypeDef->getParticle()); XERCES_STD_QUALIFIER cout << XERCES_STD_QUALIFIER endl; } }
bool TypeDefinition::canSubstitute(const Type& type) const { // Have to do this the hard way since the cygwin xerces 2.5 // library has a bug. The bug is that anyType is ancestor of // itself and thus causes the derivedFromType function to hang. if (type.getName() == "anyType") { return true; } else { XSTypeDefinition* td = &mXSTypeDefinition; while (!(StrX(td->getName()) == "anyType")) { if (type.getName() == StrX(td->getName()).str()) { return true; } td = td->getBaseType(); } } return false; // The following line is sufficient with a non-buggy xerces. // return mXSTypeDefinition.derivedFromType(&dynamic_cast<const TypeDefinition*>(&type)->mXSTypeDefinition); }
void processTypeDefinitions(XSNamedMap<XSObject> *xsTypeDefs) { if (!xsTypeDefs) return; for (XMLSize_t i=0; i < xsTypeDefs->getLength(); i++) { XSTypeDefinition *xsTypeDef = (XSTypeDefinition *)xsTypeDefs->item(i); printBasic(xsTypeDef, "Type Definition"); // Content Model XERCES_STD_QUALIFIER cout << "Category:\t"; if (xsTypeDef->getTypeCategory() == XSTypeDefinition::SIMPLE_TYPE) { XERCES_STD_QUALIFIER cout << "\tSimple\n"; processSimpleTypeDefinition((XSSimpleTypeDefinition *)xsTypeDef); } else { XERCES_STD_QUALIFIER cout << "\tComplex\n"; processComplexTypeDefinition((XSComplexTypeDefinition *)xsTypeDef); } XERCES_STD_QUALIFIER cout << "\n--------------------------------------------" << XERCES_STD_QUALIFIER endl; } }