コード例 #1
0
void TCapsContentHandler::OnStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, TInt aError)
	{
	TSimpleContentHandler::OnStartElementL(aElement, aAttributes, aError);

	// Test file should contain the following:
	//		<PREFIX:NAME xlmns:PREFIX="HTTP://UPPERCASE.COM" 
	//		xlmns:ATTPREFIX="HTTP://STILLUPPERCASE.COM" ATTPREFIX:ATTNAME="VALUE"/>

	// Expat should deliver it to us as:
	//		prefix, name, "HTTP://UPPERCASE.COM"
	//		attprefix, attname, "HTTP://STILLUPPERCASE.COM", "VALUE"

	_LIT8(KPrefix, "prefix");
	_LIT8(KName, "name");
	_LIT8(KUri, "HTTP://UPPERCASE.COM");
	_LIT8(KAttprefix, "attprefix");
	_LIT8(KAttname, "attname");
	_LIT8(KAtturi, "HTTP://STILLUPPERCASE.COM");
	_LIT8(KValue, "VALUE");

	test(aElement.Prefix().DesC() == KPrefix);
	test(aElement.LocalName().DesC() == KName);
	test(aElement.Uri().DesC() == KUri);

	test(aAttributes.Count() == 1);
	const RAttribute& attribute = aAttributes[0];
	const RTagInfo& nameInfo = attribute.Attribute();

	test(nameInfo.Prefix().DesC() == KAttprefix);
	test(nameInfo.LocalName().DesC() == KAttname);
	test(nameInfo.Uri().DesC() == KAtturi);
	test(attribute.Value().DesC() == KValue);
	}
コード例 #2
0
// --------------------------------------------------------------------------
// CUPnPXMLParserLite::SetAttributesL
// See upnpxmlparser.h
// --------------------------------------------------------------------------
void CUPnPXMLParserLite::SetAttributesL( CUpnpObjectLite& aObject, 
    const RAttributeArray& aAttributes )
    {
    __LOG( "CUPnPXMLParserLite::SetAttributesL" );
    
    if ( iStack->Count() )
        {
        // Object has a parent.
        // Should not really happen
        __LOG( "Object has a parent!" );
        __PANICD(__FILE__, __LINE__);      
        }
        
    RAttribute attribute;
    TInt count = aAttributes.Count();
    for ( TInt i = 0 ; i < count; i++ ) // Read attributes.
        {
        attribute = aAttributes[ i ];
        const TDesC8& name = attribute.Attribute().LocalName().DesC();
        
        if( !name.CompareF( KId ) )
            {
            aObject.SetObjectIdL( attribute.Value().DesC() );
            }
        }
    __LOG( "CUPnPXMLParserLite::SetAttributesL - End" );
    }
コード例 #3
0
void TNamespaceContentHandler::OnStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, TInt aError)
	{
	TSimpleContentHandler::OnStartElementL(aElement, aAttributes, aError);

	if(iState==KNothingMapped)
		test(aElement.Prefix().DesC().Length()==0 && aElement.Uri().DesC().Length()==0);
	else
		 if(aElement.Prefix().DesC().Length()==0)
			test(aElement.Uri().DesC()==iDefaultUri);
		else
			test(aElement.Prefix().DesC()==iElementPrefix && aElement.Uri().DesC()==iElementUri);

	if(aAttributes.Count())
		{
		const RTagInfo& attribute = aAttributes[0].Attribute();

		if(attribute.Prefix().DesC().Length()==0)
			test(attribute.Uri().DesC().Length()==0);
		else
			{
			test(iState!=KNothingMapped);
			test(attribute.Prefix().DesC()==iAttributePrefix && attribute.Uri().DesC()==iAttributeUri);
			}
		}
	}
コード例 #4
0
void TRebuildingContentHandler::OnStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, TInt aErrorCode)
	{
	User::LeaveIfError(aErrorCode);

	const TDesC8& localPart8 = aElement.LocalName().DesC();
	const TDesC8& prefix8 = aElement.Prefix().DesC();

	if(prefix8.Length())
		{
		iOutFile.Write(_L8("<"));
		iOutFile.Write(prefix8);
		iOutFile.Write(_L8(":"));
		iOutFile.Write(localPart8);
		}
	else
		{
		iOutFile.Write(_L8("<"));
		iOutFile.Write(localPart8);
		}	

	TInt nAttributes = aAttributes.Count();
	for(TInt i=0; i<nAttributes; i++)
		{
		const RAttribute& attribute = aAttributes[i];
		const RTagInfo& nameInfo = attribute.Attribute();

		const TDesC8& localPart8 = nameInfo.LocalName().DesC();
		const TDesC8& prefix8 = nameInfo.Prefix().DesC();
		const TDesC8& value8 = attribute.Value().DesC();

		if(prefix8.Length())
			{
			iOutFile.Write(_L8(" "));
			iOutFile.Write(prefix8);
			iOutFile.Write(_L8(":"));
			iOutFile.Write(localPart8);
			}
		else
			{
			iOutFile.Write(_L8(" "));
			iOutFile.Write(localPart8);
			}	

		iOutFile.Write(_L8("=\""));
		iOutFile.Write(value8);
		iOutFile.Write(_L8("\""));
		}
	
	if ( IsForbiddenTagL ( localPart8 ) )
		{
		iOutFile.Write(_L8(" /"));	
		}
		
	iOutFile.Write(_L8(">"));
	}
