SlideShare une entreprise Scribd logo
1  sur  25
Télécharger pour lire hors ligne
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

Contenu connexe

En vedette

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
 

En vedette (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
 

Similaire à 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
 

Similaire à 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...
 

Plus 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
 

Plus 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
 

Dernier

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Dernier (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
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
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 

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