cheap nfl jerseys china cheap nfl jerseys free shipping wholesale nfl jerseys china wholesale jerseys from china cheap nfl jerseys free shipping cheap nfl jerseys for sale cheap jerseys free shipping wholesale nfl jerseys from china cheap nfl jerseys sale cheap nike nfl jerseys china wholesale jerseys free shipping cheap nfl jerseys wholesale wholesale nfl jerseys online cheap nfl jerseys wholesale china jerseys wholesale cheap coach handbags outlet authentic designer handbags cheap coach handbags outlet cheap coach purses outlet discount coach bags coach bags sale coach purse outlet cheap real coach purses coach handbags sale online coach purse outlet michael kors outlet online store cheap michael kors bags cheap michael kors purse michael kors factory outlet online cheap michael kors handbags cheap michael kors purses michael kors bags outlet online cheap michael kors purse michael kors handbags discount
XML
XML
eXtensible Markup Language
eXtensible Markup Language
sistema per lo scambio di dati tra sistemi informativi

XQuery o XML Query

XQuery interroga dati XML, come SQL interroga un database.
XQuery ha lo stesso modello di dati, le stesse funzioni e gli steesi operatori di XPath
XQuery non è ancora uno standard W3C.
XQuery può essere usato per:

la funzione doc è usata per aprire file XML:

doc("books.xml")

XQuery usa il path per navigare negli elementi:

doc("books.xml")/bookstore/book/title

L'espressione estrae:
<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>

XQuery utilizza predicati per selezionare i dati estratti:

doc("books.xml")/bookstore/book[price<30]/title

Ancora più potente il costrutto FLWOR (For, Let, Where, Order by, Return):

for $x in doc("books.xml")/bookstore/book
where $x/price>30
return $x/title

Con FLWOR si possono ordinare i datii:

for $x in doc("books.xml")/bookstore/book
where $x/price>30
order by $x/title
return $x/title

Si possono aggiungere tag HTML:

<ul>
{
for $x in doc("books.xml")/bookstore/book/title
order by $x
return <li>{$x}</li>
}
</ul>

Si possono selezionare ulteriormente i dati:

<ul>
{
for $x in doc("books.xml")/bookstore/book/title
order by $x
return <li>{data($x)}>{data($x)}</li>
}
</ul>

Esiste if-then-else:

for $x in doc("books.xml")/bookstore/book
return if ($x/@category="CHILDREN")
then <child>{data($x/title)}</child>
else <adult>{data($x/title)}</adult>

In XQuery ci sono 7 tipi di nodo: element, attribute, text, namespace, processing-instruction, comment e document (root).
I valori atomici sono nodi senza figli, nè genitori, detti item

Le relazioni tra i nodi sono: Parent, Children, Sibling, Anx�cestor e Descendant.

La sintassi è semplice:

Gli operatori dii confronto sono:: L'espressione $bookstore//book/@q > 10
è vera se qualunque valore dell'attributo q è maggiore di 10

L'espressione $bookstore//book/@q gt 10
è vera se c'è un solo attributo q e questo è maggiore di 10; se vengono restituiti più valori q, si ha un errore.

Si possono aggiungere elementi HTML:

<html> <body> <h1>Bookstore </h1>
<ul>
{
for $x in doc("books.xml")/bookstore/book
order by $x/title
return <li>{data($x/title)}. Category: {data($x/@category)} </li>
}
</ul>
</body> </html>

E si possono aggiungere attributi agli elementi HTML:

<html> <body> <h1>Bookstore </h1>
<ul>
{
for $x in doc("books.xml")/bookstore/book
order by $x/title
return <li class="{data($x/@category)}">{data($x/title)}</li>
}
</ul>
</body> </html>

Esistono le clausole let e where:

let $x := (1 to 5)
return <test>{$x}</test>

where $x/price>30 and $x/price<100

Esistono le funzioni predefinite:

<name>{uppercase($booktitle)}</name>

E le funzioni definite dall'utente:

declare function local:minPrice(
$price as xs:decimal?,
$discount as xs:decimal?)
AS xs:decimal?
{
let $disc := ($price * $discount) div 100
return ($price - $disc)
};
(: chiamata:)
<minPrice>{local:minPrice($book/price, $book/discount)}</minPrice>

il tutorial W3Schools
il reference W3Schools