flwor

Simple XQuery FLWOR to return text without numbers

╄→гoц情女王★ 提交于 2020-04-16 06:08:11
问题 How do I return non-numeric text? for $foo in db:open("foo") return $foo//text() Assuming that every address or phone number cell from the original spreadsheet has numerals, I'm looking to return any string without numerals. context, per Michael Kay's note: Each cell of the spreadsheet has a String. There's only one column of what can easily be CSV data. Seemingly, only the names lack numerals. On that assumption, looking to break the data into "chunks" to differentiate each individual. There

How to use tumbling window to group XML elements by content?

梦想与她 提交于 2020-02-29 06:54:39
问题 How do I group based on whether there's a match to [0-9] for digits with a tumbling window ? desired output: ... <record> <name>joe</name> <data>phone1</data> <data>phone2</data> </record> ... current output, not grouped: <xml> <record> <person key="$s" data="name">phone1</person> </record> <record> <person key="$s" data="name">phone2</person> </record> <record> <person key="$s" data="name">phone3sue</person> </record> <record> <person key="$s" data="name">cell4</person> </record> <record>

How to create a new list item with FLOWR and XQuery?

我的梦境 提交于 2020-02-25 06:30:49
问题 I'm looking to select non-numerical data from an XML file towards shredding it into database columns, or at least an xmltable -like structure. This FLWOR gives a somewhat useful result: xquery version "3.0"; declare namespace office="urn:oasis:names:tc:opendocument:xmlns:text:1.0"; <ul> { for $foo in db:open("foo") return <li>{$foo//text()[not(matches(., '[0-9]'))]}</li> } </ul> However, it outputs all results into a single li tag, like: a b c d Preferred output would be of the form: a b Most

add an XPath statement to a FLOWR to select “id” nodes from Twitter database

孤人 提交于 2020-02-08 10:17:10
问题 Looking at the "id" field for a twitter database: thufir@dur:~/flwor$ thufir@dur:~/flwor$ basex BaseX 9.0.1 [Standalone] Try 'help' to get more information. > > open twitter Database 'twitter' was opened in 218.67 ms. > > xquery //id <id type="number">1224165280068382720</id> <id type="number">60919433</id> <id type="number">1224160851797643264</id> <id type="number">60919433</id> .. <id type="number">14248074</id> Query executed in 268.13 ms. > how would I get the same result from a FLWOR

Concat XML nodes using XQuery

痞子三分冷 提交于 2019-12-13 16:08:48
问题 I required the following output <name>Thomas Mapother</name> <name>Tom Cruise</name> using the below XML using XQuery FLOWR Expressions. INSERT INTO XMLO1 VALUES ('<Contact> <Names> <Name Type = "Legal"> <First>Thomas</First> <Middle>T</Middle> <Last>Mapother</Last> </Name> <Name Type = "Stage"> <First>Tom</First> <Middle>C</Middle> <Last>Cruise</Last> </Name> </Names> </Contact>') I tried the below query. But it returns a different output. SELECT xDoc.query('let $names := Contact/Names/Name

Return multiple XML nodes and Custom parent tag using FLWOR XQuery

瘦欲@ 提交于 2019-12-11 17:08:21
问题 I need to get the following output using a FLWOR expression. <oldPlanes> <make>Cessna</make> <model>Centurian</model> <make>Piper</make> <model>Tripacer</model> </oldPlanes> using CREATE TABLE XMLO1 (xDoc XML NOT NULL) INSERT INTO XMLO1 VALUES (' <planes> <plane> <year>1977</year> <make>Cessna</make> <model>Skyhawk</model> <color>Light blue and white</color> </plane> <plane> <year>1975</year> <make>Piper</make> <model>Apache</model> <color>White</color> </plane> <plane> <year>1960</year>

Error “undefined variable at noteLine” in FLWOR expression when returning multiple nodes

二次信任 提交于 2019-12-11 01:06:00
问题 I have a very strange problem with a FLWOR loop, that works one way but not another. The goal is to take a string of any length, and break it into XML nodes that can only hold 80 chars each. So, first whack, this works great: for $noteLine in $noteLineArr where $noteLine != '' return if (fn:string-length(fn:normalize-space($noteLine)) < 80) then ( <NTE> <NoteRefCd>WHI</NoteRefCd> <Descr>{fn:substring(fn:normalize-space($noteLine), 1, 80)}</Descr> </NTE> ) else if (fn:string-length(fn

Incomplete FLWOR expression: expecting 'return'

天涯浪子 提交于 2019-12-10 22:16:02
问题 I am having some trouble with the if-then-else command of the XQuery. Currently I am using BaseX to edit XQuery (if that matters!) if ($item/pf3:Current/pf3:Name) then ( let $Name := "None" ) else ( let $Name := data($item/pf3:Current/pf3:Name) ) This piece throws an error saying: [XPST0003] Incomplete FLWOR expression: expecting 'return'. 回答1: There is a small problem with your xquery. Here is the corrected version - let $Name := if ($item/pf3:Current/pf3:Name) then "None" else data($item

Xquery: same test has different result whether used in switch/case or in if/then/else

泪湿孤枕 提交于 2019-12-10 13:35:13
问题 I can't find an explanation on the following. I've made this test script in order to solve my previous question. xquery version "3.0" ; declare default function namespace 'local' ; declare function local:is-img-only( $element as element() ) as xs:boolean { ($element/child::*[1] instance of element(img)) and (fn:not($element/child::*[2])) and (fn:normalize-space($element) = '') } ; let $in-xml := <myxml> <p id="1"> <img id="1"/> </p> <p id="2"> <img id="1"/> hello </p> <p id="3"> <img id="1"/>