Re: XML schemas and PG column names - Mailing list pgsql-hackers

From Andrew Dunstan
Subject Re: XML schemas and PG column names
Date
Msg-id 4B23CA05.8020503@dunslane.net
Whole thread Raw
In response to Re: XML schemas and PG column names  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: XML schemas and PG column names  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: XML schemas and PG column names  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-hackers

Tom Lane wrote:
> Andrew Dunstan <andrew@dunslane.net> writes:
>   
>> I propose that we annotate the schema section RowType elements with the 
>> original names, so we would have something like this in the schema section:
>>     
>  
> 1. Is that legal per the SQL/XML spec?
>   

It is certainly legal per XML and XSD specs, and the SQL/XML spec has 
annotations using appinfo elements. It would be rather surprising if the 
SQL/XML spec forbade annotations such as I propose. The spec is 
mind-bogglingly impenetrable, though. Perhaps Peter or Nicholas might know.

> 2. What happens when the column name contains characters that would have
> to be escaped, such as "<" --- haven't you just replaced one de-escaping
> problem with another?
>
>             
>   

No. say the name is "foo & bar < baz". Then the annotation would be:
   <pg:column-name>foo & bar < baz</pg:column-name>

But the difference is that the XML processor will automatically unescape 
this value (and re-escape it on output if necessary). The user won't 
have to do anything (or shouldn't if their XML processor is worth 
anything at all). So in a stylesheet, I'd be able to do something like:
   <xsl:for-each select="//[complexType[@name="RowType"]//pg:column-name">      <th><xsl:value-of select="." /></th>
</xsl:for-each>

and it would just Do The Right Thing. (If we didn't want the output 
re-escaped, say when the otuput format was not XML or HTML, we could 
make it do that too).

cheers

andrew



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: XML schemas and PG column names
Next
From: Magnus Hagander
Date:
Subject: Winflex