Schreiben Sie einen XQuery-Ausdruck, der aus den Daten eine standardkonforme XHTML-Datei erzeugt, in der die Bücherdaten tabellarisch aufgelistet werden.
Musterlösung vom 29.06.2008:
<?xml version="1.0" ?> <!DOCTYPE catalogue SYSTEM "books.dtd"> <catalogue> <book type="broschiert" lang="de"> <authors> <author sex="m"> <firstname>Oliver</firstname> <lastname>Vornberger</lastname> </author> <author sex="m"> <firstname>Patrick</firstname> <lastname>Fox</lastname> </author> </authors> <title edition="10">Datenbanksysteme</title> <isbn /> <publisher>Selbstverlag der Universitaet Osnabrueck</publisher> <price currency="EUR">7,50</price> </book> <book type="broschiert" lang="de"> <authors> <author sex="m"> <firstname>Alfons</firstname> <lastname>Kemper</lastname> </author> <author sex="m"> <firstname>Andre</firstname> <lastname>Eickler</lastname> </author> </authors> <title edition="4">Datenbanksysteme - Eine Einfuehrung</title> <isbn>3-486-25706-4</isbn> <publisher>Oldenbourg</publisher> <price currency="EUR">39,80</price> </book> <book type="broschiert" lang="en"> <authors> <author sex="m"> <firstname>Elliotte Rusty</firstname> <lastname>Harold</lastname> </author> <author sex="m"> <firstname>Scott</firstname> <lastname>Means</lastname> </author> </authors> <title edition="1">XML in a Nutshell</title> <isbn>0-596-00058-8</isbn> <publisher>O'Reilly</publisher> <price currency="USD">29,95</price> </book> </catalogue>
<!ELEMENT author ( firstname, lastname ) > <!ATTLIST author sex ( m | f ) #REQUIRED > <!ELEMENT authors ( author+ ) > <!ELEMENT book ( authors, title, isbn, publisher, price ) > <!ATTLIST book lang CDATA #REQUIRED > <!ATTLIST book type ( broschiert | gebunden | geheftet ) #REQUIRED > <!ELEMENT catalogue ( book+ ) > <!ELEMENT firstname ( #PCDATA ) > <!ELEMENT isbn ( #PCDATA ) > <!ELEMENT lastname ( #PCDATA ) > <!ELEMENT price ( #PCDATA ) > <!ATTLIST price currency CDATA #REQUIRED > <!ELEMENT publisher ( #PCDATA ) > <!ELEMENT title ( #PCDATA ) > <!ATTLIST title edition CDATA #IMPLIED >
<html> <head> <title>Buecherliste</title> </head> <body> <table>{ for $buch in /catalogue/book let $autoren := data($buch//author/firstname | $buch//author/lastname) return <tr> <td>{$autoren}</td> <td>{data($buch/title)}</td> <td>{data($buch/isbn)}</td> <td>{data($buch/publisher)}</td> <td>{concat(data($buch/price), ' ', data($buch/price/@currency))}</td> </tr> } </table> </body> </html>