ComplexType Parser::parseComplexType( ParserContext *context, const QDomElement &element ) { ComplexType newType( d->mNameSpace ); newType.setName( element.attribute( QLatin1String("name") ) ); if (debugParsing()) qDebug() << "complexType:" << d->mNameSpace << newType.name(); if ( element.hasAttribute( QLatin1String("mixed") ) ) newType.setContentModel( XSDType::MIXED ); QDomElement childElement = element.firstChildElement(); AttributeGroup::List attributeGroups; Group::List groups; while ( !childElement.isNull() ) { NSManager namespaceManager( context, childElement ); const QName name( childElement.tagName() ); if ( name.localName() == QLatin1String("all") ) { all( context, childElement, newType ); } else if ( name.localName() == QLatin1String("sequence") || name.localName() == QLatin1String("choice") ) { Element::List elems; parseCompositor( context, childElement, newType.nameSpace(), &elems, &groups ); foreach ( const Element& elem, elems ) newType.addElement( elem ); } else if ( name.localName() == QLatin1String("attribute") ) {
ComplexType Parser::parseComplexType( ParserContext *context, const QDomElement &element ) { ComplexType newType( d->mNameSpace ); newType.setName( element.attribute( QLatin1String("name") ) ); if (debugParsing()) qDebug() << "complexType:" << d->mNameSpace << newType.name(); if ( element.hasAttribute( QLatin1String("mixed") ) ) newType.setContentModel( XSDType::MIXED ); QDomElement childElement = element.firstChildElement(); AttributeGroup::List attributeGroups; while ( !childElement.isNull() ) { NSManager namespaceManager( context, childElement ); const QName name( childElement.tagName() ); if ( name.localName() == QLatin1String("all") ) { all( context, childElement, newType ); } else if ( name.localName() == QLatin1String("sequence") ) { parseCompositor( context, childElement, newType ); } else if ( name.localName() == QLatin1String("choice") ) { parseCompositor( context, childElement, newType ); } else if ( name.localName() == QLatin1String("attribute") ) { newType.addAttribute( parseAttribute( context, childElement ) ); } else if ( name.localName() == QLatin1String("attributeGroup") ) { AttributeGroup g = parseAttributeGroup( context, childElement ); attributeGroups.append( g ); } else if ( name.localName() == QLatin1String("anyAttribute") ) { addAnyAttribute( context, childElement, newType ); } else if ( name.localName() == QLatin1String("complexContent") ) { parseComplexContent( context, childElement, newType ); } else if ( name.localName() == QLatin1String("simpleContent") ) { parseSimpleContent( context, childElement, newType ); } else if ( name.localName() == QLatin1String("annotation") ) { Annotation::List annotations = parseAnnotation( context, childElement ); newType.setDocumentation( annotations.documentation() ); newType.setAnnotations( annotations ); } childElement = childElement.nextSiblingElement(); } newType.setAttributeGroups( attributeGroups ); return newType; }
bool Parser::parseSchemaTag( ParserContext *context, const QDomElement &root ) { QName name(root.tagName()); if ( name.localName() != QLatin1String("schema") ) { qDebug() << "ERROR localName=" << name.localName(); return false; } // Already done by caller when coming from type.cpp, but doesn't hurt to do twice context->namespaceManager()->enterChild(root); // This method can call itself recursively, so save/restore the member attribute. QString oldNamespace = d->mNameSpace; if ( root.hasAttribute( QLatin1String("targetNamespace") ) ) d->mNameSpace = root.attribute( QLatin1String("targetNamespace") ); if (root.attribute( QLatin1String("elementFormDefault") ) == QLatin1String("qualified")) d->mDefaultQualifiedElements = true; if (root.attribute( QLatin1String("attributeFormDefault") ) == QLatin1String("qualified")) d->mDefaultQualifiedAttributes = true; // mTypesTable.setTargetNamespace( mNameSpace ); QDomElement element = root.firstChildElement(); while ( !element.isNull() ) { NSManager namespaceManager( context, element ); const QName name( element.tagName() ); if (debugParsing()) qDebug() << "Schema: parsing" << name.localName(); if ( name.localName() == QLatin1String("import") ) { parseImport( context, element ); } else if ( name.localName() == QLatin1String("element") ) { addGlobalElement( parseElement( context, element, d->mNameSpace, element ) ); } else if ( name.localName() == QLatin1String("complexType") ) { ComplexType ct = parseComplexType( context, element ); d->mComplexTypes.append( ct ); } else if ( name.localName() == QLatin1String("simpleType") ) { SimpleType st = parseSimpleType( context, element ); d->mSimpleTypes.append( st ); } else if ( name.localName() == QLatin1String("attribute") ) { addGlobalAttribute( parseAttribute( context, element, d->mNameSpace ) ); } else if ( name.localName() == QLatin1String("attributeGroup") ) { d->mAttributeGroups.append( parseAttributeGroup( context, element, d->mNameSpace ) ); } else if ( name.localName() == QLatin1String("group") ) { d->mGroups.append( parseGroup( context, element, d->mNameSpace ) ); } else if ( name.localName() == QLatin1String("annotation") ) { d->mAnnotations = parseAnnotation( context, element ); } else if ( name.localName() == QLatin1String("include") ) { parseInclude( context, element ); } else { qWarning() << "Unsupported schema element" << name.localName(); } element = element.nextSiblingElement(); } if (!resolveForwardDeclarations()) return false; d->mNameSpace = oldNamespace; return true; }