SlideShare una empresa de Scribd logo
1 de 25
Descargar para leer sin conexión
The Road to the XML Type
  Current and Future Developments


Nikolay Samokhvalov   Peter Eisentraut



            PGCon 2007
Current Developments
                          Future Developments
                                   Conclusion


Outline



  1   Current Developments

  2   Future Developments

  3   Conclusion




          Nikolay Samokhvalov, Peter Eisentraut   The Road to the XML Type
Current Developments     XML Data Type
                          Future Developments     XML Publishing
                                   Conclusion     XML Export


Outline



  1   Current Developments

  2   Future Developments

  3   Conclusion




          Nikolay Samokhvalov, Peter Eisentraut   The Road to the XML Type
Current Developments     XML Data Type
                          Future Developments     XML Publishing
                                   Conclusion     XML Export


New Features



  Target for PostgreSQL 8.3:
      XML Data Type
      XML Publishing
      XML Export
      SQL:2003 conformance
      XPath




          Nikolay Samokhvalov, Peter Eisentraut   The Road to the XML Type
Current Developments     XML Data Type
                          Future Developments     XML Publishing
                                   Conclusion     XML Export


Outline


  1   Current Developments
        XML Data Type
        XML Publishing
        XML Export

  2   Future Developments

  3   Conclusion




          Nikolay Samokhvalov, Peter Eisentraut   The Road to the XML Type
Current Developments     XML Data Type
                            Future Developments     XML Publishing
                                     Conclusion     XML Export


XML Data Type

  CREATE TABLE test (
      ...,
      data xml,
      ...
  );

  Features:
      Input checking
      Support functions
  Issues:
      Internal storage format (plain text)
      Encoding handling

            Nikolay Samokhvalov, Peter Eisentraut   The Road to the XML Type
Current Developments     XML Data Type
                         Future Developments     XML Publishing
                                  Conclusion     XML Export


Using the XML Type
  Bizarre SQL way:

  INSERT INTO test VALUES (
      ...,
      XMLPARSE (DOCUMENT ’<foo>...</foo>’),
      ...
  );

  SELECT XMLSERIALIZE (DOCUMENT data AS varchar)
      FROM test;

  Simple PostgreSQL way:

  INSERT INTO test VALUES (... , ’<foo>...</foo>’, ...);

  SELECT data FROM test;

         Nikolay Samokhvalov, Peter Eisentraut   The Road to the XML Type
Current Developments     XML Data Type
                         Future Developments     XML Publishing
                                  Conclusion     XML Export


XML Type Oddities



     No comparison operators
     To retrieve, use:
         Cast to text, or
         XPath, or
         Other key column
     To index, use:
         Cast to text, or
         XPath




         Nikolay Samokhvalov, Peter Eisentraut   The Road to the XML Type
Current Developments     XML Data Type
                          Future Developments     XML Publishing
                                   Conclusion     XML Export


Outline


  1   Current Developments
        XML Data Type
        XML Publishing
        XML Export

  2   Future Developments

  3   Conclusion




          Nikolay Samokhvalov, Peter Eisentraut   The Road to the XML Type
Current Developments     XML Data Type
                         Future Developments     XML Publishing
                                  Conclusion     XML Export


Producing XML Content

  The old way?

  SELECT ’<record id="’ || id || ’"><value>’
         || ad_hoc_escape_func(value)
         || ’</value></record>’
      FROM tab;

  The new way:

  SELECT XMLELEMENT(NAME record,
                    XMLATTRIBUTES(id),
                    XMLELEMENT(NAME value, value))
      FROM tab;



         Nikolay Samokhvalov, Peter Eisentraut   The Road to the XML Type
Current Developments     XML Data Type
                         Future Developments     XML Publishing
                                  Conclusion     XML Export


