/**
 * \brief Helper function for initializing the Declaration.
 *
 * \param particle The XSParticle to create the Declaration from.
 * \param xsdcontent The XSDContent to create the Declaration from.
 * \param type The Type of the Declaration.
 */
void Declaration::init(XSParticle& particle, XSDContent* xsdcontent, const Type* type)
{
     mMinOccurs = particle.getMinOccurs(); 
     mMaxOccurs = particle.getMaxOccurs(); 
     mUnbounded = particle.getMaxOccursUnbounded();
     XSElementDeclaration* dec = particle.getElementTerm();
     if (dec) {
          StrX name(dec->getName());
          mName = name.str();
          if (type) {
               mType = type;
          }
          else if (xsdcontent) {
               mType = &xsdcontent->getType(StrX(dec->getTypeDefinition()->getName()).str(),
                                            StrX(dec->getTypeDefinition()->getNamespace()).str());
          }
          else {
               Error e("Neither Type nor XSDContent in Declaration constructor.");
               throw e;
          }
     }
     else {
          Error e("No XSElementDeclaration in Declaration constructor.");
          throw e;
     }
}
Beispiel #2
0
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;
    }
}
/**
 * \brief Handles a single XSParticle.
 *
 * \param xsParticle The XSParticle to handle.
 */
void TypeDefinition::processParticle(XSParticle& xsParticle)
{
     XSParticle::TERM_TYPE termType = xsParticle.getTermType();
     if (termType == XSParticle::TERM_ELEMENT) {
          XSElementDeclaration* dec = xsParticle.getElementTerm();
          string nameSpace = StrX(mXSTypeDefinition.getNamespace()).str();
          if (getName() == StrX(dec->getTypeDefinition()->getName()     ).str() &&
              nameSpace == StrX(dec->getTypeDefinition()->getNamespace()).str()) {
               Declaration* dec = new Declaration(xsParticle, this);
               appendSubElement(*dec);
          }
          else {
               Declaration *dec = new Declaration(xsParticle, mXSDContent);
               appendSubElement(*dec);
          }
     }
     else if (termType == XSParticle::TERM_MODELGROUP) {
          processParticles(*xsParticle.getModelGroupTerm());
     }
     else if (termType == XSParticle::TERM_WILDCARD) {
          approxsimDebug("* (wildcard) NOT IMPLEMENTED");
     }
}