{"id":194849,"date":"2020-07-08T08:18:04","date_gmt":"2020-07-08T00:18:04","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=194849"},"modified":"2020-06-27T11:19:32","modified_gmt":"2020-06-27T03:19:32","slug":"xquery-add-elements","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/xquery-add-elements.html","title":{"rendered":"XQuery \u6dfb\u52a0\u5143\u7d20 \u548c\u5c5e\u6027"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u89e3\u91ca XQuery \u6700\u4f73\u65b9\u5f0f\u662f\u8fd9\u6837\u8bb2\uff1aXQuery \u76f8\u5bf9\u4e8e XML \u7684\u5173\u7cfb\uff0c\u7b49\u540c\u4e8e SQL \u76f8\u5bf9\u4e8e\u6570\u636e\u5e93\u8868\u7684\u5173\u7cfb\u3002XQuery \u88ab\u8bbe\u8ba1\u7528\u6765\u67e5\u8be2 XML \u6570\u636e - \u4e0d\u4ec5\u4ec5\u9650\u4e8e XML \u6587\u4ef6\uff0c\u8fd8\u5305\u62ec\u4efb\u4f55\u53ef\u4ee5 XML \u5f62\u6001\u5448\u73b0\u7684\u6570\u636e\uff0c\u5305\u62ec\u6570\u636e\u5e93\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\"<\/p>\n

\u5411\u7ed3\u679c\u6dfb\u52a0\u5143\u7d20\u548c\u5c5e\u6027<\/strong><\/div>\n

\u6b63\u5982\u5728\u524d\u9762\u4e00\u8282\u770b\u5230\u7684\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u7ed3\u679c\u4e2d\u5f15\u7528\u8f93\u5165\u6587\u4ef6\u4e2d\u7684\u5143\u7d20\u548c\u5c5e\u6027\uff1a<\/p>\n

\r\nfor $x in doc(\"books.xml\")\/bookstore\/book\/title\r\norder by $x\r\nreturn $x<\/pre>\n

\u4e0a\u9762\u7684 XQuery \u8868\u8fbe\u5f0f\u4f1a\u5728\u7ed3\u679c\u4e2d\u5f15\u7528 title \u5143\u7d20\u548c lang \u5c5e\u6027\uff0c\u5c31\u50cf\u8fd9\u6837\uff1a<\/p>\n

<title lang=\"en\">Everyday Italian<\/title>\r\n<title lang=\"en\">Harry Potter<\/title>\r\n<title lang=\"en\">Learning XML<\/title>\r\n<title lang=\"en\">XQuery Kick Start<\/title><\/pre>\n

\u4ee5\u4e0a XQuery \u8868\u8fbe\u5f0f\u8fd4\u56de title \u5143\u7d20\u7684\u65b9\u5f0f\u548c\u5b83\u4eec\u5728\u8f93\u5165\u6587\u6863\u4e2d\u88ab\u63cf\u8ff0\u7684\u65b9\u5f0f\u7684\u76f8\u540c\u7684\u3002
\n\u73b0\u5728\u6211\u4eec\u8981\u5411\u7ed3\u679c\u6dfb\u52a0\u6211\u4eec\u81ea\u5df1\u7684\u5143\u7d20\u548c\u5c5e\u6027\uff01<\/p>\n

\u6dfb\u52a0 HTML \u5143\u7d20\u548c\u6587\u672c<\/strong><\/div>\n

\u73b0\u5728\uff0c\u6211\u4eec\u8981\u5411\u7ed3\u679c\u6dfb\u52a0 HTML \u5143\u7d20\u3002\u6211\u4eec\u4f1a\u628a\u7ed3\u679c\u653e\u5728\u4e00\u4e2a HTML \u5217\u8868\u4e2d\uff1a<\/p>\n

<html>\r\n<body>\r\n\r\n<h1>Bookstore<\/h1>\r\n\r\n<ul>\r\n{\r\nfor $x in doc(\"books.xml\")\/bookstore\/book\r\norder by $x\/title\r\nreturn <li>{data($x\/title)}. Category: {data($x\/@category)}<\/li>\r\n}\r\n<\/ul>\r\n\r\n<\/body>\r\n<\/html><\/pre>\n

\u4ee5\u4e0a XQuery \u8868\u8fbe\u5f0f\u4f1a\u751f\u6210\u4e0b\u9762\u7684\u7ed3\u679c\uff1a<\/p>\n

<html>\r\n<body>\r\n\r\n<h1>Bookstore<\/h1>\r\n\r\n<ul>\r\n<li>Everyday Italian. Category: COOKING<\/li>\r\n<li>Harry Potter. Category: CHILDREN<\/li>\r\n<li>Learning XML. Category: WEB<\/li>\r\n<li>XQuery Kick Start. Category: WEB<\/li>\r\n<\/ul>\r\n\r\n<\/body>\r\n<\/html><\/pre>\n
\u5411 HTML \u5143\u7d20\u6dfb\u52a0\u5c5e\u6027<\/strong><\/div>\n

\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u8981\u628a category \u5c5e\u6027\u4f5c\u4e3a HTML \u5217\u8868\u4e2d\u7684 class \u5c5e\u6027\u6765\u4f7f\u7528\uff1a<\/p>\n

<html>\r\n<body>\r\n\r\n<h1>Bookstore<\/h1>\r\n\r\n<ul>\r\n{\r\nfor $x in doc(\"books.xml\")\/bookstore\/book\r\norder by $x\/title\r\nreturn <li class=\"{data($x\/@category)}\">{data($x\/title)}<\/li>\r\n}\r\n<\/ul>\r\n\r\n<\/body>\r\n<\/html><\/pre>\n

\u4e0a\u9762\u7684 XQuery \u8868\u8fbe\u5f0f\u53ef\u751f\u6210\u4ee5\u4e0b\u7ed3\u679c\uff1a<\/p>\n

<html>\r\n<body>\r\n<h1>Bookstore<\/h1>\r\n\r\n<ul>\r\n<li class=\"COOKING\">Everyday Italian<\/li>\r\n<li class=\"CHILDREN\">Harry Potter<\/li>\r\n<li class=\"WEB\">Learning XML<\/li>\r\n<li class=\"WEB\">XQuery Kick Start<\/li>\r\n<\/ul>\r\n\r\n<\/body>\r\n<\/html><\/pre>\n","protected":false},"excerpt":{"rendered":"

\u6b63\u5982\u5728\u524d\u9762\u4e00\u8282\u770b\u5230\u7684\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u7ed3\u679c\u4e2d\u5f15\u7528\u8f93\u5165\u6587\u4ef6\u4e2d\u7684\u5143\u7d20\u548c\u5c5e\u6027\uff1a for $x in doc(“books. […]<\/p>\n","protected":false},"author":321,"featured_media":194844,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-194849","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/194849","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/321"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=194849"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/194849\/revisions"}],"predecessor-version":[{"id":194851,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/194849\/revisions\/194851"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/194844"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=194849"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=194849"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=194849"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}