Re: XML question - Mailing list pgsql-general

From Manuel Sugawara
Subject Re: XML question
Date
Msg-id m3u21u3esw.fsf@dep1.fciencias.unam.mx
Whole thread Raw
In response to Re: XML question  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-general
Peter Eisentraut <peter_e@gmx.net> writes:

> Tony Grant writes:
>
> >     - what is the _most popular_ way of storing XML data in posgresql?
> >
> >     - what is the _best_ way of stocking XML data in postgresql?
>
> 'text' is probably the only possible and reasonable answer to either of
> these (except for 'varchar').

I'm using xml-schema to specify my schema, postgreSQL to store the
data and some scripts to do the translation.  The idea is: every
element that may appear in the document is stored in a table which has
the same attributes as the element, ie if you have the definition of
the element as follows:

<complexType name="student">
  <attribute name="id" type="xs:integer"/>
  <attribute name="name" type="xs:normalizedString"/>
</complexType>

it will be mapped into postgres as:

create table student
(
  id primary key,
  name text
);

so, when I read an element of the form:

<student id="10" name="masm"/>

it is stored into postgres using something like:

insert into student (id,name) values (10,xs_normalize('masm'));

Ok, this may get more complex when you use sequence's inside the
element definition, but it is done using references. This
idea may not work with mixed content, or complex documents as html,
but it does work for me :-)

hth,
Manuel.

pgsql-general by date:

Previous
From: Stephan Richter
Date:
Subject: setting PGDATESTYLE
Next
From: Tom Lane
Date:
Subject: Re: Help with: my bits moved right off the end of the world!