MarkLogic 初学
来源:互联网 发布:surface book mac 编辑:程序博客网 时间:2024/05/01 20:03
MarkLogic -> Groups ->Default -> App Servers -> App Server分为三类:
- Http
- WebDAV
- XDBC
其中:
Root 就是数据库根目录
Module是放的xquery,而xquery其实就是view
Database才是放的数据,即xml文件
//insert a xml into db
load.xqy
xquery version "1.0-ml";(: load.xqy :)xdmp:document-insert("books.xml",<books xmlns="http://www.marklogic.com/ns/gs-books"><book bookid="1"><title>A Quick Path to an Application</title><author><last>Smith</last><first>Jim</first></author><publisher>Scribblers Press</publisher><isbn>1494-3930392-3</isbn><abstract>This book describes in detail the power of how to use XQuery to build powerful web applications that are built on the MarkLogic Server platform.</abstract></book></books>),<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Database loaded</title></head><body><b>Source XML Loaded</b><p>The source XML has been successfully loaded into the database</p></body></html>
dump.xqy
xquery version "1.0-ml";(: dump.xqy :)declare namespace bk = "http://www.marklogic.com/ns/gs-books";<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Database dump</title></head><body><b>XML Content</b>{for $book in doc("books.xml")/bk:books/bk:bookreturn<pre>Title: { $book/bk:title/text() }Author: { ($book/bk:author/bk:first/text(), " ",$book/bk:author/bk:last/text()) }Publisher: { $book/bk:publisher/text() }</pre>}<a href="update-form.xqy">Update Publisher</a></body></html>
update-form.xqy
xquery version "1.0-ml";(: update-form.xqy :)declare namespace bk="http://www.marklogic.com/ns/gs-books";<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Change Publisher</title></head><body>{let $book := doc("books.xml")/bk:books/bk:book[1]return<form action="update-write.xqy"><input type="hidden" name="bookid" value="{ $book/@bookid }"/><p><b>Change publisher for book <i>{ $book/bk:title/text() }</i>:</b></p><input type="text" name="publisher"value="{ $book/bk:publisher/text() }"/><input type="submit" value="Update publisher"/></form>}</body></html>
update-write.xqy
xquery version "1.0-ml";(: update-write.xqy :)declare namespace bk="http://www.marklogic.com/ns/gs-books";declare function local:updatePublisher(){if (doc("books.xml")) thenlet $bookid := xdmp:get-request-field("bookid")let $publisher := xdmp:get-request-field("publisher")let $b := doc("books.xml")/bk:books/bk:book[@bookid = $bookid]returnif ($b) then(xdmp:node-replace($b/bk:publisher,<bk:publisher>{ $publisher }</bk:publisher>),xdmp:redirect-response("dump.xqy"))else<span>Could not locate book with bookid { $bookid }.</span>else<span>Unable to access parent XML document.</span>};<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Update In Process</title></head><body>Attempting to complete update and redirect browser to detail page.<p>If you are seeing this page, either the redirect has failedor the update has failed. The update has failed if there isa reason provided below:<br/>{ local:updatePublisher() }</p></body></html>
- MarkLogic 初学
- Marklogic search development
- Marklogic search development -1.Developing Search Applications in MarkLogic Server
- Marklogic学习 由浅入深(2)—— 安装Marklogic Server
- Marklogic学习 由浅入深(5)-- Marklogic概念解析
- Marklogic学习 由浅入深(B)—— Marklogic vs. Hadoop
- Marklogic学习 由浅入深(D)—— Marklogic vs. Oracle
- MarkLogic中的Score和Relevance (一)
- MarkLogic中的Score和Relevance (二)
- Marklogic 一个递归方法的实现
- Marklogic wildcard search(通配符搜索)笔记
- Marklogic学习 —— 灵活的数据模型
- Marklogic学习 —— XQuery语法
- Marklogic学习 —— 日志Log处理
- Marklogic学习 —— XQuery语法基础
- Marklogic学习 —— ACID事务
- Marklogic学习 —— 安装Marklogic9
- 初学...
- 使用NSOperation和NSOperationQueue用来实现多线程
- 学习笔记(十三)
- create table #temptable 临时表 和 declare @bianliang table ()表变量
- DLL 作为 MDIChild (子窗体)
- pl/sql错误处理
- MarkLogic 初学
- greenplum plpythonu
- IOS学习之番外:开发中的那些琐碎
- 进程隐藏与进程保护(SSDT Hook 实现)(一)
- SQL SERVER 跨服务器查询
- web.xml配置struts2之后访问jsp页面报Http 404错误
- SQL2008 用户'sa'登录失败(错误18456)图文解决方法
- T-SQL 教程
- HBase Java API详解