Sorin Marian Nasoi has proposed merging lp:~zorba-coders/zorba/bug_872732 into lp:zorba.
Requested reviews: Markos Zaharioudakis (markos-za) For more details, see: https://code.launchpad.net/~zorba-coders/zorba/bug_872732/+merge/79272 Fixed the bug #872732 according to the: - W3C spec: http://www.w3.org/TR/xpath-functions-30/#func-namespace-uri-for-prefix - W3C decision from : http://www.w3.org/Bugs/Public/show_bug.cgi?id=11590 Marked the test test/rbkt/w3c_testsuite/XQuery/Functions/QNameFunc/NamespaceURIForPrefixFunc/K2-NamespaceURIForPrefixFunc-2 as expected failure in the: - test/rbkt/Queries/CMakeLists.txt - test/rbkt/Queries/w3c_known_failures.txt because the RQ uses XQTS_1_0_3, where the expected result for this test is wrong. -- https://code.launchpad.net/~zorba-coders/zorba/bug_872732/+merge/79272 Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/runtime/qnames/qnames_impl.cpp' --- src/runtime/qnames/qnames_impl.cpp 2011-07-19 19:35:04 +0000 +++ src/runtime/qnames/qnames_impl.cpp 2011-10-13 13:12:36 +0000 @@ -1,12 +1,12 @@ /* * Copyright 2006-2008 The FLWOR Foundation. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -52,7 +52,7 @@ PlanIteratorState* state; DEFAULT_STACK_INIT(PlanIteratorState, state, planState); - if (consumeNext(itemQName, theChild0.getp(), planState )) + if (consumeNext(itemQName, theChild0.getp(), planState )) { itemQName->getStringValue2(qname); @@ -60,7 +60,7 @@ index = qname.find(":", 0, 1); - if (index != zstring::npos) + if (index != zstring::npos) { resPre = qname.substr(0, index); resLocal = qname.substr(index+1, qname.size() - index); @@ -70,7 +70,7 @@ throw XQUERY_EXCEPTION( err::FOCA0002, ERROR_PARAMS( qname ), ERROR_LOC(loc) ); - } + } else { resLocal = qname; @@ -80,8 +80,8 @@ err::FOCA0002, ERROR_PARAMS( qname ), ERROR_LOC(loc) ); } - - if (consumeNext(itemElem, theChild1, planState )) + + if (consumeNext(itemElem, theChild1, planState )) { itemElem->getNamespaceBindings(NamespaceBindings); @@ -104,7 +104,7 @@ err::FONS0004, ERROR_PARAMS( resPre ), ERROR_LOC( loc ) ); } - + GENV_ITEMFACTORY->createQName(result, resNs, resPre, resLocal); STACK_PUSH(true, state); @@ -128,7 +128,7 @@ PlanIteratorState* state; DEFAULT_STACK_INIT(PlanIteratorState, state, planState); - if (consumeNext(itemURI, theChild0.getp(), planState )) + if (consumeNext(itemURI, theChild0.getp(), planState )) { itemURI->getStringValue2(resNs); @@ -138,12 +138,12 @@ consumeNext(itemQName, theChild1.getp(), planState ); itemQName->getStringValue2(qname); - + ascii::trim_whitespace(qname); index = qname.find(":", 0, 1); - if (index != zstring::npos) + if (index != zstring::npos) { if (resNs.empty()) throw XQUERY_EXCEPTION( @@ -152,12 +152,12 @@ resPre = qname.substr(0, index); resLocal = qname.substr(index+1, qname.size() - index); - } + } else { resLocal = qname; } - + if ((index != zstring::npos && ! GENV_GCAST.castableToNCName(resPre)) || ! GENV_GCAST.castableToNCName(resLocal)) { @@ -209,7 +209,7 @@ //11.2.2 fn:prefix-from-QName bool PrefixFromQNameIterator::nextImpl( - store::Item_t& result, + store::Item_t& result, PlanState& planState) const { store::Item_t item; @@ -232,8 +232,8 @@ //11.2.3 fn:local-name-from-QName bool LocalNameFromQNameIterator::nextImpl( - store::Item_t& result, - PlanState& planState) const + store::Item_t& result, + PlanState& planState) const { store::Item_t item; zstring localName; @@ -253,7 +253,7 @@ //11.2.4 fn:namespace-uri-from-QName bool NamespaceUriFromQNameIterator::nextImpl( store::Item_t& result, - PlanState& planState) const + PlanState& planState) const { store::Item_t item; zstring ns; @@ -277,6 +277,7 @@ { store::Item_t itemPrefix, itemElem; zstring resNs; + zstring prefix; bool found = false; store::NsBindings NamespaceBindings; store::NsBindings::const_iterator iter; @@ -284,43 +285,35 @@ PlanIteratorState* state; DEFAULT_STACK_INIT(PlanIteratorState, state, planState); -// According to W3C bug #11590 comment #9 -// http://www.w3.org/Bugs/Public/show_bug.cgi?id=11590#c9 -// namespace-uri-for-prefix('', <a/>) -// and -// namespace-uri-for-prefix((), <a/>) -// should return the empty sequence if (!consumeNext(itemPrefix, theChildren[0].getp(), planState )) { - resNs = theSctx->default_elem_type_ns(); - found = true; - } - else - { - if (!consumeNext(itemElem, theChildren[1].getp(), planState )) - { - ZORBA_ASSERT(false); - } - else - { - itemElem->getNamespaceBindings(NamespaceBindings); - - for (iter = NamespaceBindings.begin(); - iter != NamespaceBindings.end(); - ++iter) - { - zstring pre; - itemPrefix->getStringValue2(pre); - - ascii::trim_whitespace(pre); - - if ((*iter).first == pre) + prefix = ""; + } + else + { + itemPrefix->getStringValue2(prefix); + ascii::trim_whitespace(prefix); + } + + if (!consumeNext(itemElem, theChildren[1].getp(), planState )) + { + ZORBA_ASSERT(false); + } + else + { + itemElem->getNamespaceBindings(NamespaceBindings); + + for (iter = NamespaceBindings.begin(); + iter != NamespaceBindings.end(); + ++iter) + { + if (((*iter).first == prefix) && + !(*iter).second.empty()) { resNs = (*iter).second; found = true; break; } - } } } === modified file 'test/rbkt/Queries/CMakeLists.txt' --- test/rbkt/Queries/CMakeLists.txt 2011-10-10 10:31:20 +0000 +++ test/rbkt/Queries/CMakeLists.txt 2011-10-13 13:12:36 +0000 @@ -1,11 +1,11 @@ # Copyright 2006-2008 The FLWOR Foundation. -# +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,10 +18,10 @@ MESSAGE(STATUS "Adding tests for CTest") -FILE(GLOB_RECURSE TESTFILES FOLLOW_SYMLINKS +FILE(GLOB_RECURSE TESTFILES FOLLOW_SYMLINKS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*.xq") IF(ZORBA_TEST_XQUERYX) - FILE(GLOB_RECURSE TESTFILES_XQX FOLLOW_SYMLINKS + FILE(GLOB_RECURSE TESTFILES_XQX FOLLOW_SYMLINKS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS "*.xqx") IF (TESTFILES_XQX) LIST(APPEND TESTFILES ${TESTFILES_XQX}) @@ -94,7 +94,7 @@ LIST(SORT CHAINED_TESTS_FILES) SET(TEST_NAME "test/rbkt/${TEST_NAME}") - + # finally add the test ZORBA_ADD_TEST("${TEST_NAME}" testdriver ${CHAINED_TESTS_FILES}) @@ -143,7 +143,7 @@ SET(SKIP_TEST 1) ENDIF(HTTP_CLIENT) ENDIF(NOT CURL_FOUND) - + IF(NOT ZORBA_WITH_FILE_ACCESS) #these tests require the file module STRING(REGEX MATCH "file/" NEEDS_FILE "${TESTNAME}") @@ -211,6 +211,7 @@ IF (FOUND_XQTS AND NOT ZORBA_TEST_W3C_TO_SUBMIT_RESULTS) EXPECTED_FAILURE(test/rbkt/w3c_testsuite/XQuery/PathExpr/Steps/Steps-leading-lone-slash-8a 3408285) + EXPECTED_FAILURE(test/rbkt/w3c_testsuite/XQuery/Functions/QNameFunc/NamespaceURIForPrefixFunc/K2-NamespaceURIForPrefixFunc-2 872732) IF(NOT ZORBA_WITH_BIG_INTEGER) # These tests fail due to integer overflow. === modified file 'test/rbkt/Queries/w3c_known_failures.txt' --- test/rbkt/Queries/w3c_known_failures.txt 2011-09-12 23:22:24 +0000 +++ test/rbkt/Queries/w3c_known_failures.txt 2011-10-13 13:12:36 +0000 @@ -107,6 +107,7 @@ test/rbkt/w3c_testsuite/XQuery/Functions/HigherOrder/MapPairs/map-pairs-001 test/rbkt/w3c_testsuite/XQuery/Functions/HigherOrder/MapPairs/map-pairs-008 test/rbkt/w3c_testsuite/XQuery/Functions/HigherOrder/MapPairs/map-pairs-902 +test/rbkt/w3c_testsuite/XQuery/Functions/QNameFunc/NamespaceURIForPrefixFunc/K2-NamespaceURIForPrefixFunc-2 test/rbkt/w3c_testsuite/XQuery/SchemaValidation/ValidateExpression/validateexpr-28 test/rbkt/w3c_testsuite/XQuery/exprSeqTypes/PrologExpr/VariableProlog/ExternalVariablesWith/K2-ExternalVariablesWith-22 test/rbkt/w3c_testsuite/XQuery/StaticTyping/STFLWORExpr/ST-PITest-02
-- Mailing list: https://launchpad.net/~zorba-coders Post to : zorba-coders@lists.launchpad.net Unsubscribe : https://launchpad.net/~zorba-coders More help : https://help.launchpad.net/ListHelp