Re: returning PGresult as xml - Mailing list pgsql-hackers

From Andrew Dunstan
Subject Re: returning PGresult as xml
Date
Msg-id 40166CE2.2060703@dunslane.net
Whole thread Raw
In response to Re: returning PGresult as xml  (Scott Lamb <slamb@slamb.org>)
Responses building plperl on 7.4.1  (Dave Cramer <pg@fastcrypt.com>)
index scan with functional indexes  (Dave Cramer <pg@fastcrypt.com>)
List 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





pgsql-hackers by date:

Previous
From: Scott Lamb
Date:
Subject: Re: returning PGresult as xml
Next
From: "Simon Riggs"
Date:
Subject: Re: Recursive optimization of IN subqueries