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
eFlag Tree::insertRule(Sit S, XSLElement *tmpl)
{
  double prio;
  Attribute *a = tmpl -> atts.find(XSLA_PRIORITY);
  if (!a)
    prio = defaultPriority(tmpl);
  else
    {
      if (a -> cont.toDouble(prio))
	Err(S, ET_BAD_NUMBER);
    };
  QName q; 
  GP( QName ) mode = NULL;
  
  if (!!(a = tmpl -> atts.find(XSLA_NAME)))
    E( tmpl -> setLogical(S, q, a -> cont, FALSE) );
  
  if (q.getLocal() != UNDEF_PHRASE && 
      subtrees.getCurrent() -> getStructure() -> 
      rules().findByName(*this, q))
    {
      Str fullName;
      expandQStr(q, fullName);
      
      Err1(S, ET_DUPLICATE_RULE_NAME, fullName);
    };
  
  if (!!(a = tmpl -> atts.find(XSLA_MODE)))
    E( tmpl -> setLogical(S, *(mode = new QName), 
			  a -> cont, FALSE) );
  
  subtrees.getCurrent() -> getStructure() -> 
    rules().insert(new RuleItem(tmpl,prio,q,mode.keep()));
  return OK;
}
Beispiel #3
0
//=============================================================================
// ElementType::addAttributeType
// 
// Add a new attribute to our map
//
//=============================================================================
AutoPtr<AttributeType> ElementType::addAttributeType(const QName& name, bool bExternallyDeclared)
{
	QC_DBG_ASSERT(m_attributeTypeMap.find(name.getRawName()) == m_attributeTypeMap.end());
	AutoPtr<AttributeType> pRet(new AttributeType(*this, bExternallyDeclared, name));
	m_attributeTypeMap[name.getRawName()] = pRet;
	return pRet;
}
Beispiel #4
0
SchemaAttDef::SchemaAttDef(const SchemaAttDef* other) :

    XMLAttDef(other->getValue(), other->getType(),
              other->getDefaultType(), other->getEnumeration(),
              other->getMemoryManager())
    , fElemId(XMLElementDecl::fgInvalidElemId)
    , fAttName(0)
    , fDatatypeValidator(other->fDatatypeValidator)
    , fAnyDatatypeValidator(other->fAnyDatatypeValidator)
    , fMemberTypeValidator(other->fMemberTypeValidator)
    , fNamespaceList(0)
    , fValidity(other->fValidity)
    , fValidation(other->fValidation)
    , fPSVIScope(other->fPSVIScope)
    , fBaseAttDecl(other->fBaseAttDecl)
{
    QName* otherName = other->getAttName();
    fAttName = new (getMemoryManager()) QName(otherName->getPrefix(),
                         otherName->getLocalPart(), otherName->getURI(),
                         getMemoryManager());

    if (other->fNamespaceList && other->fNamespaceList->size()) {
        fNamespaceList = new (getMemoryManager()) ValueVectorOf<unsigned int>(*(other->fNamespaceList));
    }
}
Beispiel #5
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 #6
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 #7
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 #8
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 #9
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 #10
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 #11
0
Bool Tree::cmpQNameStrings(const QName &q, const Str& uri, const Str& local)
{
    if (q.getLocal() == stdPhrase(PHRASE_STAR))
        return (Bool)(
	    q.getUri() == UNDEF_PHRASE || dict().getKey(q.getUri()) == uri);
    else
    {
        return (Bool) 
  	        (dict().getKey(q.getUri()) == uri &&
            dict().getKey(q.getLocal()) == local);		
	}
}
Beispiel #12
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 #13
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 #14
0
Bool Tree::cmpQNamesForeign(const QName &q, const HashTable& dictForeign, const QName &qForeign)
{
/*
    printf("comparing names (%s,%s,%s) and (%s,%s,%s)\n",
        (char*)(((Tree*)this)->expand(q.getPrefix())),
	    (char*)(((Tree*)this)->expand(q.getUri())),
	    (char*)(((Tree*)this)->expand(q.getLocal())),
        (char*)(dictForeign.getKey(qForeign.getPrefix())),
	    (char*)(dictForeign.getKey(qForeign.getUri())),
	    (char*)(dictForeign.getKey(qForeign.getLocal()))
	);
*/	

    if (q.getLocal() == stdPhrase(PHRASE_STAR))
    {
        return (Bool)(q.getPrefix() == UNDEF_PHRASE || 
            (dict().getKey(q.getUri()) == dictForeign.getKey(qForeign.getUri())));
	}
    else
    {
        return (Bool) 
	        (dict().getKey(q.getUri()) == dictForeign.getKey(qForeign.getUri()) &&
            dict().getKey(q.getLocal()) == dictForeign.getKey(qForeign.getLocal()));		
	}
}
Beispiel #15
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 #16
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 #17
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 #18
0
eFlag Tree::insertAttSet(Sit S, XSLElement *tmpl)
{
    QName q; 
    Attribute *a;
    GP( QName ) sets = NULL;
    if (!!(a = tmpl -> atts.find(XSLA_NAME))) 
	E( tmpl -> setLogical(S, q, a -> cont, FALSE) );
    if (q.getLocal() != UNDEF_PHRASE && 
        attSets().findByName(q))
    {
	Str fullName;
	expandQStr(q, fullName);
	Err1(S, ET_DUPLICATE_ASET_NAME, fullName);
    };    
    attSets().append(new AttSet(q));
    return OK;
}
Beispiel #19
0
bool TypeMap::isComplexType( const QName &typeName, const QName& elementName ) const
{
    if (!typeName.isEmpty()) {
        return isComplexType( typeName );
    } else {
        QList<Entry>::ConstIterator it = elementEntry( elementName );
        return it != mElementMap.constEnd() ? (*it).complexType : false;
    }
}
Beispiel #20
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 #21
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 #22
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 #23
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 #24
0
//=============================================================================
// ElementType::getAttributeType
// 
// Locate and return an AttributeType from our internal map.
//
// Returns a NULL ptr if no matching entry exists.
//
//=============================================================================
AutoPtr<AttributeType> ElementType::getAttributeType(const QName& name) const
{
	AttributeTypeMap::const_iterator iter = m_attributeTypeMap.find(name.getRawName());
	if(iter != m_attributeTypeMap.end())
	{
		return (*iter).second;
	}
	else
	{
		return 0;
	}
}
Beispiel #25
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 #26
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 );
}
Beispiel #27
0
bool operator==( QName const &q1, char const *q2 ) {
  if ( q2 ) {
    if ( *q2 == '{' ) {
      //
      // Assume "James Clark notation," i.e., "{uri}localname".
      //
      char const *const q2_ns = q2 + 1;
      if ( char const *const rbrace = ::strchr( q2_ns, '}' ) )
        if ( char const *const q1_ns = q1.ns() )
          if ( ::strncmp( q1_ns, q2_ns, rbrace - q2_ns ) == 0 )
            if ( char const *const q1_local = q1.localname() )
              return ::strcmp( q1_local, rbrace + 1 ) == 0;
    } else if ( char const *const hash = ::strchr( q2, '#' ) ) {
      //
      // XQuery 3.0, 2.3.2 Identifying and Reporting Errors:
      //
      //    An error can be represented by a URI reference that is derived from
      //    the error QName as follows: an error with namespace URI NS and
      //    local part LP can be represented as the URI reference NS#LP . For
      //    example, an error whose QName is err:XPST0017 could be represented
      //    as http://www.w3.org/2005/xqt-errors#XPST0017.
      //
      if ( char const *const q1_ns = q1.ns() )
        if ( ::strncmp( q1_ns, q2, hash - q2 ) == 0 )
          if ( char const *const q1_local = q1.localname() )
            return ::strcmp( q1_local, hash + 1 ) == 0;
    } else if ( char const *colon = ::strchr( q2, ':' ) ) {
      //
      // Assume EQName notation, i.e., URILiteral:NCName.
      //
      if ( (colon = strchr( colon + 1, ':' )) )
        if ( char const *const q1_ns = q1.ns() )
          if ( ::strncmp( q1_ns, q2, colon - q2 ) == 0 )
            if ( char const *const q1_local = q1.localname() )
              return ::strcmp( q1_local, colon + 1 ) == 0;
    }
  } else {
    //
    // q2 is NULL so q1 must be also.
    //
    return !q1.ns() && !q1.prefix() && !q1.localname();
  }
  return false;
}
Beispiel #28
0
// ---------------------------------------------------------------------------
//  XercesAttGroupInfo: Getter methods
// ---------------------------------------------------------------------------
const SchemaAttDef* XercesAttGroupInfo::getAttDef(const XMLCh* const baseName,
                                                  const int uriId) const {

    // If no list, then return a null
    if (!fAttributes)
        return 0;

    XMLSize_t attSize = fAttributes->size();

    for (XMLSize_t i=0; i<attSize; i++) {

        const SchemaAttDef* attDef = fAttributes->elementAt(i);
        QName* attName = attDef->getAttName();

        if (uriId == (int) attName->getURI() &&
			XMLString::equals(baseName, attName->getLocalPart())) {

            return attDef;
        }
    }

    return 0;
}
Beispiel #29
0
bool XercesAttGroupInfo::containsAttribute(const XMLCh* const name,
                                           const unsigned int uri) {

    if (fAttributes) {

        XMLSize_t attCount = fAttributes->size();

        if (attCount) {

            for (XMLSize_t i=0; i < attCount; i++) {

                QName* attName = fAttributes->elementAt(i)->getAttName();

                if (attName->getURI() == uri &&
                    XMLString::equals(attName->getLocalPart(),name)) {
                    return true;
                }
            }
        }
    }

    return false;
}
Beispiel #30
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 );
    }