HTML Tutorials |
|
XML Tutorials |
|
Browser Scripting |
|
Server Scripting |
|
.NET (dotnet) |
|
Multimedia |
|
Web Building |
|
Java Tutorials |
|
Programming Langauges |
|
Soft Skills |
|
Database Tutorials |
|
Operating System |
|
Software Testing |
|
SAP Module |
|
Networking Programming |
|
Microsoft Office |
|
Accounting |
|
|
XQuery Wahl- und Filterelemente |
Das XML Beispiel-Dokument
|
Wir benutzen das „bookdetails.xml“ Dokument im Beispiel unten (die gleiche XML Akte wie in den vorhergehenden Kapiteln).
|
Selecting and Filtering Elements
|
As we have seen in the previous chapters, we are selecting
and filtering elements with either a FLWOR expression or with a Path expression .
Look at the FLWOR expression which is given below:
|
for $x in doc("bookdetails.xml")/bookstore/book
where $x/price>30
order by $x/title
return $x/title
|
|
- for - (optional) binds the variable to each item returned
by the in expression
- let - This one is optional
- where - (optional) specify a criteria
- order by - (optional) specify the sort-order of the
result
- return - specify what to return in the result
|
|
Für Klauselbindung, die eine Variable zu jedem Einzelteil durch den Ausdruck zurückbrachte. Für Klauselresultat in der Wiederholung. Es kann für Klauseln im gleichen FLWOR Ausdruck mehrfach geben.
Um eine spezifische Anzahl von Zeiten in a für Klausel zu schlingen, kannst du zum Schlüsselwort verwenden müssen:
|
for $x in (1 to 5)
return <test>{$x}</test>
|
|
Result:
|
<test>1</test>
<test>2</test>
<test>3</test>
<test>4</test>
<test>5</test>
|
|
The at keyword can be used to count the number of iteration:
|
for $x at $i in doc("bookdetails.xml")/bookstore/book/title
return <book>{$i}. {data($x)}</book>
|
|
Result:
|
<book>1. Everyday Italian</book>
<book>2. Harry Potter</book>
<book>3. XQuery Kick Start</book>
<book>4. Learning XML</book>
|
|
Du kannst mehr als ein im Ausdruck in für Klausel verwenden. Komma verwenden, um das jedes im Ausdruck zu trennen:
|
for $x in (10,20), $y in (100,200)
return <test>x={$x} and y={$y}</test>
|
|
Result:
|
<test>x=10 and y=100</test>
<test>x=10 and y=200</test>
<test>x=20 and y=100</test>
<test>x=20 and y=200</test>
|
|
The let Clause
|
The let clause erlaubt variable Anweisungen und sie vermeidet immer, den gleichen Ausdruck viele Male zu wiederholen. Klausel lassen ergibt nicht eine Wiederholung.
|
let $x := (1 to 5)
return <test>{$x}</test>
|
|
Resultat:
|
|
The where Clause
|
The where clause verwendet wird, um eine oder mehrer Kriterien für das bestimmte Resultat zu spezifizieren:
|
where $x/price>30 and $x/price<100
|
|
The order by Clause
|
The order by clause wird verwendet, um den Artauftrag der Resultate zu spezifizieren. Hier möchten wir das Resultat durch die Kategorie bestellen und betiteln:
|
for $x in doc("bookdetails.xml")/bookstore/book
order by $x/@category, $x/title
return $x/title
|
|
Result:
|
<title lang="en">Harry Potter</title>
<title lang="en">Everyday Italian</title>
<title lang="en">Learning XML</title>
<title lang="en">XQuery Kick Start</title>
|
|
The return Clause
|
The return clause spezifizieren, was zurückgegangen werden soll.
|
for $x in doc("bookdetails.xml")/bookstore/book
return $x/title
|
|
Resultat:
|
<title lang="en">Everyday Italian</title>
<title lang="en">Harry Potter</title>
<title lang="en">XQuery Kick Start</title>
<title lang="en">Learning XML</title>
|
|
|
|
Keywords:
xquery select ,xquery order by ,xpath select,xquery sql server,xquery distinct,xpath distinct ,xpath select attribute,xpath select node,xquery distinct values,xpath distinct values,xpath select nodes,xpath select all,xquery tutorial
|
|
HTML Quizes |
|
XML Quizes |
|
Browser Scripting Quizes |
|
Server Scripting Quizes |
|
.NET (dotnet) Quizes |
|
Multimedia Quizes |
|
Web Building Quizes |
|
Java Quizes |
|
Programming Langauges Quizes |
|
Soft Skills Quizes |
|
Database Quizes |
|
Operating System Quizes |
|
Software Testing Quizes |
|
SAP Module Quizes |
|
Networking Programming Quizes |
|
Microsoft Office Quizes |
|
Accounting Quizes |
|
|