Generating an XSD file from an existing database

Started by Blake McBrideover 10 years ago4 messagesgeneral
Jump to latest
#1Blake McBride
blake1024@gmail.com

Greetings,

I need an XML specification for my exiting schema - an XSD file. Reading
the docs I see schema_to_xml but I do not understand:

A. Will that produce the XSD file I seek?

B. I do not understand the documentation. Can I do this through psql? I
need an exact example if possible.

Thank you.

Blake McBride

#2Rob Sargent
robjsargent@gmail.com
In reply to: Blake McBride (#1)
Re: Generating an XSD file from an existing database

On Dec 6, 2015, at 2:30 PM, Blake McBride <blake1024@gmail.com> wrote:

Greetings,

I need an XML specification for my exiting schema - an XSD file. Reading the docs I see schema_to_xml but I do not understand:

A. Will that produce the XSD file I seek?

B. I do not understand the documentation. Can I do this through psql? I need an exact example if possible.

Thank you.

Blake McBride

Yes, those functions are available through psql
select schema_to_xml(<arglist>)
and
select schema_to_xmlschema(<arglist>) are what you’re after.

Redirect the output of each into separate files.

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#3Blake McBride
blake1024@gmail.com
In reply to: Rob Sargent (#2)
Re: Generating an XSD file from an existing database

On Sun, Dec 6, 2015 at 3:47 PM, Rob Sargent <robjsargent@gmail.com> wrote:

On Dec 6, 2015, at 2:30 PM, Blake McBride <blake1024@gmail.com> wrote:

Greetings,

I need an XML specification for my exiting schema - an XSD file.

Reading the docs I see schema_to_xml but I do not understand:

A. Will that produce the XSD file I seek?

B. I do not understand the documentation. Can I do this through psql?

I need an exact example if possible.

Thank you.

Blake McBride

Yes, those functions are available through psql
select schema_to_xml(<arglist>)
and
select schema_to_xmlschema(<arglist>) are what you’re after.

Redirect the output of each into separate files.

Thanks. My problem is understanding the arguments. I am hoping to get an
exact example.

Server: localhost
Database: wmco
Schema: public

Once I am in psql, exactly what do I type? (I just don't understand the
docs.)

Thank you!

Blake

#4Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Blake McBride (#3)
Re: Generating an XSD file from an existing database

On 12/06/2015 01:59 PM, Blake McBride wrote:

On Sun, Dec 6, 2015 at 3:47 PM, Rob Sargent <robjsargent@gmail.com
<mailto:robjsargent@gmail.com>> wrote:

On Dec 6, 2015, at 2:30 PM, Blake McBride <blake1024@gmail.com

<mailto:blake1024@gmail.com>> wrote:

Greetings,

I need an XML specification for my exiting schema - an XSD file.

Reading the docs I see schema_to_xml but I do not understand:

A. Will that produce the XSD file I seek?

B. I do not understand the documentation. Can I do this through

psql? I need an exact example if possible.

Thank you.

Blake McBride

Yes, those functions are available through psql
select schema_to_xml(<arglist>)
and
select schema_to_xmlschema(<arglist>) are what you’re after.

Redirect the output of each into separate files.

Thanks. My problem is understanding the arguments. I am hoping to get
an exact example.

Server: localhost
Database: wmco
Schema: public

Once I am in psql, exactly what do I type? (I just don't understand the
docs.)

<WARNING> Will produce a big file. On a relatively small database the
below created a 5.6 G file <WARNING>

\o schema_file.xml
select schema_to_xml('public', 't', 't', 'text');
\o

Explanation of above:
\o redirects further commands to the file specified.

Run xml function

\o resets output to stdout

If you want to use the table form, then:

\o cell_per.xml
select table_to_xml('cell_per'::regclass, 't', 't', 'text');
\o

Thank you!

Blake

--
Adrian Klaver
adrian.klaver@aklaver.com

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general