这是一个sample数据库,我可以从中extract一本书作为参考。然后trang
和xjc
创建存根:
thufir@dur:~/basex/w3schools$
thufir@dur:~/basex/w3schools$ basex singleBook.xq > book.xml
thufir@dur:~/basex/w3schools$
thufir@dur:~/basex/w3schools$ cat singleBook.xq
let $db := db:open("com.w3schools.books")
for $item in $db
return $item/bookstore/book[3]
thufir@dur:~/basex/w3schools$
thufir@dur:~/basex/w3schools$ cat book.xml
<book category="web">
<title lang="en">XQuery Kick Start</title>
<author>James McGovern</author>
<author>Per Bothner</author>
<author>Kurt Cagle</author>
<author>James Linn</author>
<author>Vaidyanathan Nagarajan</author>
<year>2003</year>
<price>49.99</price>
</book>thufir@dur:~/basex/w3schools$
thufir@dur:~/basex/w3schools$
thufir@dur:~/basex/w3schools$ trang book.xml book.xsd
thufir@dur:~/basex/w3schools$
thufir@dur:~/basex/w3schools$ xjc book.xsd
parsing a schema...
compiling a schema...
generated/Book.java
generated/ObjectFactory.java
generated/Title.java
thufir@dur:~/basex/w3schools$
但是也许直接在原始文件本身上使用JAXB
来解组书籍会更有意义吗?