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)