XMLELEMENT Example
                                                  Result:
 SQL:
                                                  <?xml version=’1.0’
 XMLROOT (                                              standalone=’yes’ ?>
   XMLELEMENT (                                   <gazonk name=’val’
      NAME ’gazonk’,                                      num=’2’>
      XMLATTRIBUTES (                               <qux>foo</qux>
        ’val’ AS ’name’,                          </gazonk>
        1 + 1 AS ’num’
      ),
      XMLELEMENT (
        NAME ’qux’,
        ’foo’
      )
   ),
   VERSION ’1.0’,
   STANDALONE YES
 )
         Nikolay Samokhvalov, Peter Eisentraut   The Road to the XML Type
Current Developments     XML Data Type
                          Future Developments     XML Publishing
                                   Conclusion     XML Export


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>
          Nikolay Samokhvalov, Peter Eisentraut   The Road to the XML Type
Current Developments     XML Data Type
                           Future Developments     XML Publishing
                                    Conclusion     XML Export


XMLAGG Example

 SELECT xmlelement (’Emp’, xmlattributes (’Sales Representative’
   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)
           Nikolay Samokhvalov, Peter Eisentraut   The Road to the XML Type
Current Developments     XML Data Type
                          Future Developments     XML Publishing
                                   Conclusion     XML Export


Outline


  1   Current Developments
        XML Data Type
        XML Publishing
        XML Export

  2   Future Developments

  3   Conclusion




          Nikolay Samokhvalov, Peter Eisentraut   The Road to the XML Type
Current Developments     XML Data Type
                           Future Developments     XML Publishing
                                    Conclusion     XML Export


XML Export



      Map table/schema/database contents to XML document
      Map table/schema/database schema to XML Schema
  Useful for:
      Downstream processing (e.g., SOAP, web services)
      Postprocessing using XSLT
      Backup???
      Display formats (alternative to psql’s HTML mode)




           Nikolay Samokhvalov, Peter Eisentraut   The Road to the XML Type
Current Developments     XML Data Type
                          Future Developments     XML Publishing
                                   Conclusion     XML Export


XML Export Functions
  Data export:
  table_to_xml(tbl regclass, nulls boolean,
               tableforest boolean, targetns text)
  query_to_xml(query text, nulls boolean,
               tableforest boolean, targetns text)
  cursor_to_xml(cursor refcursor, count int, nulls boolean,
                tableforest boolean, targetns text)

  Schema export:
  table_to_xmlschema(tbl regclass, nulls boolean,
                     tableforest boolean, targetns text)
  query_to_xmlschema(query text, nulls boolean,
                     tableforest boolean, targetns text)
  cursor_to_xmlschema(cursor refcursor, nulls boolean,
                      tableforest boolean, targetns text)


          Nikolay Samokhvalov, Peter Eisentraut   The Road to the XML Type
Current Developments     XML Data Type
                          Future Developments     XML Publishing
                                   Conclusion     XML Export


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: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>
          Nikolay Samokhvalov, Peter Eisentraut   The Road to the XML Type
Current Developments     XML Data Type
                         Future Developments     XML Publishing
                                  Conclusion     XML Export


XML Export Format Example


  <catalogname>
    <schemaname>
      <tablename>
        <row>
          <colname1>value</colname1>
          <colname2 xsi:nil=’true’/>
          ...
        </row>
        ...
      </tablename>
      ...
    </schemaname>
    ...
  </catalogname>



         Nikolay Samokhvalov, Peter Eisentraut   The Road to the XML Type
Current Developments     XML Data Type
                          Future Developments     XML Publishing
                                   Conclusion     XML Export


Outline


  1   Current Developments
        XML Data Type
        XML Publishing
        XML Export

  2   Future Developments

  3   Conclusion




          Nikolay Samokhvalov, Peter Eisentraut   The Road to the XML Type
Current Developments     XML Data Type
                        Future Developments     XML Publishing
                                 Conclusion     XML Export


XPath




  tbd




        Nikolay Samokhvalov, Peter Eisentraut   The Road to the XML Type
Current Developments     XML Data Type
                        Future Developments     XML Publishing
                                 Conclusion     XML Export


External Dependencies




     Uses libxml (LGPL) for XML publishing and XPath
     Enable with configure --with-libxml
     Not necessary for XML export




        Nikolay Samokhvalov, Peter Eisentraut   The Road to the XML Type
Current Developments
                          Future Developments
                                   Conclusion


Outline



  1   Current Developments

  2   Future Developments

  3   Conclusion




          Nikolay Samokhvalov, Peter Eisentraut   The Road to the XML Type
Current Developments
                         Future Developments
                                  Conclusion


Further Work/Ideas

     XQuery support (SQL:2006)
     Ctree indexes
     Inline ORDER BY for XMLAGG (example:
     ... XMLAGG(XMLELEMENT(...) ORDER BY col1) ...)
     Improved namespaces support
     JDBC support
     DTD, XML Schema, Relax-NG validation
     XSLT
     XML Canonical
     Pretty printing
     Shredding

         Nikolay Samokhvalov, Peter Eisentraut   The Road to the XML Type
Current Developments
                          Future Developments
                                   Conclusion


Outline



  1   Current Developments

  2   Future Developments

  3   Conclusion




          Nikolay Samokhvalov, Peter Eisentraut   The Road to the XML Type
Current Developments
                        Future Developments
                                 Conclusion


More Information




     http://developer.postgresql.org/index.php/
     XML_Support
     PostgreSQL documentation




        Nikolay Samokhvalov, Peter Eisentraut   The Road to the XML Type

Más contenido relacionado

Destacado

Chapter 2 the structure of the atom
Chapter 2 the structure of the atomChapter 2 the structure of the atom
Chapter 2 the structure of the atom
Ling Leon
 
Properties of matter ppt
Properties of matter pptProperties of matter ppt
Properties of matter ppt
dsacre
 
Structure of atom ppt
Structure of atom pptStructure of atom ppt
Structure of atom ppt
lekshmisg91
 
States Of Matter Power Point
States Of Matter Power PointStates Of Matter Power Point
States Of Matter Power Point
wolffer87
 
What is matter? slide show
What is matter? slide showWhat is matter? slide show
What is matter? slide show
mater1ag
 

Destacado (6)

Structure Of Atom[1] Monika Khurana
Structure Of Atom[1] Monika KhuranaStructure Of Atom[1] Monika Khurana
Structure Of Atom[1] Monika Khurana
 
Chapter 2 the structure of the atom
Chapter 2 the structure of the atomChapter 2 the structure of the atom
Chapter 2 the structure of the atom
 
Properties of matter ppt
Properties of matter pptProperties of matter ppt
Properties of matter ppt
 
Structure of atom ppt
Structure of atom pptStructure of atom ppt
Structure of atom ppt
 
States Of Matter Power Point
States Of Matter Power PointStates Of Matter Power Point
States Of Matter Power Point
 
What is matter? slide show
What is matter? slide showWhat is matter? slide show
What is matter? slide show
 

Similar a The Road to the XML Type: Current and Future Developments

20070524 Pgcon2007 Roadtoxmltype
20070524 Pgcon2007 Roadtoxmltype20070524 Pgcon2007 Roadtoxmltype
20070524 Pgcon2007 Roadtoxmltype
Nikolay Samokhvalov
 
Postgresql N Samokhvalov P Eisentraut Xml Type Pgcon Ottawa 2007
Postgresql N Samokhvalov P Eisentraut Xml Type Pgcon Ottawa 2007Postgresql N Samokhvalov P Eisentraut Xml Type Pgcon Ottawa 2007
Postgresql N Samokhvalov P Eisentraut Xml Type Pgcon Ottawa 2007
Nikolay Samokhvalov
 
ibm_research_aug_8_03
ibm_research_aug_8_03ibm_research_aug_8_03
ibm_research_aug_8_03
Attila Barta
 
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 1
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 1OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 1
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 1
Marco Gralike
 

Similar a The Road to the XML Type: Current and Future Developments (20)

20070524 Pgcon2007 Roadtoxmltype
20070524 Pgcon2007 Roadtoxmltype20070524 Pgcon2007 Roadtoxmltype
20070524 Pgcon2007 Roadtoxmltype
 
PostgreSQL and XML
PostgreSQL and XMLPostgreSQL and XML
PostgreSQL and XML
 
XML Support: Specifications and Development
XML Support: Specifications and DevelopmentXML Support: Specifications and Development
XML Support: Specifications and Development
 
Day2 xslt x_path_xquery
Day2 xslt x_path_xqueryDay2 xslt x_path_xquery
Day2 xslt x_path_xquery
 
DB2 Native XML
DB2 Native XMLDB2 Native XML
DB2 Native XML
 
Postgresql N Samokhvalov P Eisentraut Xml Type Pgcon Ottawa 2007
Postgresql N Samokhvalov P Eisentraut Xml Type Pgcon Ottawa 2007Postgresql N Samokhvalov P Eisentraut Xml Type Pgcon Ottawa 2007
Postgresql N Samokhvalov P Eisentraut Xml Type Pgcon Ottawa 2007
 
PGCon-2007 The Road to XML Type
PGCon-2007 The Road to XML TypePGCon-2007 The Road to XML Type
PGCon-2007 The Road to XML Type
 
XML Schema Patterns for Databinding
XML Schema Patterns for DatabindingXML Schema Patterns for Databinding
XML Schema Patterns for Databinding
 
Oracle XML Handling
Oracle XML HandlingOracle XML Handling
Oracle XML Handling
 
ibm_research_aug_8_03
ibm_research_aug_8_03ibm_research_aug_8_03
ibm_research_aug_8_03
 
XSLT 3.0 - new features
XSLT 3.0 - new featuresXSLT 3.0 - new features
XSLT 3.0 - new features
 
Creating the PromQL Transpiler for Flux by Julius Volz, Co-Founder | Prometheus
Creating the PromQL Transpiler for Flux by Julius Volz, Co-Founder | PrometheusCreating the PromQL Transpiler for Flux by Julius Volz, Co-Founder | Prometheus
Creating the PromQL Transpiler for Flux by Julius Volz, Co-Founder | Prometheus
 
Xslt by asfak mahamud
Xslt by asfak mahamudXslt by asfak mahamud
Xslt by asfak mahamud
 
Converting with custom transformer part 2
Converting with custom transformer part 2Converting with custom transformer part 2
Converting with custom transformer part 2
 
Jackson beyond JSON: XML, CSV
Jackson beyond JSON: XML, CSVJackson beyond JSON: XML, CSV
Jackson beyond JSON: XML, CSV
 
Transforming xml with XSLT
Transforming  xml with XSLTTransforming  xml with XSLT
Transforming xml with XSLT
 
XML - State of the Art
XML - State of the ArtXML - State of the Art
XML - State of the Art
 
XSLT for Web Developers
XSLT for Web DevelopersXSLT for Web Developers
XSLT for Web Developers
 
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 1
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 1OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 1
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 1
 
Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...
Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...
Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...
 

Más de Peter Eisentraut

Replication Solutions for PostgreSQL
Replication Solutions for PostgreSQLReplication Solutions for PostgreSQL
Replication Solutions for PostgreSQL
Peter Eisentraut
 
The Common Debian Build System (CDBS)
The Common Debian Build System (CDBS)The Common Debian Build System (CDBS)
The Common Debian Build System (CDBS)
Peter Eisentraut
 

Más de Peter Eisentraut (20)

Programming with Python and PostgreSQL
Programming with Python and PostgreSQLProgramming with Python and PostgreSQL
Programming with Python and PostgreSQL
 
Getting Started with PL/Proxy
Getting Started with PL/ProxyGetting Started with PL/Proxy
Getting Started with PL/Proxy
 
Linux distribution for the cloud
Linux distribution for the cloudLinux distribution for the cloud
Linux distribution for the cloud
 
Most Wanted: Future PostgreSQL Features
Most Wanted: Future PostgreSQL FeaturesMost Wanted: Future PostgreSQL Features
Most Wanted: Future PostgreSQL Features
 
Porting Applications From Oracle To PostgreSQL
Porting Applications From Oracle To PostgreSQLPorting Applications From Oracle To PostgreSQL
Porting Applications From Oracle To PostgreSQL
 
Porting Oracle Applications to PostgreSQL
Porting Oracle Applications to PostgreSQLPorting Oracle Applications to PostgreSQL
Porting Oracle Applications to PostgreSQL
 
PostgreSQL: Die Freie Datenbankalternative
PostgreSQL: Die Freie DatenbankalternativePostgreSQL: Die Freie Datenbankalternative
PostgreSQL: Die Freie Datenbankalternative
 
Access ohne Access: Freie Datenbank-Frontends
Access ohne Access: Freie Datenbank-FrontendsAccess ohne Access: Freie Datenbank-Frontends
Access ohne Access: Freie Datenbank-Frontends
 
PostgreSQL and PL/Java
PostgreSQL and PL/JavaPostgreSQL and PL/Java
PostgreSQL and PL/Java
 
Replication Solutions for PostgreSQL
Replication Solutions for PostgreSQLReplication Solutions for PostgreSQL
Replication Solutions for PostgreSQL
 
PostgreSQL News
PostgreSQL NewsPostgreSQL News
PostgreSQL News
 
PostgreSQL News
PostgreSQL NewsPostgreSQL News
PostgreSQL News
 
Access ohne Access: Freie Datenbank-Frontends
Access ohne Access: Freie Datenbank-FrontendsAccess ohne Access: Freie Datenbank-Frontends
Access ohne Access: Freie Datenbank-Frontends
 
Docbook: Textverarbeitung mit XML
Docbook: Textverarbeitung mit XMLDocbook: Textverarbeitung mit XML
Docbook: Textverarbeitung mit XML
 
Collateral Damage: Consequences of Spam and Virus Filtering for the E-Mail Sy...
Collateral Damage: Consequences of Spam and Virus Filtering for the E-Mail Sy...Collateral Damage: Consequences of Spam and Virus Filtering for the E-Mail Sy...
Collateral Damage: Consequences of Spam and Virus Filtering for the E-Mail Sy...
 
Collateral Damage: Consequences of Spam and Virus Filtering for the E-Mail S...
Collateral Damage:
Consequences of Spam and Virus Filtering for the E-Mail S...Collateral Damage:
Consequences of Spam and Virus Filtering for the E-Mail S...
Collateral Damage: Consequences of Spam and Virus Filtering for the E-Mail S...
 
Spaß mit PostgreSQL
Spaß mit PostgreSQLSpaß mit PostgreSQL
Spaß mit PostgreSQL
 
The Common Debian Build System (CDBS)
The Common Debian Build System (CDBS)The Common Debian Build System (CDBS)
The Common Debian Build System (CDBS)
 
SQL/MED and PostgreSQL
SQL/MED and PostgreSQLSQL/MED and PostgreSQL
SQL/MED and PostgreSQL
 
The Lives of Others: Open-Source Development Practices Elsewhere
The Lives of Others: Open-Source Development Practices ElsewhereThe Lives of Others: Open-Source Development Practices Elsewhere
The Lives of Others: Open-Source Development Practices Elsewhere
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Último (20)

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 

The Road to the XML Type: Current and Future Developments

  • 1. The Road to the XML Type Current and Future Developments Nikolay Samokhvalov Peter Eisentraut PGCon 2007
  • 2. Current Developments Future Developments Conclusion Outline 1 Current Developments 2 Future Developments 3 Conclusion Nikolay Samokhvalov, Peter Eisentraut The Road to the XML Type
  • 3. Current Developments XML Data Type Future Developments XML Publishing Conclusion XML Export Outline 1 Current Developments 2 Future Developments 3 Conclusion Nikolay Samokhvalov, Peter Eisentraut The Road to the XML Type
  • 4. Current Developments XML Data Type Future Developments XML Publishing Conclusion XML Export New Features Target for PostgreSQL 8.3: XML Data Type XML Publishing XML Export SQL:2003 conformance XPath Nikolay Samokhvalov, Peter Eisentraut The Road to the XML Type
  • 5. Current Developments XML Data Type Future Developments XML Publishing Conclusion XML Export Outline 1 Current Developments XML Data Type XML Publishing XML Export 2 Future Developments 3 Conclusion Nikolay Samokhvalov, Peter Eisentraut The Road to the XML Type
  • 6. Current Developments XML Data Type Future Developments XML Publishing Conclusion XML Export XML Data Type CREATE TABLE test ( ..., data xml, ... ); Features: Input checking Support functions Issues: Internal storage format (plain text) Encoding handling Nikolay Samokhvalov, Peter Eisentraut The Road to the XML Type
  • 7. Current Developments XML Data Type Future Developments XML Publishing Conclusion XML Export Using the XML Type Bizarre SQL way: INSERT INTO test VALUES ( ..., XMLPARSE (DOCUMENT ’<foo>...</foo>’), ... ); SELECT XMLSERIALIZE (DOCUMENT data AS varchar) FROM test; Simple PostgreSQL way: INSERT INTO test VALUES (... , ’<foo>...</foo>’, ...); SELECT data FROM test; Nikolay Samokhvalov, Peter Eisentraut The Road to the XML Type
  • 8. Current Developments XML Data Type Future Developments XML Publishing Conclusion XML Export XML Type Oddities No comparison operators To retrieve, use: Cast to text, or XPath, or Other key column To index, use: Cast to text, or XPath Nikolay Samokhvalov, Peter Eisentraut The Road to the XML Type
  • 9. Current Developments XML Data Type Future Developments XML Publishing Conclusion XML Export Outline 1 Current Developments XML Data Type XML Publishing XML Export 2 Future Developments 3 Conclusion Nikolay Samokhvalov, Peter Eisentraut The Road to the XML Type
  • 10. Current Developments XML Data Type Future Developments XML Publishing Conclusion XML Export Producing XML Content The old way? SELECT ’<record id="’ || id || ’"><value>’ || ad_hoc_escape_func(value) || ’</value></record>’ FROM tab; The new way: SELECT XMLELEMENT(NAME record, XMLATTRIBUTES(id), XMLELEMENT(NAME value, value)) FROM tab; Nikolay Samokhvalov, Peter Eisentraut The Road to the XML Type
  • 11. Current Developments XML Data Type Future Developments XML Publishing Conclusion XML Export XMLELEMENT Example Result: SQL: <?xml version=’1.0’ XMLROOT ( standalone=’yes’ ?> XMLELEMENT ( <gazonk name=’val’ NAME ’gazonk’, num=’2’> XMLATTRIBUTES ( <qux>foo</qux> ’val’ AS ’name’, </gazonk> 1 + 1 AS ’num’ ), XMLELEMENT ( NAME ’qux’, ’foo’ ) ), VERSION ’1.0’, STANDALONE YES ) Nikolay Samokhvalov, Peter Eisentraut The Road to the XML Type
  • 12. Current Developments XML Data Type Future Developments XML Publishing Conclusion XML Export 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> Nikolay Samokhvalov, Peter Eisentraut The Road to the XML Type
  • 13. Current Developments XML Data Type Future Developments XML Publishing Conclusion XML Export XMLAGG Example SELECT xmlelement (’Emp’, xmlattributes (’Sales Representative’ 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) Nikolay Samokhvalov, Peter Eisentraut The Road to the XML Type
  • 14. Current Developments XML Data Type Future Developments XML Publishing Conclusion XML Export Outline 1 Current Developments XML Data Type XML Publishing XML Export 2 Future Developments 3 Conclusion Nikolay Samokhvalov, Peter Eisentraut The Road to the XML Type
  • 15. Current Developments XML Data Type Future Developments XML Publishing Conclusion XML Export XML Export Map table/schema/database contents to XML document Map table/schema/database schema to XML Schema Useful for: Downstream processing (e.g., SOAP, web services) Postprocessing using XSLT Backup??? Display formats (alternative to psql’s HTML mode) Nikolay Samokhvalov, Peter Eisentraut The Road to the XML Type
  • 16. Current Developments XML Data Type Future Developments XML Publishing Conclusion XML Export XML Export Functions Data export: table_to_xml(tbl regclass, nulls boolean, tableforest boolean, targetns text) query_to_xml(query text, nulls boolean, tableforest boolean, targetns text) cursor_to_xml(cursor refcursor, count int, nulls boolean, tableforest boolean, targetns text) Schema export: table_to_xmlschema(tbl regclass, nulls boolean, tableforest boolean, targetns text) query_to_xmlschema(query text, nulls boolean, tableforest boolean, targetns text) cursor_to_xmlschema(cursor refcursor, nulls boolean, tableforest boolean, targetns text) Nikolay Samokhvalov, Peter Eisentraut The Road to the XML Type
  • 17. Current Developments XML Data Type Future Developments XML Publishing Conclusion XML Export 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: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> Nikolay Samokhvalov, Peter Eisentraut The Road to the XML Type
  • 18. Current Developments XML Data Type Future Developments XML Publishing Conclusion XML Export XML Export Format Example <catalogname> <schemaname> <tablename> <row> <colname1>value</colname1> <colname2 xsi:nil=’true’/> ... </row> ... </tablename> ... </schemaname> ... </catalogname> Nikolay Samokhvalov, Peter Eisentraut The Road to the XML Type
  • 19. Current Developments XML Data Type Future Developments XML Publishing Conclusion XML Export Outline 1 Current Developments XML Data Type XML Publishing XML Export 2 Future Developments 3 Conclusion Nikolay Samokhvalov, Peter Eisentraut The Road to the XML Type
  • 20. Current Developments XML Data Type Future Developments XML Publishing Conclusion XML Export XPath tbd Nikolay Samokhvalov, Peter Eisentraut The Road to the XML Type
  • 21. Current Developments XML Data Type Future Developments XML Publishing Conclusion XML Export External Dependencies Uses libxml (LGPL) for XML publishing and XPath Enable with configure --with-libxml Not necessary for XML export Nikolay Samokhvalov, Peter Eisentraut The Road to the XML Type
  • 22. Current Developments Future Developments Conclusion Outline 1 Current Developments 2 Future Developments 3 Conclusion Nikolay Samokhvalov, Peter Eisentraut The Road to the XML Type
  • 23. Current Developments Future Developments Conclusion Further Work/Ideas XQuery support (SQL:2006) Ctree indexes Inline ORDER BY for XMLAGG (example: ... XMLAGG(XMLELEMENT(...) ORDER BY col1) ...) Improved namespaces support JDBC support DTD, XML Schema, Relax-NG validation XSLT XML Canonical Pretty printing Shredding Nikolay Samokhvalov, Peter Eisentraut The Road to the XML Type
  • 24. Current Developments Future Developments Conclusion Outline 1 Current Developments 2 Future Developments 3 Conclusion Nikolay Samokhvalov, Peter Eisentraut The Road to the XML Type
  • 25. Current Developments Future Developments Conclusion More Information http://developer.postgresql.org/index.php/ XML_Support PostgreSQL documentation Nikolay Samokhvalov, Peter Eisentraut The Road to the XML Type