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); } } }
void TNamespaceContentHandler::OnEndElementL(const RTagInfo& aElement, TInt aError) { TSimpleContentHandler::OnEndElementL(aElement, 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); }
/** This method is a callback to indicate the end of the element has been reached. @param aElement is a handle to the element's details. @param aErrorCode is the error code. If this is not KErrNone then special action may be required. */ void CTestHandler::OnEndElementL(const RTagInfo& aElement, TInt aErrorCode) { _LIT8(KOnEndElementFuncName,"OnEndElement()\r\n"); _LIT8(KInfoOnEndElePU,"\tElement end namespace: %S \t prefix: %S \tname: %S\r\n"); _LIT8(KInfoOnError,"Error occurs %d \r\n"); TBuf8<KShortInfoSize> info; TBuf8<KShortInfoSize> info2; TBuf8<KShortInfoSize> info3; TBuf8<KShortInfoSize> info4; iLog.Write(KOnEndElementFuncName); if (aErrorCode == KErrNone) { info2.Copy(aElement.LocalName().DesC()); info3.Copy(aElement.Uri().DesC()); info4.Copy(aElement.Prefix().DesC()); info.Format(KInfoOnEndElePU,&info3,&info4,&info2); iLog.Write(info); } else { info.Format(KInfoOnError,aErrorCode); iLog.Write(info); } }
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); }
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(">")); }
/** This method is a callback to indicate an element has been parsed. @param aElement is a handle to the element's details. @param aAttributes contains the attributes for the element. @param aErrorCode is the error code. If this is not KErrNone then special action may be required. */ void CTestHandler::OnStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, TInt aErrorCode) { _LIT8(KOnStartElementFuncName,"OnStartElement()\r\n"); _LIT8(KInfoOnStartElePU,"\tElement start namespace: %S \t prefix: %S \tname: %S\r\n"); _LIT8(KInfoOnAttributePU,"\t\tAttribute namaspace: %S \t prefix: %S \tname: %S \t value: %S\r\n"); _LIT8(KInfoOnError,"Error occurs %d \r\n"); iLog.Write(KOnStartElementFuncName); if (aErrorCode == KErrNone) { TBuf8<KShortInfoSize> info; TBuf8<KShortInfoSize> info2; TBuf8<KShortInfoSize> info3; TBuf8<KShortInfoSize> info4; TBuf8<KShortInfoSize> info5; info2.Copy(aElement.LocalName().DesC()); info3.Copy(aElement.Uri().DesC()); info4.Copy(aElement.Prefix().DesC()); info.Format(KInfoOnStartElePU,&info3,&info4,&info2); iLog.Write(info); RArray <RAttribute> array = aAttributes; TInt size = array.Count(); RAttribute attr; if ( size > 0 ) { for ( TInt i = 0; i < size; i++) { attr = array[i]; info2.Copy(attr.Attribute().LocalName().DesC()); info3.Copy(attr.Attribute().Uri().DesC()); info4.Copy(attr.Attribute().Prefix().DesC()); info5.Copy(attr.Value().DesC()); info.Format(KInfoOnAttributePU,&info3,&info4,&info2,&info5); iLog.Write(info); } } } else { TBuf8<KShortInfoSize> info; info.Format(KInfoOnError,aErrorCode); iLog.Write(info); } }
EXPORT_C void CSenSoapMessage2::ParseHeaderL( const RTagInfo& aElement, const RAttributeArray& aAttributes) { TLSLOG_L(KSenMessagesLogChannel, KMinLogLevel, "CSenSoapMessage2::ParseHeaderL"); const TPtrC8 saxLocalName = aElement.LocalName().DesC(); const TPtrC8 saxNsUri = aElement.Uri().DesC(); const TPtrC8 saxPrefix = aElement.Prefix().DesC(); TXmlEngElement element = AsElementL(); RSenDocument document = AsDocumentL(); CSenWsSecurityHeader2* pTemp = NewSecurityHeaderLC(NULL, document, element); if ((pTemp->XmlNs() == saxNsUri) && (KSecurityName() == saxLocalName)) { // Remove existing <Security> header TXmlEngElement header = HeaderL(); RXmlEngNodeList<TXmlEngElement> list; CleanupClosePushL(list); header.GetElementsByTagNameL(list, KSecurityName, pTemp->XmlNs()); while ( list.HasNext() ) { TXmlEngElement element = list.Next(); element.Remove(); } CleanupStack::PopAndDestroy(&list); if ( ipSecurityHeader ) { delete ipSecurityHeader; ipSecurityHeader = NULL; } ipSecurityHeader = pTemp; CleanupStack::Pop(); // pTemp TXmlEngElement wsSecurityHeader = ipSecurityHeader->AsElementL(); wsSecurityHeader.MoveTo(header); OnDelegateParsingL(*ipSecurityHeader); } else { TXmlEngElement rootElement = pTemp->AsElementL(); rootElement.Remove(); CleanupStack::PopAndDestroy(); // pTemp CSenSoapEnvelope2::ParseHeaderL(aElement, aAttributes); } }
EXPORT_C RAttribute RAttribute::Copy() /** Copy method. The original and copy must be closed seperately. */ { RAttribute copy; RTagInfo tagCopy = iAttribute.Copy(); copy.Open(const_cast <RString&> (tagCopy.Uri()), const_cast <RString&> (tagCopy.Prefix()), const_cast <RString&> (tagCopy.LocalName()), iValue.Copy(), iType); return copy; }
void OnEndElementL(const RTagInfo& aElement, TInt aErrorCode) { User::LeaveIfError(aErrorCode); const TDesC8& localPart8 = aElement.LocalName().DesC(); const TDesC8& prefix8 = aElement.Prefix().DesC(); iOut.Append(_L8("</")); if(prefix8.Length()) { iOut.Append(prefix8); iOut.Append(_L8(":")); } iOut.Append(localPart8); iOut.Append(_L8(">")); };
void CSenXmlReader::OnEndElementL(const RTagInfo& aElement, TInt /* aErrorCode */) { if(!iContentHandler) { SENDEBUG_L("OnEndElementL: 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); } iContentHandler->EndElement(nsUri, localName, qualifiedName); if (prefix != KNullDesC8) { CleanupStack::PopAndDestroy(); // pQName } }
void TRebuildingContentHandler::OnEndElementL(const RTagInfo& aElement, TInt aErrorCode) { User::LeaveIfError(aErrorCode); const TDesC8& localPart8 = aElement.LocalName().DesC(); const TDesC8& prefix8 = aElement.Prefix().DesC(); if ( IsForbiddenTagL ( localPart8 ) ) { return; // The end tag has been already inserted for forbidden tags } iOutFile.Write(_L8("</")); if(prefix8.Length()) { iOutFile.Write(prefix8); iOutFile.Write(_L8(":")); } iOutFile.Write(localPart8); iOutFile.Write(_L8(">")); }
// -------------------------------------------------------------------------- // CUPnPXMLParserLite::OnStartElementL // See upnpxmlparser.h // -------------------------------------------------------------------------- void CUPnPXMLParserLite::OnStartElementL( const RTagInfo& aElement, const RAttributeArray& aAttributes, TInt aErrorCode ) { __LOG1( "CUPnPXMLParserLite::OnStartElementL, error code: %d", aErrorCode ); if ( aErrorCode != KErrNone ) { return; } const TDesC8& desName = aElement.LocalName().DesC(); const TDesC8& prefix = aElement.Prefix().DesC(); // Delete content, since there may be some stuff between the elements // (comments, whitespace etc.) delete iElementValue; iElementValue = NULL; if ( !desName.CompareF( KContainer ) ) // Container element { CUpnpObjectLite* tmpContainer = CUpnpObjectLite::NewL(); CleanupStack::PushL( tmpContainer ); SetAttributesL( *tmpContainer, aAttributes ); //push into the stack, ownership is transferred iStack->PushL( tmpContainer ); CleanupStack::Pop( tmpContainer ); } else if ( !desName.CompareF( KItem ) ) // Item element { CUpnpObjectLite* tmpItem = CUpnpObjectLite::NewL(); CleanupStack::PushL( tmpItem ); SetAttributesL( *tmpItem, aAttributes ); //push into the stack, ownership is transferred iStack->PushL( tmpItem ); CleanupStack::Pop( tmpItem ); } else if( !desName.CompareF( KTitle ) ) // Title element { // check that we have item or container. cause leave if not if ( iStack->Count() == 0) { User::Leave( KErrArgument ); } // We should have an item or a container already! //__ASSERTD( iStack->Top(), __FILE__, __LINE__ ); iTitle = ETrue; } else if( !desName.CompareF( KClass ) ) // Object class element { // check that we have item or container. cause leave if not if ( iStack->Count() == 0) { User::Leave( KErrArgument ); } // We should have an item or a container already! //__ASSERTD( iStack->Top(), __FILE__, __LINE__ ); iObjectClass = ETrue; } // Ignore DIDL-Lite, desc and X_DLNADOC -elements (DLNA req) else if( desName.Compare( KDIDL ) == KErrNone || desName.Compare( KDesc ) == KErrNone || desName.Compare( KDlnaDoc ) == KErrNone ) { // Ignore } else { // check that we have item or container. cause leave if not if ( iStack->Count() == 0) { User::Leave( KErrArgument ); } // Ignore rest of the elements } __LOG( "CUPnPXMLParserLite::OnStartElementL, end" ); }
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 } }