Your SlideShare is downloading. ×
XML Support: Specifications and Development
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

XML Support: Specifications and Development

1,108

Published on

originally presented at the PostgreSQL Anniversary Summit 2006

originally presented at the PostgreSQL Anniversary Summit 2006

Published in: Technology, News & Politics
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,108
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
17
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. XML Support Specifications and Development Peter Eisentraut PostgreSQL Anniversary Summit July 8–9, 2006 Toronto Peter Eisentraut XML Support
  • 2. XML Support Types of “XML Support”: XML data type and support functions XML export format Mapping XML documents to SQL databases Peter Eisentraut XML Support
  • 3. Specifications ISO/IEC 9075-14:2003 (“XML-Related Specifications” – SQL/XML) ISO/IEC 9075-14:2006, as of 2006-06-12 Already implemented by IBM DB/2, Microsoft SQL Server, OpenLink Virtuoso, Oracle, . . . More information: http://www.sqlx.org/ Peter Eisentraut XML Support
  • 4. XML Data Type CREATE TABLE test ( ..., data xml, ... ); Features: Input checking Support functions Peter Eisentraut XML Support
  • 5. XML Input/Output No string literals as input XMLPARSE ( DOCUMENT|CONTENT value ) --> xml XMLSERIALIZE ( DOCUMENT|CONTENT xmlvalue AS varchar ) --> varchar These could serve as PostgreSQL input/output functions. Peter Eisentraut XML Support
  • 6. XML Support Functions XMLCOMMENT XMLCONCAT XMLELEMENT XMLFOREST XMLPI XMLROOT XMLAGG IS DOCUMENT, IS NOT DOCUMENT Peter Eisentraut XML Support
  • 7. XMLELEMENT Example XMLROOT ( <?xml version=’1.0’ XMLELEMENT ( standalone=’yes’ ?> NAME ’gazonk’, <gazonk name=’val’ XMLATTRIBUTES ( num=’2’> ’val’ AS ’name’, <qux>foo</qux> 1 + 1 AS ’num’ </gazonk> ), XMLELEMENT ( NAME ’qux’, ’foo’ ) ), VERSION ’1.0’, STANDALONE YES ) Peter Eisentraut XML Support
  • 8. XMLFOREST Example SELECT xmlforest ( "FirstName" as "FName", "LastName" as "LName", ’string’ as "str", "Title", "Region" ) FROM "Demo"."demo"."Employees"; might result in <FName>Nancy</FName> <LName>Davolio</LName> <str>string</str> <Title>Sales Representative</Title> <Region>WA</Region> . . . <FName>Anne</FName> <LName>Dodsworth</LName> <str>string</str> <Title>Sales Representative</Title> (1 row per record) Peter Eisentraut XML Support
  • 9. XMLAGG Example SELECT xmlelement (’Emp’, xmlattributes (’Sales Representative’ as "Title"), xmlagg (xmlelement (’Name’, "FirstName", ’ ’, "LastName"))) FROM "Demo"."demo"."Employees" WHERE "Title" = ’Sales Representative’; might result in <Emp Title="Sales Representative"> <Name>Nancy Davolio</Name> <Name>Janet Leverling</Name> <Name>Margaret Peacock</Name> <Name>Michael Suyama</Name> <Name>Robert King</Name> <Name>Anne Dodsworth</Name> </Emp> (1 row) Peter Eisentraut XML Support
  • 10. SQL:2006 More specific XML data type: XML XML(DOCUMENT) XML(CONTENT) XML(SEQUENCE) XML(DOCUMENT(ANY)) XML(DOCUMENT(UNTYPED)) XML(DOCUMENT(XMLSCHEMA ’http://...’)) More functions: XMLDOCUMENT XMLTEXT XMLVALIDATE IS CONTENT IS VALID More options everywhere XQuery Peter Eisentraut XML Support
  • 11. XML Data Type Status Current status: Google Summer of Code project works on SQL:2003 (Nikolay Samokhvalov) Previous patches for support functions available, but work with text data type (Pavel Stehule) Also: Integrate contrib/xml functionality Peter Eisentraut XML Support
  • 12. Implementation Issues Uses libxml (LGPL) Encoding handling Memory management Optional/mandatory? Peter Eisentraut XML Support
  • 13. For the Future XQuery support (SQL:2006) Ctree indexes Peter Eisentraut XML Support
  • 14. XML Export Format Map SQL schema to XML Schema Map database contents to XML document Useful for: Postprocessing using XSLT pg_dump psql? Peter Eisentraut XML Support
  • 15. Mapping Names SQL <identifier> fully-escaped XML name partially-escaped XML name employee EMPLOYEE EMPLOYEE "employee" employee employee "hire date" hire_x0020_date hire_x0020_date "comp_plan" comp_x005F_plan comp_x005F_plan "dept:id" dept_x003A_id dept:id xmlcol _xFFFF_xmlcol xmlcol Peter Eisentraut XML Support
  • 16. XML Schema Mapping Example CREATE TABLE test (a int PRIMARY KEY, b varchar(200)); is mapped to <xsd:complexType name="RowType.catalog.schema.test"> <xsd:sequence> <xsd:element name="a" type="INTEGER"></xsd:element> <xsd:element name="b" type="VARCHAR_200_200" minOccurs="0"></xsd:element> </xsd:sequence> </xsd:complexType> <xsd:complexType name="TableType.catalog.schema.test"> <xsd:sequence> <xsd:element name="row" type="RowType.catalog.schema.test" minOccurs="0" maxOccurs="unbounded" /> </xsd:sequence> </xsd:complexType> Peter Eisentraut XML Support
  • 17. XML Export Format Example <catalogname> <schemaname> <tablename> <row> <colname1>value</colname1> <colname2 xsi:nil=’true’/> ... </row> ... </tablename> ... </schemaname> ... </catalogname> Peter Eisentraut XML Support
  • 18. XML Export Format Status Prototype available Would like XML data type first Where to put it? pg_dump? psql? user-defined functions? Peter Eisentraut XML Support
  • 19. <?end ?> Peter Eisentraut XML Support

×