/**
 * \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;
     }
}
예제 #2
0
파일: SCMPrint.cpp 프로젝트: QEver/vosproj
void processParticle(XSParticle *xsParticle)
{
    if (!xsParticle) {
        XERCES_STD_QUALIFIER cout << "xsParticle is NULL"; 
        return;
    }
    XSParticle::TERM_TYPE termType = xsParticle->getTermType();
    if (termType == XSParticle::TERM_ELEMENT) {
        XSElementDeclaration *xsElement = xsParticle->getElementTerm();
        XERCES_STD_QUALIFIER cout << StrX(xsElement->getName());
    } else if (termType == XSParticle::TERM_MODELGROUP) {
        XERCES_STD_QUALIFIER cout << "(";
        
        XSModelGroup *xsModelGroup = xsParticle->getModelGroupTerm();
        XSModelGroup::COMPOSITOR_TYPE compositorType = xsModelGroup->getCompositor();
        XSParticleList *xsParticleList = xsModelGroup->getParticles();
        for (unsigned i = 0; i < xsParticleList->size()-1; i++) {
            processParticle(xsParticleList->elementAt(i));
            printCompositorTypeConnector(compositorType);
        }
        processParticle(xsParticleList->elementAt(xsParticleList->size()-1));
        
        XERCES_STD_QUALIFIER cout << ")";
    } else if (termType == XSParticle::TERM_WILDCARD) {
        XERCES_STD_QUALIFIER cout << "* (wildcard)";
    }
}