Questions tagged [flwor]

Acronym denoting a certain XQuery expression for querying, manipulating, and transforming XML data.

Acronym denoting the components of a certain XQuery expression, allowing transformation, manipulation and sorting of an XQuery result. FLWOR stands for: for (iterate over nodeset) - let (declare variable) - where (restrict source nodeset) - order by (sort result) - return (deliver the output).

103 questions
6
votes
3 answers

Using xquery FLWOR expressions to find multiple "where" restrictions

I am trying to find employees who work on projects located in Houston but the department the project is housed in is not located in Houston. I was trying to model the expression after this example of FLWOR expressions but the query doesn't return…
mnky9800n
  • 1,113
  • 2
  • 15
  • 33
6
votes
1 answer

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

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…
laconis
  • 97
  • 8
6
votes
2 answers

FLWOR in Sql server count number of hits

I am using SQL Server 2008 R2. My problem is that I want to count number of hits that i receive from XQuery query using FLWOR. For each hit, I want a consecutive number, like: 0,1,2,3,4... My query: select @xml.query('for $s at $count in…
FrenkyB
  • 6,625
  • 14
  • 67
  • 114
4
votes
2 answers

Return a calculated element name from a XML FLWOR query

I have the following XML data in SQLServer 2008 R2 DECLARE @data XML SET @data = '' I would like to get a list of the attribute names from root and output that as a list of elements, like this:
d4nt
  • 15,475
  • 9
  • 42
  • 51
4
votes
3 answers

transforming sequence of elements to tree

I have a list of elements with information about how deep they are located in an XML tree. The elements at "the bottom," i.e. those elements that occur before an element with a lower depth, contain text.
4
votes
1 answer

Xquery FLWOR with group by

I want to group all movies by genre and then list all movie titles in this genre. My XML movie database looks as following: A History of Violence 2005 USA
4
votes
1 answer

xquery beginner- how to use an if-then-else within a FLWOR statement

I want to extract some content from a web page's XML equivalent, using XQuery. Here, I want to use if-then-else -- if a specific condition is met, then one value is returned by the xquery expression, otherwise a different value is returned. This is…
user1578871
  • 53
  • 1
  • 1
  • 4
3
votes
1 answer

XQuery returns items not in set

I am writing some XQuery on the following document: ... ... ... …
Shane McGarry
  • 513
  • 1
  • 6
  • 19
3
votes
2 answers

Converting xml to csv from XQuery in BaseX

The reason for which I'm writing is because I have a database of approx 1k of xmls in BaseX. I already cleaned it and got the info I wanted. Nevertheless, I want to be able to export that data in the CSV format. When I tried with the code given in…
Antonio López Ruiz
  • 1,396
  • 5
  • 20
  • 36
2
votes
1 answer

Wildcard in XQuery corresponding to [where LIKE '%.mp3'] in SQL

I´m wondering how to use wildcards in XQuery. I have two lines of codes which gives me the return that I want from a xml file: for $phrase in //phrases[@pPhrase="Phrase1.mp3"] return concat(string($phrase/@pPhrase), ",…
Markus
  • 21
  • 1
2
votes
3 answers

How is "at" used in XQuery to find the position of a node?

Where and how is $p defined or created from? Why is it the index or position of the node at all? Input from w3schools, the bookstore example. output: Harry Potter J K.…
2
votes
1 answer

How to "stitch together" results into a single XML document with eXist-db?

How do I create a "single" result of one notes element as the root node, with multiple child nodes of note elements? Here's the query in eXide: xquery version "3.0"; for $note in collection('/db/tmp')/note return {$note} where…
2
votes
2 answers

Unordered list inside table using FLWOR

I want to make a table in which I'm going to make an unordered list with the names of the hotels and the number of stars like this: Hoteles · Macuya (4) · Fuentevino (2) · Tresarazos (3) Using this code:
Lordpascal
  • 51
  • 1
  • 6
2
votes
2 answers

How to return a range of XML nodes with XQuery of FLWOR?

I'm interested in getting back a specific range of results, say from 99 to 199, or, perhaps, the last JSON object. While this works for small numbers or ranges, how can it be generalized or expanded to a larger range? xquery version "3.0"; for $i…
Thufir
  • 8,216
  • 28
  • 125
  • 273
2
votes
1 answer

How to pipe one FLWOR into another?

Simple FLWOR to get all the data (from what was a spreadsheet): for $foo in db:open("foo") return $foo//text() gives this type of output: ... Smallville, XX 12345-1234 Bob (123) 456-7809 (123) 876-3468 Smallville, XX…
Thufir
  • 8,216
  • 28
  • 125
  • 273
1
2 3 4 5 6 7