如何从书店XML文件中解组书籍?

时间:2019-10-12 09:16:24

标签: xml xpath jaxb xquery xjc

这是一个sample数据库,我可以从中extract一本书作为参考。然后trangxjc创建存根:

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来解组书籍会更有意义吗?

0 个答案:

没有答案