void XMLInitializer::initializeComplexTypeInfo()
{
  // create type name
  XMLCh typeName[128];
  XMLSize_t nsLen = XMLString::stringLen(SchemaSymbols::fgURI_SCHEMAFORSCHEMA);

  XMLString::copyString(typeName, SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
  typeName[nsLen] = chComma;
  XMLString::copyString(typeName + nsLen + 1, SchemaSymbols::fgATTVAL_ANYTYPE);

  // Create and initialize 'anyType'
  ComplexTypeInfo::fAnyType = new ComplexTypeInfo();

  ContentSpecNode* term = new ContentSpecNode
    (
      new QName
      (
        XMLUni::fgZeroLenString
        , XMLUni::fgZeroLenString
        , 1
      )
      , false
    );
  term->setType(ContentSpecNode::Any_Lax);
  term->setMinOccurs(0);
  term->setMaxOccurs(SchemaSymbols::XSD_UNBOUNDED);

  ContentSpecNode* particle = new ContentSpecNode
    (
      ContentSpecNode::ModelGroupSequence
      , term
      , 0
    );

  SchemaAttDef* attWildCard = new SchemaAttDef
    (
      XMLUni::fgZeroLenString
      , XMLUni::fgZeroLenString
      , 1
      , XMLAttDef::Any_Any
      , XMLAttDef::ProcessContents_Lax
    );

  ComplexTypeInfo::fAnyType->setTypeName(typeName);
  ComplexTypeInfo::fAnyType->setBaseComplexTypeInfo(ComplexTypeInfo::fAnyType);
  ComplexTypeInfo::fAnyType->setDerivedBy(SchemaSymbols::XSD_RESTRICTION);
  ComplexTypeInfo::fAnyType->setContentType(SchemaElementDecl::Mixed_Complex);
  ComplexTypeInfo::fAnyType->setContentSpec(particle);
  ComplexTypeInfo::fAnyType->setAttWildCard(attWildCard);
}
Exemple #2
0
ComplexTypeInfo* ComplexTypeInfo::getAnyType(unsigned int emptyNSId)
{
    if (!sAnyTypeMutexRegistered)
    {
        if (!sAnyTypeMutex)
        {
            XMLMutexLock lock(XMLPlatformUtils::fgAtomicMutex);
            if (!sAnyTypeMutex)
                sAnyTypeMutex = new XMLMutex;
        }

        // Use a faux scope to synchronize while we do this
        {
            XMLMutexLock lock(sAnyTypeMutex);

            // If we got here first, then register it and set the registered flag
            if (!sAnyTypeMutexRegistered)
            {
                // create type name
                XMLCh typeName[128];
                unsigned int nsLen = XMLString::stringLen(
                                         SchemaSymbols::fgURI_SCHEMAFORSCHEMA);

                XMLString::copyString(
                    typeName, SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
                typeName[nsLen] = chComma;
                XMLString::copyString(
                    typeName + nsLen + 1, SchemaSymbols::fgATTVAL_ANYTYPE);

                // Create and initialize 'anyType'
                fAnyType = new ComplexTypeInfo();

                ContentSpecNode* term = new ContentSpecNode
                (
                    new QName
                    (
                        XMLUni::fgZeroLenString
                        , XMLUni::fgZeroLenString
                        , emptyNSId
                    )
                    , false
                );
                term->setType(ContentSpecNode::Any_Lax);
                term->setMinOccurs(0);
                term->setMaxOccurs(SchemaSymbols::XSD_UNBOUNDED);

                ContentSpecNode* particle = new ContentSpecNode
                (
                    ContentSpecNode::ModelGroupSequence
                    , term
                    , 0
                );

                SchemaAttDef* attWildCard = new SchemaAttDef
                (
                    XMLUni::fgZeroLenString
                    , XMLUni::fgZeroLenString
                    , emptyNSId
                    , XMLAttDef::Any_Any
                    , XMLAttDef::ProcessContents_Lax
                );

                fAnyType->setTypeName(typeName);
                fAnyType->setBaseComplexTypeInfo(fAnyType);
                fAnyType->setDerivedBy(SchemaSymbols::XSD_RESTRICTION);
                fAnyType->setContentType(SchemaElementDecl::Mixed_Complex);
                fAnyType->setContentSpec(particle);
                fAnyType->setAttWildCard(attWildCard);

                // register cleanup method
                anyTypeCleanup.registerCleanup(ComplexTypeInfo::reinitAnyType);
                sAnyTypeMutexRegistered = true;
            }
        }
    }

    return fAnyType;
}