Diogo Simões has proposed merging lp:~diogo-simoes89/zorba/DC-documentation into lp:zorba/data-cleaning-module.
Requested reviews: Zorba Coders (zorba-coders) For more details, see: https://code.launchpad.net/~diogo-simoes89/zorba/DC-documentation/+merge/103586 Addition of return types in functions signatures: Applied in conversion and consolidation modules. -- https://code.launchpad.net/~diogo-simoes89/zorba/DC-documentation/+merge/103586 Your team Zorba Coders is requested to review the proposed merge of lp:~diogo-simoes89/zorba/DC-documentation into lp:zorba/data-cleaning-module.
=== modified file 'src/com/zorba-xquery/www/modules/data-cleaning/consolidation.xq' --- src/com/zorba-xquery/www/modules/data-cleaning/consolidation.xq 2011-08-01 11:26:53 +0000 +++ src/com/zorba-xquery/www/modules/data-cleaning/consolidation.xq 2012-04-25 23:42:19 +0000 @@ -50,7 +50,7 @@ : @return The most frequent node in the input sequence. : @example test/Queries/data-cleaning/consolidation/most-frequent.xq :) -declare function con:most-frequent ( $s ) { +declare function con:most-frequent ( $s ) as xs:anyAtomicType{ (for $str in set:distinct($s) order by count($s[deep-equal(.,$str)]) descending return $str)[1] }; @@ -67,7 +67,7 @@ : @return The least frequent node in the input sequence. : @example test/Queries/data-cleaning/consolidation/leastfrequent_1.xq :) -declare function con:least-frequent ( $s ) { +declare function con:least-frequent ( $s ) as xs:anyAtomicType{ let $aux := for $str in set:distinct($s) order by count($s[deep-equal(.,$str)]) return $str return if (count($aux) = 0) then () else ($aux[1]) }; @@ -242,7 +242,7 @@ : @return The node having the largest number of descending elements in the input sequence. : @example test/Queries/data-cleaning/consolidation/most-elements.xq :) -declare function con:most-elements ( $s ) { +declare function con:most-elements ( $s ) as element()*{ (for $str in set:distinct($s) order by count($str/descendant-or-self::element()) descending return $str)[1] }; @@ -260,7 +260,7 @@ : @return The node having the largest number of descending attributes in the input sequence. : @example test/Queries/data-cleaning/consolidation/most-attributes.xq :) -declare function con:most-attributes ( $s ) { +declare function con:most-attributes ( $s ) as element()*{ (for $str in set:distinct($s) order by count($str/descendant-or-self::*/attribute()) descending return $str)[1] }; @@ -278,7 +278,7 @@ : @return The node having the largest number of descending nodes in the input sequence. : @example test/Queries/data-cleaning/consolidation/most-nodes.xq :) -declare function con:most-nodes ( $s ) { +declare function con:most-nodes ( $s ) as element(){ (for $str in set:distinct($s) order by count($str/descendant-or-self::node()) descending return $str)[1] }; @@ -296,7 +296,7 @@ : @return The node having the smallest number of descending elements in the input sequence. : @example test/Queries/data-cleaning/consolidation/least-elements.xq :) -declare function con:least-elements ( $s ) { +declare function con:least-elements ( $s ) as element()*{ (for $str in set:distinct($s) order by count($str/descendant-or-self::element()) return $str)[1] }; @@ -314,7 +314,7 @@ : @return The node having the smallest number of descending attributes in the input sequence. : @example test/Queries/data-cleaning/consolidation/least-attributes.xq :) -declare function con:least-attributes ( $s ) { +declare function con:least-attributes ( $s ) as element()*{ (for $str in set:distinct($s) order by count($str/descendant-or-self::*/attribute()) return $str)[1] }; @@ -332,7 +332,7 @@ : @return The node having the smallest number of descending nodes in the input sequence. : @example test/Queries/data-cleaning/consolidation/least-nodes.xq :) -declare function con:least-nodes ( $s ) { +declare function con:least-nodes ( $s ) as element()*{ (for $str in set:distinct($s) order by count($str/descendant-or-self::node()) return $str)[1] }; @@ -350,7 +350,7 @@ : @return The node having the largest number of distinct descending elements in the input sequence. : @example test/Queries/data-cleaning/consolidation/most-distinct-elements.xq :) -declare function con:most-distinct-elements ( $s ) { +declare function con:most-distinct-elements ( $s ) as element()*{ (for $str in set:distinct($s) order by count(set:distinct($str/descendant-or-self::element())) descending return $str)[1] }; @@ -368,7 +368,7 @@ : @return The node having the largest number of distinct descending attributes in the input sequence. : @example test/Queries/data-cleaning/consolidation/most-distinct-attributes.xq :) -declare function con:most-distinct-attributes ( $s ) { +declare function con:most-distinct-attributes ( $s ) as element()*{ (for $str in set:distinct($s) order by count(set:distinct($str/descendant-or-self::*/attribute())) descending return $str)[1] }; @@ -386,7 +386,7 @@ : @return The node having the largest number of distinct descending nodes in the input sequence. : @example test/Queries/data-cleaning/consolidation/most-distinct-nodes.xq :) -declare function con:most-distinct-nodes ( $s ) { +declare function con:most-distinct-nodes ( $s ) as element()*{ (for $str in set:distinct($s) order by count(set:distinct($str/descendant-or-self::node())) descending return $str)[1] }; @@ -404,7 +404,7 @@ : @return The node having the smallest number of distinct descending elements in the input sequence. : @example test/Queries/data-cleaning/consolidation/least-distinct-elements.xq :) -declare function con:least-distinct-elements ( $s ) { +declare function con:least-distinct-elements ( $s ) as element()*{ (for $str in set:distinct($s) order by count(set:distinct($str/descendant-or-self::element())) return $str)[1] }; @@ -422,7 +422,7 @@ : @return The node having the smallest number of distinct descending attributes in the input sequence. : @example test/Queries/data-cleaning/consolidation/least-distinct-attributes.xq :) -declare function con:least-distinct-attributes ( $s ) { +declare function con:least-distinct-attributes ( $s ) as element()*{ (for $str in set:distinct($s) order by count(set:distinct($str/descendant-or-self::*/attribute())) return $str)[1] }; @@ -440,7 +440,7 @@ : @return The node having the smallest number of distinct descending nodes in the input sequence. : @example test/Queries/data-cleaning/consolidation/least-distinct-nodes.xq :) -declare function con:least-distinct-nodes ( $s ) { +declare function con:least-distinct-nodes ( $s ) as element()*{ (for $str in set:distinct($s) order by count(set:distinct($str/descendant-or-self::node())) return $str)[1] }; @@ -457,7 +457,7 @@ : @param $paths A sequence of strings denoting XPath expressions. : @return The elements that, when matched to the given set of XPath expressions, always return a non-empty set of nodes. :) -declare function con:all-xpaths ( $s as element()* , $paths as xs:string* ) { +declare function con:all-xpaths ( $s as element()* , $paths as xs:string* ) as xs:anyAtomicType*{ (: for $str in set:distinct($s) where every $path in $paths satisfies count( @@ -484,7 +484,7 @@ : @return The elements that, when matched to the given set of XPath expressions, return a non-empty set of nodes : for at least one of the cases. :) -declare function con:some-xpaths ( $s as element()* , $paths as xs:string* ) { +declare function con:some-xpaths ( $s as element()* , $paths as xs:string* ) as xs:anyAtomicType*{ (: for $str in set:distinct($s) where some $path in $paths satisfies count( @@ -512,7 +512,7 @@ : @return The element that matches the largest number of XPath expressions producing a non-empty set of nodes. :) -declare function con:most-xpaths ( $s as element()* , $paths as xs:string* ) { +declare function con:most-xpaths ( $s as element()* , $paths as xs:string* ) as xs:anyAtomicType*{ (: ( for $str in set:distinct($s) @@ -543,7 +543,7 @@ : @return The element that matches the smallest number of XPath expressions producing a non-empty set of nodes. :) -declare function con:least-xpaths ( $s as element()* , $paths as xs:string* ) { +declare function con:least-xpaths ( $s as element()* , $paths as xs:string* ) as xs:anyAtomicType*{ (: ( for $str in set:distinct($s) @@ -574,6 +574,6 @@ : <br/><br/><b> Attention : This function is still not implemented. </b> <br/> : :) -declare function con:validating-schema ( $s as element()*, $schema as element() ) { +declare function con:validating-schema ( $s as element()*, $schema as element() ) as xs:anyAtomicType*{ false() }; === modified file 'src/com/zorba-xquery/www/modules/data-cleaning/conversion.xq' --- src/com/zorba-xquery/www/modules/data-cleaning/conversion.xq 2012-04-11 09:50:34 +0000 +++ src/com/zorba-xquery/www/modules/data-cleaning/conversion.xq 2012-04-25 23:42:19 +0000 @@ -191,7 +191,7 @@ : @return The value resulting from the conversion : @example test/Queries/data-cleaning/conversion/unit-convert.xq :) -declare %an:nondeterministic function conversion:unit-convert ( $v as xs:double, $t as xs:string, $m1 as xs:string, $m2 as xs:string ) { +declare %an:nondeterministic function conversion:unit-convert ( $v as xs:double, $t as xs:string, $m1 as xs:string, $m2 as xs:string ) as xs:double { if ( $m1 = $m2 ) then $v else let $conversion-table := @@ -351,7 +351,7 @@ : @see http://www.ecb.int/stats/exchange/eurofxref/html/index.en.html : @example test/Queries/data-cleaning/conversion/currency-convert.xq :) -declare %an:nondeterministic function conversion:currency-convert ( $v as xs:double, $m1 as xs:string, $m2 as xs:string, $date as xs:string ) { +declare %an:nondeterministic function conversion:currency-convert ( $v as xs:double, $m1 as xs:string, $m2 as xs:string, $date as xs:string ) as xs:double{ let $daily := "http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml" let $hist := "http://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist.xml" let $doc := if (string-length($date) = 0) then http:get-node($daily)[2] else @@ -374,7 +374,7 @@ : <br/><br/><b> Attention : This function is still not implemented. </b> <br/> : :) -declare function conversion:phone-from-domain ( $domain as xs:string ) { +declare function conversion:phone-from-domain ( $domain as xs:string ) as xs:string*{ () }; @@ -388,7 +388,7 @@ : <br/><br/><b> Attention : This function is still not implemented. </b> <br/> : :) -declare function conversion:address-from-domain ( $domain as xs:string ) { +declare function conversion:address-from-domain ( $domain as xs:string ) as xs:string*{ () }; @@ -402,6 +402,6 @@ : <br/><br/><b> Attention : This function is still not implemented. </b> <br/> : :) -declare function conversion:name-from-domain ( $domain as xs:string ) { +declare function conversion:name-from-domain ( $domain as xs:string ) as xs:string*{ () };
-- 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