Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
0b75afda
Commit
0b75afda
authored
Apr 01, 2007
by
Peter Eisentraut
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mapping schemas and databases to XML and XML Schema.
Refactor and document the remaining mapping code.
parent
ae8072a4
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
713 additions
and
87 deletions
+713
-87
doc/src/sgml/func.sgml
doc/src/sgml/func.sgml
+62
-3
src/backend/utils/adt/xml.c
src/backend/utils/adt/xml.c
+627
-82
src/include/catalog/pg_proc.h
src/include/catalog/pg_proc.h
+15
-1
src/include/utils/xml.h
src/include/utils/xml.h
+9
-1
No files found.
doc/src/sgml/func.sgml
View file @
0b75afda
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.37
1 2007/03/25 11:56:01 ishii
Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.37
2 2007/04/01 09:00:24 petere
Exp $ -->
<chapter
id=
"functions"
>
<chapter
id=
"functions"
>
<title>
Functions and Operators
</title>
<title>
Functions and Operators
</title>
...
@@ -11427,7 +11427,7 @@ cursor_to_xml(cursor refcursor, count int, nulls boolean, tableforest boolean, t
...
@@ -11427,7 +11427,7 @@ cursor_to_xml(cursor refcursor, count int, nulls boolean, tableforest boolean, t
query whose text is passed as parameter
query whose text is passed as parameter
<parameter>
query
</parameter>
and maps the result set.
<parameter>
query
</parameter>
and maps the result set.
<function>
cursor_to_xml
</function>
fetches the indicated number of
<function>
cursor_to_xml
</function>
fetches the indicated number of
rows from the cursor specifi
c
ed by the parameter
rows from the cursor specified by the parameter
<parameter>
cursor
</parameter>
. This variant is recommendable if
<parameter>
cursor
</parameter>
. This variant is recommendable if
large tables have to be mapped, because the result value is built
large tables have to be mapped, because the result value is built
up in memory by each function.
up in memory by each function.
...
@@ -11492,7 +11492,7 @@ cursor_to_xml(cursor refcursor, count int, nulls boolean, tableforest boolean, t
...
@@ -11492,7 +11492,7 @@ cursor_to_xml(cursor refcursor, count int, nulls boolean, tableforest boolean, t
values should be included in the output. If true, null values in
values should be included in the output. If true, null values in
columns are represented as
columns are represented as
<screen>
<![CDATA[
<screen>
<![CDATA[
<columname xsi:nil="true"/>
<column
n
ame xsi:nil="true"/>
]]>
</screen>
]]>
</screen>
where
<literal>
xsi
</literal>
is the XML namespace prefix for XML
where
<literal>
xsi
</literal>
is the XML namespace prefix for XML
Schema Instance. An appropriate namespace declaration will be
Schema Instance. An appropriate namespace declaration will be
...
@@ -11530,6 +11530,65 @@ query_to_xml_and_xmlschema(query text, nulls boolean, tableforest boolean, targe
...
@@ -11530,6 +11530,65 @@ query_to_xml_and_xmlschema(query text, nulls boolean, tableforest boolean, targe
</synopsis>
</synopsis>
</para>
</para>
<para>
In addition, the following functions are available to produce
analogous mappings of entire schemas or the entire current
database.
<synopsis>
schema_to_xml(schema name, nulls boolean, tableforest boolean, targetns text)
schema_to_xmlschema(schema name, nulls boolean, tableforest boolean, targetns text)
schema_to_xml_and_xmlschema(schema name, nulls boolean, tableforest boolean, targetns text)
database_to_xml(nulls boolean, tableforest boolean, targetns text)
database_to_xmlschema(nulls boolean, tableforest boolean, targetns text)
database_to_xml_and_xmlschema(nulls boolean, tableforest boolean, targetns text)
</synopsis>
Note that these potentially produce a lot of data, which needs to
be built up in memory. When requesting content mappings of large
schemas or databases, it may be worthwhile to consider mapping the
tables separately instead, possibly even through a cursor.
</para>
<para>
The result of a schema content mapping looks like this:
<screen>
<![CDATA[
<schemaname>
table1-mapping
table2-mapping
...
</schemaname>]]>
</screen>
where the format of a table mapping depends on the
<parameter>
tableforest
</parameter>
parameter as explained above.
</para>
<para>
The result of a database content mapping looks like this:
<screen>
<![CDATA[
<dbname>
<schema1name>
...
</schema1name>
<schema2name>
...
</schema2name>
...
</dbname>]]>
</screen>
where the schema mapping is as above.
</para>
<para>
<para>
As an example for using the output produced by these functions,
As an example for using the output produced by these functions,
<xref
linkend=
"xslt-xml-html"
>
shows an XSLT stylesheet that
<xref
linkend=
"xslt-xml-html"
>
shows an XSLT stylesheet that
...
...
src/backend/utils/adt/xml.c
View file @
0b75afda
This diff is collapsed.
Click to expand it.
src/include/catalog/pg_proc.h
View file @
0b75afda
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.45
2 2007/03/30 18:34:56 mha
Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.45
3 2007/04/01 09:00:25 petere
Exp $
*
*
* NOTES
* NOTES
* The script catalog/genbki.sh reads this file and generates .bki
* The script catalog/genbki.sh reads this file and generates .bki
...
@@ -4100,6 +4100,20 @@ DESCR("map table contents and structure to XML and XML Schema");
...
@@ -4100,6 +4100,20 @@ DESCR("map table contents and structure to XML and XML Schema");
DATA
(
insert
OID
=
2930
(
query_to_xml_and_xmlschema
PGNSP
PGUID
12
100
0
f
f
t
f
s
4
142
"25 16 16 25"
_null_
_null_
"{query,nulls,tableforest,targetns}"
query_to_xml_and_xmlschema
-
_null_
));
DATA
(
insert
OID
=
2930
(
query_to_xml_and_xmlschema
PGNSP
PGUID
12
100
0
f
f
t
f
s
4
142
"25 16 16 25"
_null_
_null_
"{query,nulls,tableforest,targetns}"
query_to_xml_and_xmlschema
-
_null_
));
DESCR
(
"map query result and structure to XML and XML Schema"
);
DESCR
(
"map query result and structure to XML and XML Schema"
);
DATA
(
insert
OID
=
2933
(
schema_to_xml
PGNSP
PGUID
12
100
0
f
f
t
f
s
4
142
"19 16 16 25"
_null_
_null_
"{schema,nulls,tableforest,targetns}"
schema_to_xml
-
_null_
));
DESCR
(
"map schema contents to XML"
);
DATA
(
insert
OID
=
2934
(
schema_to_xmlschema
PGNSP
PGUID
12
100
0
f
f
t
f
s
4
142
"19 16 16 25"
_null_
_null_
"{schema,nulls,tableforest,targetns}"
schema_to_xmlschema
-
_null_
));
DESCR
(
"map schema structure to XML Schema"
);
DATA
(
insert
OID
=
2935
(
schema_to_xml_and_xmlschema
PGNSP
PGUID
12
100
0
f
f
t
f
s
4
142
"19 16 16 25"
_null_
_null_
"{schema,nulls,tableforest,targetns}"
schema_to_xml_and_xmlschema
-
_null_
));
DESCR
(
"map schema contents and structure to XML and XML Schema"
);
DATA
(
insert
OID
=
2936
(
database_to_xml
PGNSP
PGUID
12
100
0
f
f
t
f
s
3
142
"16 16 25"
_null_
_null_
"{nulls,tableforest,targetns}"
database_to_xml
-
_null_
));
DESCR
(
"map database contents to XML"
);
DATA
(
insert
OID
=
2937
(
database_to_xmlschema
PGNSP
PGUID
12
100
0
f
f
t
f
s
3
142
"16 16 25"
_null_
_null_
"{nulls,tableforest,targetns}"
database_to_xmlschema
-
_null_
));
DESCR
(
"map database structure to XML Schema"
);
DATA
(
insert
OID
=
2938
(
database_to_xml_and_xmlschema
PGNSP
PGUID
12
100
0
f
f
t
f
s
3
142
"16 16 25"
_null_
_null_
"{nulls,tableforest,targetns}"
database_to_xml_and_xmlschema
-
_null_
));
DESCR
(
"map database contents and structure to XML and XML Schema"
);
DATA
(
insert
OID
=
2931
(
xmlpath
PGNSP
PGUID
12
1
0
f
f
f
f
i
3
143
"25 142 1009"
_null_
_null_
_null_
xmlpath
-
_null_
));
DATA
(
insert
OID
=
2931
(
xmlpath
PGNSP
PGUID
12
1
0
f
f
f
f
i
3
143
"25 142 1009"
_null_
_null_
_null_
xmlpath
-
_null_
));
DESCR
(
"evaluate XPath expression, with namespaces support"
);
DESCR
(
"evaluate XPath expression, with namespaces support"
);
DATA
(
insert
OID
=
2932
(
xmlpath
PGNSP
PGUID
14
1
0
f
f
f
f
i
2
143
"25 142"
_null_
_null_
_null_
"select pg_catalog.xmlpath($1, $2, NULL)"
-
_null_
));
DATA
(
insert
OID
=
2932
(
xmlpath
PGNSP
PGUID
14
1
0
f
f
f
f
i
2
143
"25 142"
_null_
_null_
_null_
"select pg_catalog.xmlpath($1, $2, NULL)"
-
_null_
));
...
...
src/include/utils/xml.h
View file @
0b75afda
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $PostgreSQL: pgsql/src/include/utils/xml.h,v 1.1
7 2007/03/22 20:14:58 momjian
Exp $
* $PostgreSQL: pgsql/src/include/utils/xml.h,v 1.1
8 2007/04/01 09:00:26 petere
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -47,6 +47,14 @@ extern Datum cursor_to_xmlschema(PG_FUNCTION_ARGS);
...
@@ -47,6 +47,14 @@ extern Datum cursor_to_xmlschema(PG_FUNCTION_ARGS);
extern
Datum
table_to_xml_and_xmlschema
(
PG_FUNCTION_ARGS
);
extern
Datum
table_to_xml_and_xmlschema
(
PG_FUNCTION_ARGS
);
extern
Datum
query_to_xml_and_xmlschema
(
PG_FUNCTION_ARGS
);
extern
Datum
query_to_xml_and_xmlschema
(
PG_FUNCTION_ARGS
);
extern
Datum
schema_to_xml
(
PG_FUNCTION_ARGS
);
extern
Datum
schema_to_xmlschema
(
PG_FUNCTION_ARGS
);
extern
Datum
schema_to_xml_and_xmlschema
(
PG_FUNCTION_ARGS
);
extern
Datum
database_to_xml
(
PG_FUNCTION_ARGS
);
extern
Datum
database_to_xmlschema
(
PG_FUNCTION_ARGS
);
extern
Datum
database_to_xml_and_xmlschema
(
PG_FUNCTION_ARGS
);
typedef
enum
typedef
enum
{
{
XML_STANDALONE_YES
,
XML_STANDALONE_YES
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment