How is XQUERY actually used?

I read a lot of XQUERY tutorials on the website. Almost all of them teach me XQUERY syntax. Say I understand the XQUERY syntax, how am I going to actually implement XQUERY on my site?

For example, I have book.xml :

<?xml version="1.0" encoding="iso-8859-1" ?>
<books>
<book>
   <title>Doraemon</title>
   <authorid>1</authorid>
</book>
<book>
   <title>Ultraman</title>
   <authorid>2</authorid>
</book>
</books>

Then I have author.xml

<?xml version="1.0" encoding="iso-8859-1" ?>
<authors>
<author id="1">Mr A</author>
<author id="2">Mr B</author>
</authors>

I want to generate HTML that looks like this:

<table>
    <tr>  <td>Title</td>     <td>Author</td> </tr>
    <tr>  <td>Doraemon</td>  <td>Mr A</td>   </tr>
    <tr>  <td>Ultraman</td>  <td>Mr B</td>   </tr>
</table>

Please show me an example. Or any site that I can link to. Many thanks.

+5
source share
7 answers
(: file: titles.xqy :)
<table>
<tr><th>title</th><th>author</th></tr>
{
let $books-doc := doc("books.xml")
let $authors-doc := doc("authors.xml")
for $b in $books-doc//book,
    $a in $authors-doc//author
where $a/@id = $b/authorid
return 
<tr>
    <td>{$b/title/text()}</td>
    <td>{$a/text()}</td>
</tr>
}

+3
source

xml html. , XQuery , XSTL , - . . - XQuery.

+3

XQuery SQL, . SQL (MS SQL Server, Oracle, Sybase, MySQL, PostreSQL, SQLite ..), XQuery XML (MARKLogic, Sedena, Qexo, Qizx/db ..).

MARKLogic XDB HTTP-. - MARKLogic XDB, HTTP- XQuery HTML.

MARKLogic ( 100 ) .

+2

, , XQuery.

XML- XML HTML, XSL. XSL , XQuery. , , XSL .

XQuery , XML, . XQuery - XML , XSL .

+1

XQuery -:

:

, API, , , XML . : Zorba API PHP, API XQuery Java ..

XML- XML, XQuery, XQuery . . BaseX - .

:

, HTML- XML-. XQuery, Zorba, Saxon, BaseX, CLI. API.

, XML- .

, , XQuery , , HTML- XQuery, HTML XML, .

:

XML HTML, XQuery -. , , - XML-. , XML-, . XQuery Update Facility.

, . , , .

+1
<table>
<tr><td>Title<td><td>Author<td></tr>
{
    let $authordoc := fn:doc("author.xml")
    for $book in fn:doc("book.xml")/books/book
    return
        <tr>
                <td>{ $book/title }</td>
                <td>{ $authordoc/authors/author/[@id eq $book/authorid] }</td>
        </tr>
}
</table>

ps: / ,

0

All Articles