// --------------------------------------------------------------------------
// CUPnPXMLParserLite::ParseResultDataL
// See upnpxmlparser.h
// --------------------------------------------------------------------------
EXPORT_C void CUPnPXMLParserLite::ParseResultDataL(
    RPointerArray<CUpnpObjectLite>& aResultArray, const TDesC8& aData,
    const TDesC& aFormatString )
    {
    __LOG( "CUPnPXMLParserLite::ParseResultDataL, begin" );
    
    delete iFormatString; iFormatString = NULL;
    if( aFormatString != KNullDesC )
        {
        iFormatString = aFormatString.AllocL();
        }
    
    if ( !aData.Length() )
        {
        User::Leave( KErrArgument );
        }
        
    iResultRoot = &aResultArray;

    // Create parser 
    CMatchData* matchData = CMatchData::NewLC();
    matchData->SetMimeTypeL( KXmlMimeType ); 
    matchData->SetVariantL( KLIB2XML ); 
    CParser* parser = CParser::NewLC( *matchData, *this ); 
    parser->EnableFeature( Xml::EReportNamespaceMapping );
    
    Xml::ParseL( *parser, aData );    
    
    CleanupStack::PopAndDestroy( parser );
    CleanupStack::PopAndDestroy( matchData );
    
    iResultRoot = NULL;           
    __LOG( "CUPnPXMLParserLite::ParseResultDataL, end" );
    }
Пример #2
0
/**
@SYMTestCaseID 		 		SYSLIB-XML-CT-3740
@SYMTestCaseDesc		    Reporting namespace uri's and prefixes.
@SYMTestPriority 		    Medium
@SYMTestActions  		    Checks that namespace uri's and prefixes are correctly reported.
@SYMTestExpectedResults 	content handler has no errors.
@SYMPREQ 		 		 	PREQ230
*/
LOCAL_C void NamespaceTestL()
	{
	_LIT8(KDefaultUri, "http://www.symbian.com");
	_LIT8(KElementPrefix, "elprefix");
	_LIT8(KElementUri, "http://element.uri");
	_LIT8(KAttributePrefix, "attprefix");
	_LIT8(KAttributeUri, "http://attribute.uri");

	TNamespaceContentHandler contentHandler(KDefaultUri, KElementPrefix, KElementUri, KAttributePrefix, KAttributeUri);

	CParser* parser = CParser::NewLC(KParserDataType, contentHandler);

	RFs fs;
	User::LeaveIfError(fs.Connect());
	CleanupClosePushL(fs);

	User::LeaveIfError(parser->EnableFeature(EReportNamespaceMapping));

	ParseL(*parser, fs, KNamespaceTestFile());
	User::LeaveIfError(contentHandler.iError); // For OOM testing

	test(contentHandler.iError==KErrNone);

	CleanupStack::PopAndDestroy(2);
	}
Пример #3
0
/**
@SYMTestCaseID 		 		SYSLIB-XML-CT-3748
@SYMTestCaseDesc		    Processing namespaces.
@SYMTestPriority 		    Medium
@SYMTestActions  		    Creating an xml parser and enabling namespace mapping reporting, before parsing a document.
@SYMTestExpectedResults 	The document is parsed with the namespace mapping reporting enabled.
@SYMDEF 		 		 	INC059062
*/
LOCAL_C void INC059062L()
	{
	RDefectTests handler;
	CleanupClosePushL (handler);

	CParser* parser = CParser::NewLC(KXmlParserDataType, handler);

	User::LeaveIfError(parser->EnableFeature(EReportNamespaceMapping));

	RFile handle;
	handle.Open(TheFs, KNsAndBindingFile, EFileShareReadersOnly);
	CleanupClosePushL (handle);

	ParseL(*parser, handle);

	CleanupStack::PopAndDestroy (&handle);
	CleanupStack::PopAndDestroy (parser);
	CleanupStack::PopAndDestroy (&handler);
	}
Пример #4
0
/**
@SYMTestCaseID 			 	SYSLIB-XML-CT-3742
@SYMTestCaseDesc		    Testing the Features functions of CParser, to make sure they work correctly.
@SYMTestPriority 		    Medium
@SYMTestActions  		    Create the parser object and enable and disable features, testing if they are allowed or not.
@SYMTestExpectedResults 	Enabling and Disabling features return the expected result.
@SYMCR			 		 	CR0000
*/
LOCAL_C void ParserFeatureTestL()
	{
	RFs fs;
	User::LeaveIfError(fs.Connect());
	CleanupClosePushL(fs);

	TCapsContentHandler contentHandler;

	CParser* parser = CParser::NewLC(KParserDataType, contentHandler);

	// Use a non-existing feature
	test(parser->EnableFeature(0xFFFFFFFF) == KErrNotSupported);
	test(parser->DisableFeature(0xFFFFFFFF) == KErrNotSupported);

	// Enable defined but unsupported features
	test(parser->EnableFeature(EErrorOnUnrecognisedTags) == KErrNotSupported);
	test(parser->EnableFeature(EReportUnrecognisedTags) == KErrNotSupported);
	test(parser->EnableFeature(ESendFullContentInOneChunk) == KErrNotSupported);
	test(parser->EnableFeature(ERawContent) == KErrNotSupported);

	// Enable supported features
	test(parser->EnableFeature(EReportNamespaces) == KErrNone);
	test(parser->EnableFeature(EReportNamespacePrefixes) == KErrNone);
	test(parser->EnableFeature(EReportNamespaceMapping) == KErrNone);
	test(parser->EnableFeature(EConvertTagsToLowerCase) == KErrNone);

	// Disable mandatory features
	test(parser->DisableFeature(EReportNamespacePrefixes)==KErrNotSupported);
	test(parser->DisableFeature(EReportNamespaces)==KErrNotSupported);

	// Disable optional features
	test(parser->DisableFeature(EReportNamespaceMapping) == KErrNone);
	test(parser->DisableFeature(EConvertTagsToLowerCase) == KErrNone);

	// Re-enable optional features needed for test
	test(parser->EnableFeature(EConvertTagsToLowerCase | EReportNamespaceMapping)
		== KErrNone);

	ParseL(*parser, fs, KCapsTestFile());

	test(contentHandler.iNumElements == 1);
	test(contentHandler.iNumPrefixMappings == 2);
	test(contentHandler.iNumPrefixUnmappings == 2);
	test(contentHandler.iError == KErrNone);

	TSimpleContentHandler contentHandler2;

	CParser* parser2 = CParser::NewLC(KParserDataType, contentHandler2);

	parser2->EnableFeature(EReportNamespaceMapping);

	ParseL(*parser2, fs, KNamespaceTestFile());

	test(contentHandler2.iNumElements == 5);
	test(contentHandler2.iNumPrefixMappings == 3);
	test(contentHandler2.iNumPrefixUnmappings == 3);
	test(contentHandler2.iError == KErrNone);

	User::LeaveIfError(parser2->DisableFeature(EReportNamespaceMapping));
	test(!parser2->IsFeatureEnabled(EReportNamespaceMapping));

	ParseL(*parser2, fs, KNamespaceTestFile());

	test(contentHandler2.iNumElements == 5);
	test(contentHandler2.iNumPrefixMappings == 0);
	test(contentHandler2.iNumPrefixUnmappings == 0);
	test(contentHandler2.iError == KErrNone);

	CleanupStack::PopAndDestroy(3);
	}