sir i m working on xquery for finding assocation rule using xquery i complete the conding for how i write xquery for that. but now i found a problem that they give me error that "Unexpected token "declare function" beyond end of query" i send me coding part for u plz help me out for how i do.........i m using oxygen xml developer for running the xquery my simple query running proper but we use more than one function in recursive manner they create problem give error Unexpected token "declare function" beyond end of query.
(: You can activate the content completion by pressing the Ctrl+Space keys. :)
xquery version "1.0";
(: Namespace for the <oXygen/> custom functions and variables :)
declare namespace oxy="http://www.oxygenxml.com/xquery/functions";
declare namespace global="http://www.oxygenxml.com/xquery/functions";
(: The URI of the document that is to be queried :)
declare variable $oxy:document-uri as xs:string := "transaction.xml";
declare variable $oxy:document-to-query as xs:string := "transaction.xml";
declare variable $local:document-to-query as xs:string := "transaction.xml";
declare variable $oxy:document as document-node() := doc($oxy:document-uri);
(:declare function Fp-growth($l,$L,$minsup,$total,$src) as xs:(element,element,minsup,total,src) := "transaction.xml";:)
let $src := doc("transaction.xml")//items
let $minsup:=2
let $total:=count($src)*1.00
let $c:=distinct-values($src/*)
let $l:=(for $itemset in $c
let $items:=(for $item in $src/*
where $itemset=$item
return $item)
let $sup:=(count($items)+1)
where $sup>=$minsup
return <largeItemset>
<items> {$items} </items>
<support> {$sup} </support>
</largeItemset>)
let $L:=$l
return <largeItemsets>{oxyl:FP-growth($l,$L,$minsup,$total,$src)}
</largeItemsets>
_/////that part is fine but we we use next fp-growth function they give same error
plz sir help me for solving this////
declare function oxy:FP-growth(element $l, element $L, element $minsup, element $total, element $src)
returns element {
let $f-item:= first item in $L
let $l-item:= last item in $L
let $T:=oxy:getl-itemsets($src, $total, $minsup)
return <items>
{oxy:join ($l-item, $T)}
</items>
let $l:=$l-items
let $L:=oxy:remove($l)
for f-item in $L
where $f-item != $l-item
return oxy:FP-growth($l, $L, $minsup, $total, $src)
}
declare function oxy:getl-itemsets(element $src, element $total, element $minsup)
returns element {
let $l:=(for $itemset in $src
where $itemset=$l-item
return $itemset)
let $sup:=(count($l)+1
where $sup>=$minsup
return <largeItemset>
<items> {$item} </items>
<support> {$sup} </support>
</largeItemset>
}
declare function oxy:join(element $X, element $Y) returns element {
let $items := (for $item in $Y
where every $i in $X satisfies
$i != $item
return $item)
return $X union $items
}
declare function oxy:removeDuplicate(element $C) returns element
{
for $itemset1 in $C
let $items1 := $itemset1/*
let $items :=(for $itemset2 in $C
let $items2 := $itemset2/*
where $itemset2>>$itemset1 and
count($items1) =
count(commonIts($items1, $items2))
return $items2)
where count($items) = 0
return $itemset1
}
input file for this xquery is:=
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="personal-schema.css"?>
<transactions>
<transaction id="1">
<items>
<title>The Green Mile</title>
<author>Stephen King</author>
<item>a</item>
<item>d</item>
<item>e</item>
</items>
</transaction>
<transaction id="2">
<items>
<title>The Green Mile</title>
<author>J. D. Salinger</author>
<item>b</item>
<item>c</item>
<item>d</item>
</items>
</transaction>
<transaction id="3">
<items>
<title>The Green Mile</title>
<author>Issac Asimov</author>
<item>a</item>
<item>c</item>
<item>e</item>
</items>
</transaction>
<transaction id="4">
<items>
<title>The Green Mile</title>
<author>Isaac Asimov</author>
<item>b</item>
<item>c</item>
<item>d</item>
</items>
</transaction>
<transaction id="5">
<items>
<title>The Green Mile</title>
<author>Oscar Wilde</author>
<item>a</item>
<item>b</item>
</items>
</transaction>
</transactions>