zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #25383
[Merge] lp:~zorba-coders/zorba/html-module-bug-1189804 into lp:zorba/html-module
Matthias Brantner has proposed merging lp:~zorba-coders/zorba/html-module-bug-1189804 into lp:zorba/html-module.
Commit message:
adapted test to use unordered-maps module
Requested reviews:
Matthias Brantner (matthias-brantner)
For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/html-module-bug-1189804/+merge/182529
adapted test to use unordered-maps module
--
https://code.launchpad.net/~zorba-coders/zorba/html-module-bug-1189804/+merge/182529
Your team Zorba Coders is subscribed to branch lp:zorba/html-module.
=== modified file 'test/Queries/link_crawler2.xq2'
--- test/Queries/link_crawler2.xq2 2013-08-09 09:37:05 +0000
+++ test/Queries/link_crawler2.xq2 2013-08-28 01:38:25 +0000
@@ -15,7 +15,7 @@
:)
import module namespace http = "http://www.zorba-xquery.com/modules/http-client";
-import module namespace map = "http://www.zorba-xquery.com/modules/store/data-structures/unordered-map";
+import module namespace map = "http://zorba.io/modules/unordered-maps";
import module namespace html = "http://www.zorba-xquery.com/modules/converters/html";
import module namespace x = "http://zorba.io/modules/xml";
import schema namespace opt = "http://zorba.io/modules/xml-options";
@@ -32,8 +32,8 @@
-declare variable $local:processed-internal-links := xs:QName("processed-internal-links");
-declare variable $local:processed-external-links := xs:QName("processed-external-links");
+declare variable $local:processed-internal-links := "processed-internal-links";
+declare variable $local:processed-external-links := "processed-external-links";
declare variable $local:tidy-options := <options xmlns="http://www.zorba-xquery.com/modules/converters/html-options" >
<tidyParam name="output-xml" value="yes" />
<tidyParam name="doctype" value="omit" />
@@ -54,7 +54,7 @@
declare %an:sequential function local:delete-containers(){
for $x in map:available-maps()
- return map:delete($x);
+ return map:drop($x);
};
declare function local:is-internal($x as xs:string) as xs:boolean
@@ -76,9 +76,9 @@
}
catch *
{
- map:insert($local:processed-external-links, (<FROM>{$start-uri}</FROM>,
+ map:insert($local:processed-external-links, $href, (<FROM>{$start-uri}</FROM>,
<MESSAGE>malformed</MESSAGE>,
- <RESULT>broken</RESULT>), $href);
+ <RESULT>broken</RESULT>));
}
$absuri
};
@@ -129,17 +129,17 @@
{
if(count($http-result) ge 1)
then
- map:insert($map-name, (<STATUS>{fn:string($http-result[1]/@status)}</STATUS>,
+ map:insert($map-name, $url, (<STATUS>{fn:string($http-result[1]/@status)}</STATUS>,
<MESSAGE>{fn:string($http-result[1]/@message)}</MESSAGE>,
<RESULT>{if(local:alive($http-result))
then "Ok"
else if(local:is-redirect($http-result))
then "redirect"
else "broken"
- }</RESULT>), $url);
- else map:insert($map-name, <RESULT>broken</RESULT>, $url);
+ }</RESULT>));
+ else map:insert($map-name, $url, <RESULT>broken</RESULT>);
if(local:is-redirect($http-result)) then
- map:insert($map-name, <REDIRECT>{fn:string($http-result[1]/httpsch:header[@name = "Location"]/@value)}</REDIRECT>, $url);
+ map:insert($map-name, $url, <REDIRECT>{fn:string($http-result[1]/httpsch:header[@name = "Location"]/@value)}</REDIRECT>);
else {}
};
@@ -155,7 +155,7 @@
then exit returning false();
else {}
fn:trace($x, "HEAD external link");
- map:insert($local:processed-external-links, <FROM>{$baseUri}</FROM>, $x);
+ map:insert($local:processed-external-links, $x, <FROM>{$baseUri}</FROM>);
variable $http-call:=();
try{
$http-call:=http:send-request(<httpsch:request method="GET" href="{$x}"/>, (), ());
@@ -185,7 +185,7 @@
then exit returning false();
else {}
fn:trace($x, "GET internal link");
- map:insert($local:processed-internal-links, <FROM>{$baseUri}</FROM>, $x);
+ map:insert($local:processed-internal-links, $x, <FROM>{$baseUri}</FROM>);
variable $http-call:=();
try{
$http-call:=http:send-request(<httpsch:request method="GET" href="{$x}" follow-redirect="false"/>, (), ());
@@ -216,8 +216,8 @@
}
catch *
{
- map:insert($local:processed-internal-links, (<MESSAGE>{concat("cannot tidy: ", $err:description)}</MESSAGE>,
- <RESULT>broken</RESULT>), $x);
+ map:insert($local:processed-internal-links, $x, (<MESSAGE>{concat("cannot tidy: ", $err:description)}</MESSAGE>,
+ <RESULT>broken</RESULT>));
try{
$content:=x:parse($string-content,
<opt:options>
@@ -225,7 +225,7 @@
</opt:options>);
}
catch *
- { map:insert($local:processed-internal-links, <MESSAGE>{concat("cannot parse: ", $err:description)}</MESSAGE>, $x);}
+ { map:insert($local:processed-internal-links, $x, <MESSAGE>{concat("cannot parse: ", $err:description)}</MESSAGE>);}
}
variable $links :=();
if(empty($content))
@@ -240,9 +240,9 @@
declare function local:print-results() as element()*
{
- for $x in map:keys($local:processed-internal-links)/map:attribute/@value/string()
+ for $x in jn:members(map:keys($local:processed-internal-links))
return <INTERNAL><LINK>{$x}</LINK>{map:get($local:processed-internal-links,$x)}</INTERNAL>,
- for $x in map:keys($local:processed-external-links)/map:attribute/@value/string()
+ for $x in jn:members(map:keys($local:processed-external-links))
return <EXTERNAL><LINK>{$x}</LINK>{map:get($local:processed-external-links,$x)}</EXTERNAL>
};
Follow ups