コード例 #5
0
// -----------------------------------------------------------------------------
// CUpnpServiceStateTableContentHandler::ParseAttributesL
// Parse attributes, and set correct eventable values to aResultStateVariable.
// -----------------------------------------------------------------------------
//
void CUpnpServiceStateTableContentHandler::ParseAttributesL(
    CUpnpStateVariable& aResultStateVariable,
    const RAttributeArray& aAttributes )
    {
    TBool sendEventsNotFound(ETrue);
    for ( TInt index=0; index<aAttributes.Count(); ++index )
        {
        if ( !aAttributes[index].Attribute().LocalName().DesC().Compare( KUpnpSendEvents ) )
            {
            aResultStateVariable.SetEventableL( aAttributes[index].Value().DesC() );
            sendEventsNotFound = EFalse;
            }
        }
    if ( sendEventsNotFound )
        {
        aResultStateVariable.SetEventableL( KYes );
        }
    }
コード例 #6
0
void CTFXConfigParser::OnStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, TInt aErrorCode)
    {
    if (iFileType == EConfigFileManifest)
        {
        OnMfStartElementL(aElement, aAttributes, aErrorCode);
        return;
        }
    else if (iFileType == EConfigFileSel)
        {
        OnSelStartElementL(aElement, aAttributes, aErrorCode);
        return;
        }


    if (!aElement.LocalName().DesC().CompareF(KManifestTag))
        {
        iFileType = EConfigFileManifest;
        return;
        }
    else if (!aElement.LocalName().DesC().CompareF(KSelTag))
        {
        iFileType = EConfigFileSel;

        // find if there's baseskin attribute
        // if baseskin is found then parsing is stopped and
        // baseskin is parsed and registered first
        TInt attrCount( aAttributes.Count() );
        for( TInt i( 0 ); i < attrCount; i++ )
            {
            RAttribute attribute = aAttributes[i];
            RTagInfo tag = attribute.Attribute();
            if (!tag.LocalName().DesC().CompareF(KBaseSkinTag))
                {
                // base skin can be found once per parser
                if( iBaseSkinSelFile.Length() == 0 )
                    {
                    iBaseSkinSelFile.Copy( attribute.Value().DesC() );
                    User::Leave( KBaseSkinParserLeave );
                    }
                }
            }
        return;
        }
    }
コード例 #7
0
ファイル: BLParser.cpp プロジェクト: juhanapaavola/swiiplayer
void CBLParser::OnStartElementL( const RTagInfo &aElement, const RAttributeArray &aAttributes, TInt aErrorCode )
    {
    (void)aErrorCode;
    TBuf<KMaxFileName> name;
    RAttribute attr;
    TBuf<10> num;
    TLex lex;
    TInt err(KErrNone);
    TUint32 scan(0);    
    
    name.Copy(aElement.LocalName().DesC());
    if(aAttributes.Count())
        {
        attr = aAttributes[0];
        num.Copy(attr.Value().DesC());
        lex.Assign(num);
        
        if(name == KBlacklist)
            {
            err = lex.Val(scan,EHex);
            iObserver.AddToBlacklist(scan);
            }
        }    
    }
