【发布时间】:2016-04-08 23:38:59
【问题描述】:
我在 MarkLogic 数据库中加载了以下 XML 文档:
<x:books xmlns:x="urn:books">
<book id="bk001">
<author>Writer</author>
<title>The First Book</title>
<genre>Fiction</genre>
<price>44.95</price>
<pub_date>2000-10-01</pub_date>
<review>An amazing story of nothing.</review>
</book>
<book id="bk002">
<author>Poet</author>
<title>The Poet's First Poem</title>
<genre>Poem</genre>
<price>24.95</price>
<review>Least poetic poems.</review>
</book>
</x:books>
我是 XQuery 的新手。当我从 SQL 数据库中检索 XML 文档中的值时,我将如何检索它?
输出:
BookID | Author | Title | Genre | price | pub_date | review
bk001 | Writer | The First Book | Fiction | 44.95 | 2000-10-01
bk002 | Poet | The Poet's First Poem | Poem | 24.95 | Least poetic poems.
注意:不需要管道分隔,而是一些集合列表。
有人可以分享一些链接或帮助我编写这个 XQuery 吗?我是新手。
【问题讨论】:
-
请注意,不同的项目(书籍)通常应位于不同的文档中。如果您有一个带有书根的文档,并且其下有很多书本元素,则搜索和索引功能将无法正常工作。 MarkLogic data modeling guidelines 将是有用的阅读。
标签: xml xsd xquery marklogic xquery-sql