Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
614e4235
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
614e4235
编写于
3月 05, 2004
作者:
B
Bruce Momjian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add missing xml files.
上级
31f4b59a
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
141 addition
and
0 deletion
+141
-0
contrib/xml/Makefile
contrib/xml/Makefile
+13
-0
contrib/xml/README.pgxml
contrib/xml/README.pgxml
+118
-0
contrib/xml/pgxml.sql.in
contrib/xml/pgxml.sql.in
+10
-0
未找到文件。
contrib/xml/Makefile
0 → 100644
浏览文件 @
614e4235
# $Header: /cvsroot/pgsql/contrib/xml/Attic/Makefile,v 1.7 2004/03/05 04:10:11 momjian Exp $
subdir
=
contrib/xml
top_builddir
=
../..
include
$(top_builddir)/src/Makefile.global
MODULE_big
=
pgxml_dom
OBJS
=
pgxml_dom.o
SHLIB_LINK
=
-lxml2
DATA_built
=
pgxml_dom.sql
DOCS
=
README.pgxml
include
$(top_srcdir)/contrib/contrib-global.mk
contrib/xml/README.pgxml
0 → 100644
浏览文件 @
614e4235
This package contains some simple routines for manipulating XML
documents stored in PostgreSQL. This is a work-in-progress and
somewhat basic at the moment (see the file TODO for some outline of
what remains to be done).
At present, two modules (based on different XML handling libraries)
are provided.
Prerequisite:
pgxml.c:
expat parser 1.95.0 or newer (http://expat.sourceforge.net)
or
pgxml_dom.c:
libxml2 (http://xmlsoft.org)
The libxml2 version provides more complete XPath functionality, and
seems like a good way to go. I've left the old versions in there for
comparison.
Compiling and loading:
----------------------
The Makefile only builds the libxml2 version.
To compile, just type make.
Then you can use psql to load the two function definitions:
\i pgxml_dom.sql
Function documentation and usage:
---------------------------------
pgxml_parse(text) returns bool
parses the provided text and returns true or false if it is
well-formed or not. It returns NULL if the parser couldn't be
created for any reason.
pgxml_xpath (XQuery functions) - differs between the versions:
pgxml.c (expat version) has:
pgxml_xpath(text doc, text xpath, int n) returns text
parses doc and returns the cdata of the nth occurence of
the "simple path" entry.
However, the remainder of this document will cover the pgxml_dom.c version.
pgxml_xpath(text doc, text xpath, text toptag, text septag) returns text
evaluates xpath on doc, and returns the result wrapped in
<toptag>...</toptag> and each result node wrapped in
<septag></septag>. toptag and septag may be empty strings, in which
case the respective tag will be omitted.
Example:
Given a table docstore:
Attribute | Type | Modifier
-----------+---------+----------
docid | integer |
document | text |
containing documents such as (these are archaeological site
descriptions, in case anyone is wondering):
<?XML version="1.0"?>
<site provider="Foundations" sitecode="ak97" version="1">
<name>Church Farm, Ashton Keynes</name>
<invtype>watching brief</invtype>
<location scheme="osgb">SU04209424</location>
</site>
one can type:
select docid,
pgxml_xpath(document,'//site/name/text()','','') as sitename,
pgxml_xpath(document,'//site/location/text()','','') as location
from docstore;
and get as output:
docid | sitename | location
-------+--------------------------------------+------------
1 | Church Farm, Ashton Keynes | SU04209424
2 | Glebe Farm, Long Itchington | SP41506500
3 | The Bungalow, Thames Lane, Cricklade | SU10229362
(3 rows)
or, to illustrate the use of the extra tags:
select docid as id,
pgxml_xpath(document,'//find/type/text()','set','findtype')
from docstore;
id | pgxml_xpath
----+-------------------------------------------------------------------------
1 | <set></set>
2 | <set><findtype>Urn</findtype></set>
3 | <set><findtype>Pottery</findtype><findtype>Animal bone</findtype></set>
(3 rows)
Which produces a new, well-formed document. Note that document 1 had
no matching instances, so the set returned contains no
elements. document 2 has 1 matching element and document 3 has 2.
This is just scratching the surface because XPath allows all sorts of
operations.
Note: I've only implemented the return of nodeset and string values so
far. This covers (I think) many types of queries, however.
John Gray <jgray@azuli.co.uk> 16 August 2001
contrib/xml/pgxml.sql.in
0 → 100644
浏览文件 @
614e4235
-- SQL for XML parser
-- Adjust this setting to control where the objects get created.
SET search_path TO public;
CREATE OR REPLACE FUNCTION pgxml_parse(text) RETURNS boolean
AS 'MODULE_PATHNAME' LANGUAGE c STRICT;
CREATE OR REPLACE FUNCTION pgxml_xpath(text, text, text, text) RETURNS text
AS 'MODULE_PATHNAME' LANGUAGE c STRICT;
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录