コード例 #8
0
void CTFXConfigParser::OnSelStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, TInt /*aErrorCode*/)
    {
    if (!aElement.LocalName().DesC().CompareF(KFullSCRTransTag))
        {
        iFsTransitionArray = new (ELeave) RPointerArray<CTFxTransition>;
        iParserState = EStateParsingFs;
        return;
        }
    else if (!aElement.LocalName().DesC().CompareF(KCtrlTransTag))
        {
        iCtrlTransitionArray = new (ELeave) RPointerArray<CTFxCtrlTransition>;
        iParserState = EStateParsingCtrl;
        return;
        }
    else if(!aElement.LocalName().DesC().CompareF(KListTransTag))
        {
        iListTransitionArray = new (ELeave) RPointerArray<CTFxTransition>;
        iParserState = EStateParsingList;
        }

   else if (!aElement.LocalName().DesC().CompareF(KTransitionTag))
        {
        if (iParserState == EStateParsingFs && !iFsTransitionArray)
            {
            User::Leave(KErrCorrupt);
            }
        else if (iParserState == EStateParsingCtrl && !iCtrlTransitionArray)
            {
            User::Leave(KErrCorrupt);
            }
        else if (iParserState == EStateParsingList && !iListTransitionArray)
            {
            User::Leave(KErrCorrupt);
            }
        // list transition has same params as fs transition
        if (iParserState == EStateParsingFs
            || iParserState == EStateParsingList)
            {
            iCurrentTransition = new (ELeave) CTFxTransition;

            for (TInt count = 0; count < aAttributes.Count(); count++)
                {
                RAttribute attribute = aAttributes[count];
                RTagInfo tag = attribute.Attribute();
                if (!tag.LocalName().DesC().CompareF(KContextTag))
                    {
                    iCurrentTransition->SetContextId(attribute.Value().DesC());
                    }
                else if (!tag.LocalName().DesC().CompareF(KEffectTag))
                    {
                    iCurrentTransition->SetEffectNameL(attribute.Value().DesC());
                    }
                else if (!tag.LocalName().DesC().CompareF(KUidTag))
                    {
                    iCurrentTransition->SetUid(attribute.Value().DesC());
                    }
                else if( !tag.LocalName().DesC().CompareF(KTypeTag))
                    {
                    iCurrentTransition->SetType(attribute.Value().DesC());
                    }
                }
            }
        else if (iParserState == EStateParsingCtrl)
            {
            iCurrentCtrlTransition = new (ELeave) CTFxCtrlTransition;
            for (TInt count = 0; count < aAttributes.Count(); count++)
                {
                RAttribute attribute = aAttributes[count];
                RTagInfo tag = attribute.Attribute();
                if (!tag.LocalName().DesC().CompareF(KContextUidTag))
                    {
                    iCurrentCtrlTransition->SetContextUidL(attribute.Value().DesC());
                    }
                else if (!tag.LocalName().DesC().CompareF(KEffectTag))
                    {
                    iCurrentCtrlTransition->SetEffectNameL(attribute.Value().DesC());
                    }
                else if (!tag.LocalName().DesC().CompareF(KActionTag))
                    {
                    iCurrentCtrlTransition->SetActionL(attribute.Value().DesC());
                    }
                else if (!tag.LocalName().DesC().CompareF(KActionStringTag))
                    {
                    iCurrentCtrlTransition->SetActionStringL(attribute.Value().DesC());
                    }
                }
            }
        }
    }
コード例 #9
0
void CTFXConfigParser::OnMfStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, TInt /*aErrorCode*/)
    {
    if (!aElement.LocalName().DesC().CompareF(KEffectDefinitionsTag))
        {
        if (!iFsEffectArray)
            {
            iFsEffectArray = new (ELeave) RPointerArray<CTFxEffect>;
            }
        if (!iEffectDefPathArray)
            {
            iEffectDefPathArray = new (ELeave) RPointerArray<HBufC>;
            }
        for (TInt count = 0; count < aAttributes.Count(); count++)
            {
            RAttribute attribute = aAttributes[count];
            RTagInfo tag = attribute.Attribute();
            if (!tag.LocalName().DesC().CompareF(KPathTag))
                {
                HBufC* path;
                path = HBufC::NewL(attribute.Value().DesC().Length()*2);
                path->Des().Copy(attribute.Value().DesC());
                iEffectDefPathArray->Append(path);
                }
            else if (!tag.LocalName().DesC().CompareF(KMaxTransCacheSizeTag))
                {
                SetMaxTransCacheSizeL(attribute.Value().DesC());
                }
            else if (!tag.LocalName().DesC().CompareF(KMaxCacheSizeTag))
                {
                SetMaxCacheSizeL(attribute.Value().DesC());
                }
            }
        return;
        }
    else if (!aElement.LocalName().DesC().CompareF(KEffectTag))
        {
        if (!iFsEffectArray)
            {
            User::Leave(KErrCorrupt);
            }
        iCurrentEffect = new (ELeave) CTFxEffect;
        iCurrentEffect->SetPathIndex(iEffectDefPathArray->Count()-1);
        iCurrentEffect->SetMaxTransCacheSize(iMaxTransCacheSize);
        iCurrentEffect->SetMaxCacheSize(iMaxCacheSize);
        }

    for (TInt count = 0; count < aAttributes.Count(); count++)
        {
        RAttribute attribute = aAttributes[count];
        RTagInfo tag = attribute.Attribute();
        if (!tag.LocalName().DesC().CompareF(KEffectNameTag))
            {
            iCurrentEffect->SetName(attribute.Value().DesC());
            }
        else if (!tag.LocalName().DesC().CompareF(KEffectFileTag))
            {
            iCurrentEffect->SetFilename(attribute.Value().DesC());
            }
        else if (!tag.LocalName().DesC().CompareF(KEffectWantedTimeTag))
            {
            iCurrentEffect->SetWantedTime(attribute.Value().DesC());
            }
        else if (!tag.LocalName().DesC().CompareF(KEffectMinTimeTag))
            {
            iCurrentEffect->SetMinTime(attribute.Value().DesC());
            }
        else if (!tag.LocalName().DesC().CompareF(KEffectCachePriorityTag))
            {
            iCurrentEffect->SetCachePriority(attribute.Value().DesC());
            }
        }
    }
