db:attribute and eq unexpected behaviour

Saturday, 9 July 2016 · 3 messages
AM
Alex Muir9 Jul 2016 22:25 #
Hi, I have XML data with attributes that I've set in attribute indexes with the following consistent format but with different values
form13FFileNumber="028-17473"
form13FFileNumber="028-16573"
When I query the data with following without indexes
let $data := db:open('13F')//data[@form13FFileNumber eq $form13FFileNumber]
or with the db:attribute method using indexes let $data := db:attribute("13F", $form13FFileNumber, "form13FFileNumber")/.. with both queries I get extra data and the same extra data So if I try to extract form13FFileNumber 028-11185 for example I get 028-11185 as the first result but also 028-13947 and others... Similarly for 028-10601 I get data for 028-10601 and 028-17017 and others does the dash with numbers cause a problem with the indexing? XQUERY Getting result
xquery version "3.0";
declare namespace db="http://basex.org/modules/db";
declare namespace file="http://expath.org/ns/file";
declare variable $form13FFileNumber as xs:string external;

(:let $data := db:open('13F')//data[@form13FFileNumber eq
$form13FFileNumber] :)
let $data := db:attribute("13F", $form13FFileNumber, "form13FFileNumber")/..
let $fields :=

<form13FFile>
{
for $c in $data return $c

}
</form13FFile>

return file:write(concat('../OUTPUT/form13Restatment3rd_' ,
$form13FFileNumber , '.xml'), $fields)
BD CREATE COMMANDS:
<?xml version="1.0" encoding="UTF-8"?>
<commands>
    <set
option='attrinclude'>xml:id,filingDate,type,cik,sequence,form13FFileNumber,periodOfReport</set>
    <create-db name='13F'/>
    <info-db/>
</commands>

The xml element that has all the indexes
 <data xml:id="0001534270-16-000006" filingDate="2016-06-08" type="13F-HR"
cik="1534270" sequence="000006" form13FFileNumber="028-17473"
periodOfReport="03-31-2016">
The basex 744 db is around 8gb and data was added with this xquery
let $docs := collection($path)
for $doc in $docs
return
let $path :=
concat($doc/data/@periodOfReport,'/',$doc/data/@form13FFileNumber,'/',$doc/data/@xml:id,'.xml')
return db:add('13F', $doc, $path)
Regards Alex tech.jahtoe.com bafila.jahtoe.com
CG
Christian Grün9 Jul 2016 22:32 #
Hi Alex,
Quoted text · Alex Muir · 3 lines
> So if I try to extract form13FFileNumber 028-11185 for example > > I get 028-11185 as the first result but also 028-13947 and others...
Sorry, I can’t quite grasp what’s the problem; could you detail what you mean by "extract"? Could you provide us with a little self-contained example? Thanks in advance Christian
AM
Alex Muir9 Jul 2016 22:35 #
Ah nevermind.. I just realized that some of the data has more than one form13FFileNumber which I had not seen before Sorry... Regards Alex tech.jahtoe.com bafila.jahtoe.com
Quoted text · Christian Grün · 15 lines
On Sat, Jul 9, 2016 at 8:32 PM, Christian Grün <christian.gruen at gmail.com> wrote: > Hi Alex, > > > So if I try to extract form13FFileNumber 028-11185 for example > > > > I get 028-11185 as the first result but also 028-13947 and others... > > Sorry, I can’t quite grasp what’s the problem; could you detail what > you mean by "extract"? Could you provide us with a little > self-contained example? > > Thanks in advance > Christian >

⚡Generated with XQuery