11 Replies Latest reply: Mar 20, 2012 1:53 AM by tsuji RSS

    finding association rule (creating problem)

    923415
      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);


      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>

      Edited by: 920412 on Mar 12, 2012 11:26 PM

      Edited by: 920412 on Mar 14, 2012 10:57 PM

      Edited by: 920412 on Mar 14, 2012 11:17 PM
        • 1. Re: finding association rule (creating problem)
          odie_63
          Hi,

          So you wrote all this without knowing that functions must be declared in the XQuery prolog, just like variables?
          xquery version "1.0";
          
          (: Namespace for the <oXygen/> custom functions and variables &#x3a;)
          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 &#x3a;)
          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 oxy:FP-growth( ...
          ... and you'll need a semicolon to end a function declaration.
          • 2. Re: finding association rule (creating problem)
            tsuji
            ... and the syntax for declaring function itself.
            http://www.w3.org/TR/xquery/#FunctionDeclns
            • 3. Re: finding association rule (creating problem)
              923415
              sir plz help me what i do give me suggestion plz help me sir for short out this problem
              sir i m not declare the fucntion,, i m declare the variable only.

              sir the first half is correct where i mention that working fine give no error but when u use fp-gowth funtion after the query it will give error that "unexpected tocken declare frunction at tahe end of the query" how we solve that problem
              plz sir help me
              warm regards
              sir plz give mee suggestion we we using fucntion at the end od the query it create problem give unexpected token at the end of the query that i menion in the query plz help me sir how i do

              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>


              xquery version "1.0";
              declare namespace local = "http://www.w3.org/2003/11/xpath-local-functions";

              for $src in doc("transaction.xml")//items
              let $minsup := 0.4
              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>{local:FP-growth($l,$L,$minsup,$total,$src)}
              </largeItemsets>



              declare function local:FP-growth($l as element()*, $L as element()*, $minsup as xs:decimal, $total as xs:decimal, $src as element()) as element()*
              {
              let $f-item := first item in $L
              let $l-item := last item in $L
              let $T := local:getl-itemsets($src, $total, $minsup)
              return <items>
              {local:join ($l-item, $T)}
              </items>
              let $l:=$l-items
              let $L:=local:remove($l)
              for f-item in $L
              where $f-item != $l-item
              return
              local:FP-growth($l, $L, $minsup, $total, $src)
              };

              declare function oxy:getl-itemsets( $src as element(), $total as xs:decimal , $minsup as xs:decimal))
              as 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 local:join($X as element(), $Y as element()) as element() {
              let $items := (for $item in $Y
              where every $i in $X satisfies
              $i != $item
              return $item)
              return $X union $items
              }

              declare function local:removeDuplicate($C as element()*) as 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
              }



              sir it give error "Error: syntax error, unexpected xquery, expecting <end of file> [err:XPST0003], <query>:1:43"

              plz help me sir for sort out this
              warm regards

              Edited by: 920412 on Mar 15, 2012 2:42 AM

              Edited by: 920412 on Mar 14, 2012 10:58 PM

              Edited by: 920412 on Mar 15, 2012 10:47 AM
              • 4. Re: finding association rule (creating problem)
                tsuji
                The functions look better. But odie_63 had also shown you where to put all the function declarations... Besides, a quick look over shows there is still some namespace ambiguity (oxy still appeared without declaration...) and then function block having flwor construction..., that's fine, and suddenly after the "return" there re-appear flwo... That kinds of error mean nobody can really help as the whole sense of the script in uncomprehensible. Why don't you start debugging at early stage and debug it every time with every thing you care to add to it?
                • 5. Re: finding association rule (creating problem)
                  923415
                  sir plz give me suggestion for this coding i m change th name space


                  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>


                  xquery version "1.0";
                  declare namespace local = "http://www.w3.org/2003/11/xpath-local-functions";





                  declare function local:FP-growth($l as element()*, $L as element()*, $minsup as xs:decimal, $total as xs:decimal, $src as element()) as element()*
                  {
                  let $f-item := first item in $L
                  let $l-item := last item in $L
                  let $T := local:getl-itemsets($src, $total, $minsup)
                  return <items>
                  {local:join ($l-item, $T)}
                  </items>
                  let $l:=$l-items
                  let $L:=local:remove($l)
                  for f-item in $L
                  where $f-item != $l-item
                  return
                  local:FP-growth($l, $L, $minsup, $total, $src)
                  };

                  declare function oxy:getl-itemsets( $src as element(), $total as xs:decimal , $minsup as xs:decimal))
                  as 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 local:join($X as element(), $Y as element()) as element() {
                  let $items := (for $item in $Y
                  where every $i in $X satisfies
                  $i != $item
                  return $item)
                  return $X union $items
                  }

                  declare function local:removeDuplicate($C as element()*) as 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
                  }

                  for $src in doc("transaction.xml")//items
                  let $minsup := 0.4
                  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>{local:FP-growth($l,$L,$minsup,$total,$src)}
                  </largeItemsets>


                  sir it give error "Error: syntax error, unexpected xquery, expecting <end of file> [err:XPST0003], <query>:1:43"

                  plz help me sir for sort out this
                  warm regards

                  Edited by: 920412 on Mar 15, 2012 2:42 AM

                  Edited by: 920412 on Mar 14, 2012 10:58 PM

                  Edited by: 920412 on Mar 15, 2012 10:47 AM
                  • 6. Re: finding association rule (creating problem)
                    tsuji
                    Tell the forum what are these for instance.
                    >
                    let $f-item := first item in $L
                    let $l-item := last item in $L
                    • 7. Re: finding association rule (creating problem)
                      923415
                      SIR CAN U HELP ME FOR THIS I SEND THIS IS DIFFERENT FOR THAT PREVIOUS PLZ CHEK IT ONCE PLZ SIR


                      xquery version "1.0";
                      declare namespace local = "http://www.w3.org/2003/11/xpath-local-functions";

                      declare function local:join($X as element(), $Y as element()) as element() {
                      let $items := (for $item in $Y
                      where every $i in $X satisfies
                      $i != $item
                      return $item)
                      return $X union $items
                      };

                      declare function local:commonIts($X as element(), $Y as element()) as element() {
                      for $item in $X
                      where some $i in $Y satisfies $i = $item
                      return $item
                      };

                      declare function local:removeIts($X as element(), $Y as element()) as element() {
                      for $item in $X
                      where every $i in $Y satisfies $i != $item
                      return $item
                      };

                      declare function local:candidateGen($l as element()*) as element()* {
                      for $freqSet1 in $l
                      let $items1 := $freqSet1//items/*
                      for $freqSet2 in $l
                      let $items2 := $freqSet2//items/*
                      where $freqSet2 >> $freqSet1 and
                      count($items1)+1 = count($items1 union $items2)
                      and local:prune(local:join($items1,$items2), $l)
                      return
                      <items>{local:join($items1,$items2)}</items>
                      };

                      declare function local:prune($X as element(), $Y as element()) as xs:boolean
                      {
                      every $item in $X satisfies
                      some $items in $Y//items satisfies
                      count(local:commonIts(local:removeIts($X,$item),$items/*))
                      = count($X) - 1
                      };

                      declare function local:removeDuplicate($C as element()*) as element()*
                      {
                      for $itemset1 in $C
                      let $items1 := $itemset1/*
                      let $items :=(for $itemset2 in $C
                      let $items2 := $itemset2/*
                      where $itemset2>>$itemset1 and
                      count($items1) =
                      count(local:commonIts($items1, $items2))
                      return $items2)
                      where count($items) = 0
                      return $itemset1
                      };

                      declare function local:getLargeItemsets($C as element()*, $minsup as xs:decimal, $total as xs:decimal, $src as element()) as element()*
                      {
                      for $items in $C
                      let $trans := (for $tran in $src
                      where every $item1 in $items/* satisfies
                      some $item2 in $tran/*
                      satisfies $item1 = $item2
                      return $tran)
                      let $sup := (count($trans) * 1.00) div $total
                      where $sup >= $minsup
                      return <largeItemset> {$items}
                      <support> {$sup} </support>
                      </largeItemset>
                      };

                      declare function local:apriori($l as element()*, $L as element()*, $minsup as xs:decimal, $total as xs:decimal, $src as element()) as element()*
                      {
                      let $C := local:removeDuplicate(local:candidateGen($l))
                      let $l := local:getLargeItemsets($C, $minsup, $total, $src)
                      let $L := $l union $L
                      return if (empty($l)) then
                      $L
                      else
                      local:apriori($l, $L, $minsup, $total, $src)
                      };

                      for $src in doc("transactions.xml")//items
                      let $minsup := 0.4
                      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.00) div $total
                      where $sup >= $minsup
                      return <largeItemset>
                      <items> {$itemset} </items>
                      <support> {$sup} </support>
                      </largeItemset>)
                      let $L := $l
                      return <largeItemsets> { local:apriori($l, $L,$minsup, $total, $src) }
                      </largeItemsets>


                      FOR SAME INPUT FILE

                      THE PREVIOUS FOR FPGROWH AND THAT ONE FOR APRIORI ALGO PLZ CHEK IT ONCE

                      THANK U IN ADVANCE
                      • 8. Re: finding association rule (creating problem)
                        923415
                        sir i m explain in from strating i send the different code from the previous plz check it once

                        sir i m using ""oxygen xml"" of ruuning the xquery
                        and i made a data base connection barkeley dbxml the data base connection work fiine for small xquery but i will give error in that that
                        plz help me the error is at the end of the program

                        my input firle is
                        <?xml version="1.0" standalone="yes"?>
                        <transactions>
                        <transaction id="1">
                        <items>
                        <item>a</item>
                        <item>d</item>
                        <item>e</item>
                        </items>
                        </transaction>
                        <transaction id="2">
                        <items>
                        <item>b</item>
                        <item>c</item>
                        <item>d</item>
                        </items>
                        </transaction>
                        <transaction id="3">
                        <items>
                        <item>a</item>
                        <item>c</item>
                        <item>e</item>
                        </items>
                        </transaction>
                        <transaction id="4">
                        <items>
                        <item>b</item>
                        <item>c</item>
                        <item>d</item>
                        </items>
                        </transaction>
                        <transaction id="5">
                        <items>
                        <item>a</item>
                        <item>b</item>

                        </items>
                        </transaction>
                        </transactions>



                        my code is this

                        xquery version "1.0";
                        declare namespace local = "http://www.w3.org/2003/11/xpath-local-functions";

                        declare function local:join($X as element(), $Y as element()) as element() {
                        let $items := (for $item in $Y
                        where every $i in $X satisfies
                        $i != $item
                        return $item)
                        return $X union $items
                        };

                        declare function local:commonIts($X as element(), $Y as element()) as element() {
                        for $item in $X
                        where some $i in $Y satisfies $i = $item
                        return $item
                        };

                        declare function local:removeIts($X as element(), $Y as element()) as element() {
                        for $item in $X
                        where every $i in $Y satisfies $i != $item
                        return $item
                        };

                        declare function local:candidateGen($l as element()*) as element()* {
                        for $freqSet1 in $l
                        let $items1 := $freqSet1//items/*
                        for $freqSet2 in $l
                        let $items2 := $freqSet2//items/*
                        where $freqSet2 >> $freqSet1 and
                        count($items1)+1 = count($items1 union $items2)
                        and local:prune(local:join($items1,$items2), $l)
                        return
                        <items>{local:join($items1,$items2)}</items>
                        };

                        declare function local:prune($X as element(), $Y as element()) as xs:boolean
                        {
                        every $item in $X satisfies
                        some $items in $Y//items satisfies
                        count(local:commonIts(local:removeIts($X,$item),$items/*))
                        = count($X) - 1
                        };

                        declare function local:removeDuplicate($C as element()*) as element()*
                        {
                        for $itemset1 in $C
                        let $items1 := $itemset1/*
                        let $items :=(for $itemset2 in $C
                        let $items2 := $itemset2/*
                        where $itemset2>>$itemset1 and
                        count($items1) =
                        count(local:commonIts($items1, $items2))
                        return $items2)
                        where count($items) = 0
                        return $itemset1
                        };

                        declare function local:getLargeItemsets($C as element()*, $minsup as xs:decimal, $total as xs:decimal, $src as element()) as element()*
                        {
                        for $items in $C
                        let $trans := (for $tran in $src
                        where every $item1 in $items/* satisfies
                        some $item2 in $tran/*
                        satisfies $item1 = $item2
                        return $tran)
                        let $sup := (count($trans) * 1.00) div $total
                        where $sup >= $minsup
                        return <largeItemset> {$items}
                        <support> {$sup} </support>
                        </largeItemset>
                        };

                        declare function local:apriori($l as element()*, $L as element()*, $minsup as xs:decimal, $total as xs:decimal, $src as element()) as element()*
                        {
                        let $C := local:removeDuplicate(local:candidateGen($l))
                        let $l := local:getLargeItemsets($C, $minsup, $total, $src)
                        let $L := $l union $L
                        return if (empty($l)) then
                        $L
                        else
                        local:apriori($l, $L, $minsup, $total, $src)
                        };

                        for $src in doc("transactions.xml")//items
                        let $minsup := 0.4
                        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.00) div $total
                        where $sup >= $minsup
                        return <largeItemset>
                        <items> {$itemset} </items>
                        <support> {$sup} </support>
                        </largeItemset>)
                        let $L := $l
                        return <largeItemsets> { local:apriori($l, $L,$minsup, $total, $src) }
                        </largeItemsets>

                        sir it will error like that:

                        System ID: G:\rahul\vinit\ap.xq
                        Scenario: ap2
                        XQuery file: G:\rahul\vinit\ap.xq
                        Engine name: BERKELEY DBXML
                        Severity: error
                        Description: Uncaught exception from C++ API(Internal system error)

                        thank in advance
                        • 9. Re: finding association rule (creating problem)
                          tsuji
                          You've to correct a number of function signatures:
                          [1]
                          >
                          declare function local:join($X as element(), $Y as element()) as element() {
                          >
                          declare function local:join($X as element()*, $Y as element()*) as element()* {
                          [2]
                          >
                          declare function local:commonIts($X as element(), $Y as element()) as element() {
                          >
                          declare function local:commonIts($X as element()*, $Y as element()*) as element()* {
                          [3]
                          >
                          declare function local:removeIts($X as element(), $Y as element()) as element() {
                          >
                          declare function local:removeIts($X as element()*, $Y as element()*) as element()* {
                          [4]
                          >
                          declare function local:prune($X as element(), $Y as element()) as xs:boolean
                          >
                          declare function local:prune($X as element()*, $Y as element()*) as xs:boolean
                          [5]
                          >
                          declare function local:getLargeItemsets($C as element()*, $minsup as xs:decimal, $total as xs:decimal, $src as element()) as element()*
                          >
                          declare function local:getLargeItemsets($C as element()*, $minsup as xs:decimal, $total as xs:decimal, $src as element()*) as element()* 
                          From thereupon, you can focus more on the logic from the result obtained.
                          • 10. Re: finding association rule (creating problem)
                            923415
                            thank u sir my code is running
                            but there is one problem the result he regerate is not correct sir

                            i send the complete information to u my input file my project code my output file and my actual output that i need ......plz sir chek it where is he logical mistak in code i completely chek lots of time i m not able to find where is the logical mistak plz sir help me

                            input file "transactions.xml"

                            <?xml version="1.0" standalone="yes"?>
                            <transactions>
                            <transaction id="1">
                            <items>
                            <item>a</item>
                            <item>d</item>
                            <item>e</item>
                            </items>
                            </transaction>
                            <transaction id="2">
                            <items>
                            <item>b</item>
                            <item>c</item>
                            <item>d</item>
                            </items>
                            </transaction>
                            <transaction id="3">
                            <items>
                            <item>a</item>
                            <item>c</item>
                            <item>e</item>
                            </items>
                            </transaction>
                            <transaction id="4">
                            <items>
                            <item>b</item>
                            <item>c</item>
                            <item>d</item>
                            </items>
                            </transaction>
                            <transaction id="5">
                            <items>
                            <item>a</item>
                            <item>b</item>

                            </items>
                            </transaction>
                            </transactions>

                            coding :=

                            xquery version "1.0";
                            declare namespace local = "http://www.w3.org/2003/11/xpath-local-functions";

                            declare function local:join($X as element()*, $Y as element()*) as element()* {
                            let $items := (for $item in $Y
                            where every $i in $X satisfies
                            $i != $item
                            return $item)
                            return $X union $items
                            };

                            declare function local:commonIts($X as element()*, $Y as element()*) as element()* {
                            for $item in $X
                            where some $i in $Y satisfies $i = $item
                            return $item
                            };

                            declare function local:removeIts($X as element()*, $Y as element()*) as element()* {
                            for $item in $X
                            where every $i in $Y satisfies $i != $item
                            return $item
                            };

                            declare function local:candidateGen($l as element()*) as element()* {
                            for $freqSet1 in $l
                            let $items1 := $freqSet1//items/*
                            for $freqSet2 in $l
                            let $items2 := $freqSet2//items/*
                            where $freqSet2 >> $freqSet1 and
                            count($items1)+1 = count($items1 union $items2)
                            and local:prune(local:join($items1,$items2), $l)
                            return
                            <items>{local:join($items1,$items2)}</items>
                            };

                            declare function local:prune($X as element()*, $Y as element()*) as xs:boolean
                            {
                            every $item in $X satisfies
                            some $items in $Y//items satisfies
                            count(local:commonIts(local:removeIts($X,$item),$items/*))
                            = count($X) - 1
                            };

                            declare function local:removeDuplicate($C as element()*) as element()*
                            {
                            for $itemset1 in $C
                            let $items1 := $itemset1/*
                            let $items :=(for $itemset2 in $C
                            let $items2 := $itemset2/*
                            where $itemset2>>$itemset1 and
                            count($items1) =
                            count(local:commonIts($items1, $items2))
                            return $items2)
                            where count($items) = 0
                            return $itemset1
                            };

                            declare function local:getLargeItemsets($C as element()*, $minsup as xs:decimal, $total as xs:decimal, $src as element()*) as element()*
                            {
                            for $items in $C
                            let $trans := (for $tran in $src
                            where every $item1 in $items/* satisfies
                            some $item2 in $tran/*
                            satisfies $item1 = $item2
                            return $tran)
                            let $sup := (count($trans) * 1.00) div $total
                            where $sup >= $minsup
                            return <largeItemset> {$items}
                            <support> {$sup} </support>
                            </largeItemset>
                            };

                            declare function local:fp-growth($l as element()*, $L as element()*, $minsup as xs:decimal, $total as xs:decimal, $src as element()*) as element()*
                            {
                            let $C := local:removeDuplicate(local:candidateGen($l))
                            let $l := local:getLargeItemsets($C, $minsup, $total, $src)
                            let $L := $l union $L
                            return if (empty($l)) then
                            $L
                            else
                            local:fp-growth($l, $L, $minsup, $total, $src)
                            };

                            let $src := doc("transactions.xml")//items

                            let $minsup := 0.5
                            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.00) div $total
                            where $sup >= $minsup
                            return <largeItemset>
                            <items> {$itemset} </items>
                            <support> {$sup} </support>
                            </largeItemset>)
                            let $L := $l
                            return <largeItemsets> { local:fp-growth($l, $L,$minsup, $total, $src) }
                            </largeItemsets>

                            output that is get for running the query:=
                            <?xml version="1.0" encoding="UTF-8"?>
                            <largeItemsets>
                            <largeItemset>
                            <items>a</items>
                            <support>0.6</support>
                            </largeItemset>
                            <largeItemset>
                            <items>d</items>
                            <support>0.6</support>
                            </largeItemset>
                            <largeItemset>
                            <items>b</items>
                            <support>0.6</support>
                            </largeItemset>
                            <largeItemset>
                            <items>c</items>
                            <support>0.6</support>
                            </largeItemset>
                            </largeItemsets>

                            but sir i want my output like that:=

                            <?xml version="1.0" standalone="yes"?>
                            <largeItemsets>
                            <largeItemset>
                            <Items>
                            <item>a</item>
                            </Items>
                            <support>0.6</support>
                            </largeItemset>

                            <largeItemset>
                            <Items>
                            <item>d</item>
                            </Items>
                            <support>0.6</support>
                            </largeItemset>

                            <largeItemset>
                            <Items>
                            <item>b</item>
                            </Items>
                            <support>0.6</support>
                            </largeItemset>

                            <largeItemset>
                            <Items>
                            <item>c</item>
                            </Items>
                            <support>0.6</support>
                            </largeItemset>

                            <largeItemset>
                            <Items>
                            <item>d</item>
                            <item>b</item>
                            </Items>
                            <support>0.4</support>
                            </largeItemset>

                            <largeItemset>
                            <Items>
                            <item>b</item>
                            <item>c</item>
                            </Items>
                            <support>0.4</support>
                            </largeItemset>

                            <largeItemset>
                            <Items>
                            <item>d</item>
                            <item>c</item>
                            <item>b</item>
                            </Items>
                            <support>0.4</support>
                            </largeItemset>
                            </largeItemsets>


                            sir i want that out which i shown last help me sir how i sort out this problem
                            thank i advance
                            • 11. Re: finding association rule (creating problem)
                              tsuji
                              Since I have got the script at least running beginning to end and syntactically sound, and that you time and time again proliferate the same questions to multiple threads to the limit of spamming the forum(s), I consider my help is enough and apt to come to an end to my satisfaction. The rest I leave it to the forum.