Re: [basex-talk] Optimized query for importing content based on metadata
Thanks Christian! I appreciate the touch-up and the insight. Jason On 10/19/18, 2:26 PM, "Christian Grün" wrote: Hi Jason, My version would have looked pretty similar: let $xmlroot := '/Users/jason.davis/Sandbox/dita-docs/content/' for $path in file:list($xmlroot, true()) where matches($path, '\.(xml|ditamap)$') let $doc := doc($xmlroot || $path) where $doc//brand[contains(., 'xyz')] return db:add('d4st^dita-docs^meta-test', $doc, $path) If you have already openen the document, you can directly pass it on to db:add. Cheers, Christian On Fri, Oct 19, 2018 at 11:01 PM Jason Davis wrote: > > Hi, > > I’ve cobbled together a query that I want to use to import xml from the filesystem into the database based on specific metadata requirements: > > let $xmlroot := "/Users/jason.davis/Sandbox/dita-docs/content/" >for $file in file:list($xmlroot, true()) >where matches($file, 'xml') or matches($file, 'ditamap') >let $doc := file:resolve-path($file, $xmlroot) >return if (doc($doc)//brand[contains(.,'xyz')]) >then db:add("d4st^dita-docs^meta-test", $doc) >else () > > It works, so I’m pleased! I’m just wondering if there is a more efficient way to achieve what I want to do. I know that using a specific XPath in the doc function is one thing I can do better. Any suggestions are appreciated! > > Thanks, > Jason
Re: [basex-talk] Optimized query for importing content based on metadata
Hi Jason, My version would have looked pretty similar: let $xmlroot := '/Users/jason.davis/Sandbox/dita-docs/content/' for $path in file:list($xmlroot, true()) where matches($path, '\.(xml|ditamap)$') let $doc := doc($xmlroot || $path) where $doc//brand[contains(., 'xyz')] return db:add('d4st^dita-docs^meta-test', $doc, $path) If you have already openen the document, you can directly pass it on to db:add. Cheers, Christian On Fri, Oct 19, 2018 at 11:01 PM Jason Davis wrote: > > Hi, > > I’ve cobbled together a query that I want to use to import xml from the > filesystem into the database based on specific metadata requirements: > > let $xmlroot := "/Users/jason.davis/Sandbox/dita-docs/content/" >for $file in file:list($xmlroot, true()) >where matches($file, 'xml') or matches($file, 'ditamap') >let $doc := file:resolve-path($file, $xmlroot) >return if (doc($doc)//brand[contains(.,'xyz')]) >then db:add("d4st^dita-docs^meta-test", $doc) >else () > > It works, so I’m pleased! I’m just wondering if there is a more efficient way > to achieve what I want to do. I know that using a specific XPath in the doc > function is one thing I can do better. Any suggestions are appreciated! > > Thanks, > Jason
[basex-talk] Optimized query for importing content based on metadata
Hi, I’ve cobbled together a query that I want to use to import xml from the filesystem into the database based on specific metadata requirements: let $xmlroot := "/Users/jason.davis/Sandbox/dita-docs/content/" for $file in file:list($xmlroot, true()) where matches($file, 'xml') or matches($file, 'ditamap') let $doc := file:resolve-path($file, $xmlroot) return if (doc($doc)//brand[contains(.,'xyz')]) then db:add("d4st^dita-docs^meta-test", $doc) else () It works, so I’m pleased! I’m just wondering if there is a more efficient way to achieve what I want to do. I know that using a specific XPath in the doc function is one thing I can do better. Any suggestions are appreciated! Thanks, Jason