Re: returning PGresult as xml

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: returning PGresult as xml
Date: 2004-01-27 13:51:30
Message-ID: 40166CE2.2060703@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Scott Lamb wrote:

> On Jan 25, 2004, at 3:07 AM, Brian Moore wrote:
>
>> <PGresult num_rows='1' num_cols='2'>
>> <col_desc num='0' type='int4' format='text' name='foo' />
>> <col_desc num='1' type='int4' format='text' name='bar' />
>> <row num='0'>
>> <col num='0'>1</col>
>> <col num='1'>2</col>
>> </row>
>> </PGresult>
>
>
> How would you filter for a column in XSLT based on column name with
> this schema? It's certainly not trivial. I have similar code, and I
> included the column name as an attribute in each column element for
> this reason.

Close to trivial if you set up a key on the col-desc elements, I should
think. Maybe something like:

<xsl:key name="coldesc" match="col-desc" use="@num" />

...

<xsl:for-each select=" key('coldesc',@num)/@name = 'colname' " >
...

Alternatively you can get there using the parent and preceding-sibling
axes, but it's less clear.

cheers

andrew

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2004-01-27 14:12:27 Re: Recursive optimization of IN subqueries
Previous Message Robert Treat 2004-01-27 13:10:32 Re: LWLock/ShmemIndex startup question