Beispiel #1
0
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") ) {
Beispiel #2
0
void RestHandler::endSubElement(const QName& qname, RecursiveHandler* parser) {
    using dom::presentOptional;

    if (strcmp(qname.localName(), kDisplayStepTag) == 0)
        _result->setDisplayStep(presentOptional(PitchHandler::stepFromString(_stringHandler.result())));
    else if (strcmp(qname.localName(), kDisplayOctaveTag) == 0)
        _result->setDisplayOctave(presentOptional(_integerHandler.result()));
}
Beispiel #3
0
void KeyHandler::endSubElement(const QName& qname, RecursiveHandler* parser) {
    if (strcmp(qname.localName(), kCancelTag) == 0)
        _result->setCancel(_integerHandler.result());
    else if (strcmp(qname.localName(), kFifthsTag) == 0)
        _result->setFifths(_integerHandler.result());
    else if (strcmp(qname.localName(), kModeTag) == 0)
        _result->setMode(modeFromString(_stringHandler.result()));
}
Beispiel #4
0
void Parser::parseCompositor( ParserContext *context,
  const QDomElement &element, ComplexType &ct )
{
  QName name = element.tagName();
  bool isChoice = name.localName() == "choice";
  bool isSequence = name.localName() == "sequence";

  Compositor compositor;
  if ( isChoice ) compositor.setType( Compositor::Choice );
  else if ( isSequence ) compositor.setType( Compositor::Sequence );

  if ( isChoice || isSequence ) {
    Element::List newElements;

    QDomElement childElement = element.firstChildElement();

    while ( !childElement.isNull() ) {
      QName csName = childElement.tagName();
      if ( csName.localName() == "element" ) {
        Element newElement;
        if ( isChoice ) {
          newElement = parseElement( context, childElement,
            ct.nameSpace(), element );
        } else {
          if ( isSequence ) {
            // occurence attributes can be either in the
            // parent (sequence) to on the current element
            if ( childElement.hasAttribute("minOccurs") ||
                 childElement.hasAttribute("maxOccurs")) {
              newElement = parseElement( context, childElement,
                ct.nameSpace(), childElement );
            } else {
              newElement = parseElement( context, childElement,
                ct.nameSpace(), element );
            }
          } else {
            newElement = parseElement( context, childElement,
              ct.nameSpace(), childElement );
          }
        }
        newElements.append( newElement );
        compositor.addChild( csName );
      } else if ( csName.localName() == "any" ) {
        addAny( context, childElement, ct );
      } else if ( isChoice ) {
        parseCompositor( context, childElement, ct );
      } else if ( isSequence ) {
        parseCompositor( context, childElement, ct );
      }

      childElement = childElement.nextSiblingElement();
    }

    foreach( Element e, newElements ) {
      e.setCompositor( compositor );
      ct.addElement( e );
    }
Beispiel #5
0
void PartHandler::endSubElement(const QName& qname, RecursiveHandler* parser) {
    if (strcmp(qname.localName(), kMeasureTag) == 0) {
        auto measure = _measureHandler.result();
        measure->setIndex(_measureIndex++);
        measure->setParent(_result.get());
        _result->addMeasure(std::move(measure));
    }
}
Beispiel #6
0
void Parser::parseCompositor( ParserContext *context,
  const QDomElement &element, ComplexType &ct )
{
  const QName name( element.tagName() );
  bool isChoice = name.localName() == QLatin1String("choice");
  bool isSequence = name.localName() == QLatin1String("sequence");

  Compositor compositor;
  if ( isChoice ) compositor.setType( Compositor::Choice );
  else if ( isSequence ) compositor.setType( Compositor::Sequence );
  compositor.setMaxOccurs( readMaxOccurs( element ) );

  if ( isChoice || isSequence ) {
    Element::List newElements;
    QDomElement childElement = element.firstChildElement();

    while ( !childElement.isNull() ) {
      NSManager namespaceManager( context, childElement );
      const QName csName( childElement.tagName() );
      if ( csName.localName() == QLatin1String("element") ) {
        Element newElement;
        if ( isChoice ) {
          newElement = parseElement( context, childElement,
            ct.nameSpace(), element );
        } else {
          newElement = parseElement( context, childElement,
            ct.nameSpace(), childElement );
        }
        newElements.append( newElement );
        compositor.addChild( csName );
      } else if ( csName.localName() == QLatin1String("any") ) {
        addAny( context, childElement, ct );
      } else if ( isChoice ) {
        parseCompositor( context, childElement, ct );
      } else if ( isSequence ) {
        parseCompositor( context, childElement, ct );
      }

      childElement = childElement.nextSiblingElement();
    }

    foreach( Element e, newElements ) {
      e.setCompositor( compositor );
      ct.addElement( e );
    }
Beispiel #7
0
void Parser::all( ParserContext *context, const QDomElement &element, ComplexType &ct )
{
  QDomElement childElement = element.firstChildElement();

  while ( !childElement.isNull() ) {
    QName name = childElement.tagName();
    if ( name.localName() == "element" ) {
      ct.addElement( parseElement( context, childElement, ct.nameSpace(),
        childElement ) );
    } else if ( name.localName() == "annotation" ) {
      Annotation::List annotations = parseAnnotation( context, childElement );
      ct.setDocumentation( annotations.documentation() );
      ct.setAnnotations( annotations );
    }

    childElement = childElement.nextSiblingElement();
  }
}
Beispiel #8
0
Annotation::List Parser::parseAnnotation( ParserContext *,
  const QDomElement &element )
{
  Annotation::List result;

  QDomElement e;
  for( e = element.firstChildElement(); !e.isNull();
       e = e.nextSiblingElement() ) {
    QName name = e.tagName();
    if ( name.localName() == "documentation" ) {
      result.append( Annotation( e ) );
    } else if ( name.localName() == "appinfo" ) {
      result.append( Annotation( e ) );
    }
  }

  return result;
}
Beispiel #9
0
Annotation::List Parser::parseAnnotation( ParserContext *context, const QDomElement &element )
{
  Annotation::List result;

  QDomElement child;
  for( child = element.firstChildElement(); !child.isNull();
       child = child.nextSiblingElement() ) {
    NSManager namespaceManager( context, child );
    const QName name( child.tagName() );
    if ( name.localName() == QLatin1String("documentation") ) {
      result.append( Annotation( child ) );
    } else if ( name.localName() == QLatin1String("appinfo") ) {
      result.append( Annotation( child ) );
    }
  }

  return result;
}
Beispiel #10
0
QList<TypeMap::Entry>::ConstIterator TypeMap::elementEntry( const QName &typeName ) const
{
  QList<Entry>::ConstIterator it;
  for ( it = mElementMap.constBegin(); it != mElementMap.constEnd(); ++it ) {
    if ( (*it).typeName == typeName.localName() && (*it).nameSpace == typeName.nameSpace() )
      break;
  }
  return it;
}
Beispiel #11
0
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;
}
Beispiel #12
0
QStringList TypeMap::forwardDeclarationsForAttribute( const QName &typeName ) const
{
  QList<Entry>::ConstIterator it;
  for ( it = mAttributeMap.constBegin(); it != mAttributeMap.constEnd(); ++it ) {
    if ( (*it).typeName == typeName.localName() && (*it).nameSpace == typeName.nameSpace() )
      return (*it).forwardDeclarations;
  }

  return QStringList();
}
Beispiel #13
0
QString TypeMap::localTypeForAttribute( const QName &typeName ) const
{
  QList<Entry>::ConstIterator it;
  for ( it = mAttributeMap.constBegin(); it != mAttributeMap.constEnd(); ++it ) {
    if ( (*it).typeName == typeName.localName() && (*it).nameSpace == typeName.nameSpace() )
      return (*it).localType;
  }

  return QString();
}
Beispiel #14
0
ComplexType Parser::parseComplexType( ParserContext *context,
                                      const QDomElement &complexTypeElement,
                                      const QString elementName )
{
  ComplexType newType( d->mNameSpace );

  newType.setName( complexTypeElement.attribute( "name" ) );

  if ( complexTypeElement.hasAttribute( "mixed" ) )
    newType.setContentModel( XSDType::MIXED );

  QDomElement childElement = complexTypeElement.firstChildElement();

  AttributeGroup::List attributeGroups;

  while ( !childElement.isNull() ) {
    QName name = childElement.tagName();
    if ( name.localName() == "all" ) {
      all( context, childElement, newType );
    } else if ( name.localName() == "sequence" ) {
      parseCompositor( context, childElement, newType );
    } else if ( name.localName() == "choice" ) {
      parseCompositor( context, childElement, newType );
    } else if ( name.localName() == "attribute" ) {
      newType.addAttribute( parseAttribute( context, childElement, elementName ) );
    } else if ( name.localName() == "attributeGroup" ) {
      AttributeGroup g = parseAttributeGroup( context, childElement );
      attributeGroups.append( g );
    } else if ( name.localName() == "anyAttribute" ) {
      addAnyAttribute( context, childElement, newType );
    } else if ( name.localName() == "complexContent" ) {
      parseComplexContent( context, childElement, newType );
    } else if ( name.localName() == "simpleContent" ) {
      parseSimpleContent( context, childElement, newType );
    } else if ( name.localName() == "annotation" ) {
      Annotation::List annotations = parseAnnotation( context, childElement );
      newType.setDocumentation( annotations.documentation() );
      newType.setAnnotations( annotations );
    }

    childElement = childElement.nextSiblingElement();
  }

  newType.setAttributeGroups( attributeGroups );

  return newType;
}
Beispiel #15
0
Binding WSDL::findBinding( const QName &bindingName ) const
{
  const Binding::List list = mDefinitions.bindings();
  Binding::List::ConstIterator it;
  for ( it = list.constBegin(); it != list.constEnd(); ++it ) {
    if ( (*it).name() == bindingName.localName() && (*it).nameSpace() == bindingName.nameSpace() ) {
      return *it;
    }
  }

  return Binding();
}
Beispiel #16
0
PortType WSDL::findPortType( const QName &portTypeName ) const
{
  const PortType::List list = mDefinitions.portTypes();
  PortType::List::ConstIterator it;
  for ( it = list.begin(); it != list.end(); ++it ) {
    if ( (*it).name() == portTypeName.localName() && (*it).nameSpace() == portTypeName.nameSpace() ) {
      return *it;
    }
  }
  qDebug( "findPortType: no match found for '%s'!", qPrintable( portTypeName.qname() ) );

  return PortType();
}
Beispiel #17
0
void BindingOperation::loadXML( AbstractBinding *binding, ParserContext *context, const QDomElement &element )
{
    mName = element.attribute( "name" );
    if ( mName.isEmpty() )
        context->messageHandler()->warning( "BindingOperation: 'name' required" );

    binding->parseOperation( context, mName, element );

    QDomElement child = element.firstChildElement();
    while ( !child.isNull() ) {
        QName tagName = child.tagName();
        if ( tagName.localName() == "input" ) {
            binding->parseOperationInput( context, mName, child );
        } else if ( tagName.localName() == "output" ) {
            binding->parseOperationOutput( context, mName, child );
        } else if ( tagName.localName() == "fault" ) {
            binding->parseOperationFault( context, mName, child );
        }

        child = child.nextSiblingElement();
    }
}
Beispiel #18
0
Message WSDL::findMessage( const QName &messageName ) const
{
  const Message::List list = mDefinitions.messages();
  Message::List::ConstIterator it;
  for ( it = list.constBegin(); it != list.constEnd(); ++it ) {
    if ( (*it).name() == messageName.localName() && (*it).nameSpace() == messageName.nameSpace() ) {
      return *it;
    }
  }
  qDebug( "findMessage: no match found for '%s'!", qPrintable( messageName.qname() ) );

  return Message();
}
Beispiel #19
0
void Service::loadXML( ParserContext *context, Binding::List *bindings, const QDomElement &element )
{
  mName = element.attribute( QLatin1String("name") );
  if ( mName.isEmpty() )
    context->messageHandler()->warning( QLatin1String("Service: 'name' required") );

  QDomElement child = element.firstChildElement();
  while ( !child.isNull() ) {
    NSManager namespaceManager( context, child );
    const QName tagName( child.tagName() );
    if ( tagName.localName() == QLatin1String("port") ) {
      Port port( nameSpace() );
      port.loadXML( context, bindings, child );
      mPorts.append( port );
    } else if ( tagName.localName() == QLatin1String("documentation")) {
      const QString text = child.text().trimmed();
      setDocumentation(text);
    } else {
      context->messageHandler()->warning( QString::fromLatin1("Service: unknown tag %1" ).arg( child.tagName() ) );
    }

    child = child.nextSiblingElement();
  }
}
Beispiel #20
0
void DirectionTypeHandler::endSubElement(const QName& qname, RecursiveHandler* parser) {
    if (strcmp(qname.localName(), kDynamicsTag) == 0)
        _result = _dynamicsHandler.result();
    else if (strcmp(qname.localName(), kWedgeTag) == 0)
        _result = _wedgeHandler.result();
    else if (strcmp(qname.localName(), kPedalTag) == 0)
        _result = _pedalHandler.result();
    else if (strcmp(qname.localName(), kWordsTag) == 0)
        _result = _wordsHandler.result();
    else if (strcmp(qname.localName(), kSegnoTag) == 0)
        _result = _segnoHandler.result();
    else if (strcmp(qname.localName(), kCodaTag) == 0)
        _result = _codaHandler.result();
    else if (strcmp(qname.localName(), kOctaveShiftTag) == 0)
        _result = _octaveShiftHandler.result();
}
Beispiel #21
0
void Definitions::loadXML( ParserContext *context, const QDomElement &element )
{
  setTargetNamespace( element.attribute( "targetNamespace" ) );
  mName = element.attribute( "name" );

  QDomNamedNodeMap attributes = element.attributes();
  for ( int i = 0; i < attributes.count(); ++i ) {
    QDomAttr attribute = attributes.item( i ).toAttr();
    if ( attribute.name().startsWith( "xmlns:" ) ) {
      QString prefix = attribute.name().mid( 6 );
      context->namespaceManager()->setPrefix( prefix, attribute.value() );
    }
  }

  QDomElement child = element.firstChildElement();
  while ( !child.isNull() ) {
    QName tagName = child.tagName();
    if ( tagName.localName() == "import" ) {
      Import import( mTargetNamespace );
      import.loadXML( context, child );
      mImports.append( import );
    } else if ( tagName.localName() == "types" ) {
      mType.loadXML( context, child );
    } else if ( tagName.localName() == "message" ) {
      Message message( mTargetNamespace );
      message.loadXML( context, child );
      mMessages.append( message );
    } else if ( tagName.localName() == "portType" ) {
      PortType portType( mTargetNamespace );
      portType.loadXML( context, child );
      mPortTypes.append( portType );
    } else if ( tagName.localName() == "binding" ) {
      Binding binding( mTargetNamespace );
      binding.loadXML( context, child );
      mBindings.append( binding );
    } else if ( tagName.localName() == "service" ) {
      mService.loadXML( context, &mBindings, child );
    } else if ( tagName.localName() == "documentation" ) {
      // ignore documentation for now
    } else {
      context->messageHandler()->warning( QString( "Definitions: unknown tag %1" ).arg( child.tagName() ) );
    }

    child = child.nextSiblingElement();
  }
}
Beispiel #22
0
// currently unused
bool Parser::parse( ParserContext *context, QXmlInputSource *source )
{
  QXmlSimpleReader reader;
  reader.setFeature( QLatin1String("http://xml.org/sax/features/namespace-prefixes"), true );

  QString errorMsg;
  int errorLine, errorCol;
  QDomDocument doc;
  if ( !doc.setContent( source, &reader, &errorMsg, &errorLine, &errorCol ) ) {
    qDebug( "%s at (%d,%d)", qPrintable( errorMsg ), errorLine, errorCol );
    return false;
  }

  QDomElement element = doc.documentElement();
  const QName name( element.tagName() );
  if ( name.localName() != QLatin1String("schema") ) {
    qDebug( "document element is '%s'", qPrintable( element.tagName() ) );
    return false;
  }

  return parseSchemaTag( context, element );
}
KODE::Code ElementArgumentSerializer::generate() const
{
  Q_ASSERT(!mLocalVarName.isEmpty());
  Q_ASSERT(!mOutputVarName.isEmpty());
  const QString varAndMethodBefore = mOutputVarName + (mAppend ? QLatin1String(".append(") : QLatin1String(" = "));
  const QString varAndMethodAfter = mAppend ? QString::fromLatin1(")") : QString();

  KODE::Code block;
  // for debugging, add this:
  //block += "// type: " + type.qname() + " element:" + elementType.qname();

  //if ( name.localName() == "..." )
  //    qDebug() << "appendElementArg:" << name << "type=" << type << "isBuiltin=" << mTypeMap.isBuiltinType(type) << "isQualified=" << isQualified;
  if ( mTypeMap.isTypeAny( mType ) ) {
    block += QLatin1String("if (!") + mLocalVarName + QLatin1String(".isNull()) {");
    block.indent();
    block += varAndMethodBefore + mLocalVarName + varAndMethodAfter + QLatin1String(";") + COMMENT;
    block.unindent();
    block += "}";
  } else {
    const QName actualType = mType.isEmpty() ? mElementType : mType;
    const QString typeArgs = namespaceString(actualType.nameSpace()) + QLatin1String(", QString::fromLatin1(\"") + actualType.localName() + QLatin1String("\")");
    const bool isComplex = mTypeMap.isComplexType( mType, mElementType );
    const bool isPolymorphic = mTypeMap.isPolymorphic( mType, mElementType );

    if ( mAppend && mOmitIfEmpty ) {
      if ( mUsePointer ) {
          block += "if (" + mLocalVarName + ") {";
      } else {
          block += "if (!" + mLocalVarName + "_nil) {";
      }
      block.indent();
    }

    if ( isComplex ) {
      const QString op = (isPolymorphic || mUsePointer) ? "->" : ".";
      block += QLatin1String("KDSoapValue ") + mValueVarName + QLatin1Char('(') + mLocalVarName + op + QLatin1String("serialize(") + mNameArg + QLatin1String("));") + COMMENT;
    } else {
      if ( mTypeMap.isBuiltinType( mType, mElementType ) ) {
        const QString qtTypeName = mTypeMap.localType( mType, mElementType );
        const QString value = mTypeMap.serializeBuiltin( mType, mElementType, mLocalVarName, qtTypeName );

        block += QLatin1String("KDSoapValue ") + mValueVarName + QLatin1String("(" )+ mNameArg + QLatin1String(", ") + value + QLatin1String(", ") + typeArgs + QLatin1String(");") + COMMENT;
      } else {
        block += QLatin1String("KDSoapValue ") + mValueVarName + QLatin1String("(") + mNameArg + QLatin1String(", ") + mLocalVarName + QLatin1String(".serialize(), ") + typeArgs + QLatin1String(");") + COMMENT;
      }
    }
    if ( !mNameNamespace.isEmpty() )
      block += mValueVarName + QLatin1String(".setNamespaceUri(") + mNameNamespace + QLatin1String(");");
    if ( mIsQualified )
      block += mValueVarName + QLatin1String(".setQualified(true);");
    if ( mNillable )
      block += mValueVarName + QLatin1String(".setNillable(true);");
    if ( mAppend && mOmitIfEmpty ) { // omit empty children (testcase: MSExchange, no <ParentFolderIds/>)
      block += "if (!" + mValueVarName + ".isNil())";
    }
    block += varAndMethodBefore + mValueVarName + varAndMethodAfter + QLatin1String(";") + COMMENT;

    if ( mAppend && mOmitIfEmpty ) {
      block.unindent();
      block += "}";
    }
  }
  return block;
}
void ElementArgumentSerializer::setDynamicElementName(const QString &codeLocalName, const QString &codeNamespace, const QName &baseName )
{
  mNameArg = codeLocalName;
  mNameNamespace = codeNamespace;
  mValueVarName = QLatin1String("_value") + upperlize(KODE::Style::makeIdentifier(baseName.localName()));
}
void ElementArgumentSerializer::setElementName( const QName &name )
{
  mNameArg = QLatin1String("QString::fromLatin1(\"") + name.localName() + QLatin1String("\")");
  mNameNamespace = namespaceString(name.nameSpace());
  mValueVarName = QLatin1String("_value") + upperlize(KODE::Style::makeIdentifier(name.localName()));
}
Beispiel #26
0
bool QName::operator == (const QName &qname) const {
    return (qname.nameSpace() == _nameSpace && qname.localName() == _localName);
}
Beispiel #27
0
XSD::Element WSDL::findElement( const QName &elementName ) const
{
  const XSD::Types types = mDefinitions.type().types();
  const XSD::Element::List elements = types.elements();
  for ( int i = 0; i < elements.count(); ++i ) {
    if ( elements[ i ].nameSpace() == elementName.nameSpace() && elements[ i ].name() == elementName.localName() )
      return elements[ i ];
  }

  return XSD::Element();
}
Beispiel #28
0
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;
}
Beispiel #29
0
bool Parser::parseSchemaTag( ParserContext *context, const QDomElement &root )
{
  QName name = root.tagName();
  if ( name.localName() != QLatin1String("schema") )
    return false;

  NSManager *parentManager = context->namespaceManager();
  NSManager namespaceManager;

  // copy namespaces from wsdl
  if ( parentManager )
    namespaceManager = *parentManager;

  context->setNamespaceManager( &namespaceManager );

  QDomNamedNodeMap attributes = root.attributes();
  for ( int i = 0; i < attributes.count(); ++i ) {
    QDomAttr attribute = attributes.item( i ).toAttr();
    if ( attribute.name().startsWith( QLatin1String("xmlns:") ) ) {
      QString prefix = attribute.name().mid( 6 );
      context->namespaceManager()->setPrefix( prefix, attribute.value() );
    }
  }

  if ( root.hasAttribute( QLatin1String("targetNamespace") ) )
    d->mNameSpace = root.attribute( QLatin1String("targetNamespace") );

 // mTypesTable.setTargetNamespace( mNameSpace );

  QDomElement element = root.firstChildElement();
  while ( !element.isNull() ) {
    QName name = element.tagName();
    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 ) );
    } else if ( name.localName() == QLatin1String("attributeGroup") ) {
      d->mAttributeGroups.append( parseAttributeGroup( context, element ) );
    } else if ( name.localName() == QLatin1String("annotation") ) {
      d->mAnnotations = parseAnnotation( context, element );
    } else if ( name.localName() == QLatin1String("include") ) {
      parseInclude( context, element );
    }

    element = element.nextSiblingElement();
  }

  context->setNamespaceManager( parentManager );
  d->mNamespaces = joinNamespaces( d->mNamespaces, namespaceManager.uris() );
  d->mNamespaces = joinNamespaces( d->mNamespaces, QStringList( d->mNameSpace ) );

  resolveForwardDeclarations();

  return true;
}