コード例 #10
0
void CSenXmlReader::OnStartElementL(const RTagInfo& aElement,
                             const RAttributeArray& aAttributes,
                             TInt /* aErrorCode */)
    {
    if(!iContentHandler)
        {
        SENDEBUG_L("OnStartElementL: KErrSenXmlContentHandlerNotSet");
        User::Leave(KErrSenXmlContentHandlerNotSet);
        }


    const TPtrC8 localName = aElement.LocalName().DesC();
    const TPtrC8 nsUri = aElement.Uri().DesC();
    const TPtrC8 prefix = aElement.Prefix().DesC();

    TPtrC8 qualifiedName = localName;

    if (prefix != KNullDesC8)
        {
        HBufC8* pQName = HBufC8::NewLC(prefix.Length()+localName.Length()+
                                        KSenColon().Length());
        TPtr8 qName = pQName->Des();
        qName.Append(prefix);
        qName.Append(KSenColon);
        qName.Append(localName);
        qualifiedName.Set(qName);
        }

    if(ipNsPrefixes)
        {
        // there are namespaces to declare!

        // make a new array for all attributes including namespace (to be added)
        RAttributeArray attributesAndNamespaces;

        CleanupClosePushL(attributesAndNamespaces);
        TInt nsDeclarationCount(ipNsPrefixes->Count());
        for(TInt i=0; i<nsDeclarationCount; i++)
            {
            // open and take ownership of RString - xmlnsAttrPrefix
            RAttribute nsAttribute;
            //CleanupClosePushL(nsAttribute);

            TPtrC8 nsPrefix = ipNsPrefixes->MdcaPoint(i);
            TPtrC8 nsURI =  ipNsUris->MdcaPoint(i);

            if (nsPrefix != KNullDesC8)
                {
                nsAttribute.Open(iStringPool.OpenStringL(nsURI), 
                                iStringPool.OpenStringL(KSenXmlns()),
                                iStringPool.OpenStringL(nsPrefix),
                                iStringPool.OpenStringL(nsURI) );

                }
            else
                {
                nsAttribute.Open(iStringPool.OpenStringL(nsURI),
                            iStringPool.OpenStringL(KNullDesC8()),
                            iStringPool.OpenStringL(KSenXmlns()),
                            iStringPool.OpenStringL(nsURI) );

                }   


            // append the namespace attribute (declaration)
            CleanupClosePushL(nsAttribute);
            attributesAndNamespaces.AppendL(nsAttribute);
            CleanupStack::Pop(); // nsAttribute
            }

        // the ns declarations have been done using NON-CANONIZING method
        delete ipNsPrefixes;
        ipNsPrefixes = NULL;
        delete ipNsUris;
        ipNsUris = NULL;



        // append all other ("real") attributes
        TInt count(aAttributes.Count());
        for(TInt a=0; a<count; a++)
            {
            attributesAndNamespaces.AppendL(const_cast <RAttribute&> (aAttributes[a]).Copy());
            }


        // now give the stream content forward to the interested handler object.
        // we have successfully added the namespace declaration as NON-canonized(!)
        // attribute (if conditions have been met).
        iContentHandler->StartElement(nsUri, localName, qualifiedName, attributesAndNamespaces);

        // close the copied attributes previously added into this array as copies
        count = attributesAndNamespaces.Count();
        for(TInt j=0; j<count; j++)
            {
            attributesAndNamespaces[j].Close();
            }
        // close the actual array
        CleanupStack::PopAndDestroy(); // attributesAndNamespaces.Close();
        }
    else
        {
        // give the original attributes to content handler (no new namespaces declared in attrs)
        iContentHandler->StartElement(nsUri, localName, qualifiedName, aAttributes);
        }
    

    // delete qualified element name, if one was allocated
    if (prefix != KNullDesC8)
        {
        CleanupStack::PopAndDestroy(); // pQName
        }


    }