Learning Center
Plans & pricing Sign in
Sign Out

JDOM_ XML and Databases


  • pg 1
									JDOM, XML and
    Presentation by:
   Tasadduq Wattoo
     Alpha Amatya
     Tom Murphy
    Alberto Hurtado
   JDOM is, quite simply, a Java representation of
    an XML document.
   JDOM provides a way to represent that
    document for easy and efficient reading,
    manipulation, and writing.
   It has a straightforward API, is a lightweight and
    fast, and is optimized for the Java programmer.
   It's an alternative to DOM and SAX, although it
    integrates well with both DOM and SAX.
Oracle and XML
   Implements XML through the XML DB
    component of the database
   XML DB is standard feature of Oracle Standard
    and Enterprise editions
   It provides features for storing, retrieving and
    manipulating XML data in the database
Oracle and XML cont’d
   Oracle XML DB in Oracle Database 10g
    Release 2 implements SQL 2003 and features
    from the upcoming SQL/XML standard release.
   The implementation of these standards in Oracle
    allows us to look inside an XML document in
    ways that were not possible in older SQL
Oracle and XML cont’d
   Oracle XML DB is a high-performance XML
    storage and retrieval technology
   With XML DB, the user gets all the advantages
    of relational database technology and XML
    technology at the same time.
   XML DB also adds an XML Repository to the
Oracle and XML cont’d
   Oracle XML DB is effective at accommodating
    XML content.
    It provides enhanced native support for XML.
   Oracle Database has strong XML support with
    Indexing and Search, Updates and Transaction
    Processing, Managing Relationships, Multiple
    Views of Data and Performance and Scalability
XML Data Type in Oracle
   A new data type, XMLType, was introduced in
    Oracle9i Database Release 1 to allow an XML
    document in the database to be accessible in
    SQL and at the same time allow XML
    developers the ability to use XML standards on a
   This datatype tells the database that the content
    is in XML format and allows us to perform
    queries on an XML document.
XML Implementation in Oracle
 Oracle’s XML implementation gives us the
  flexibility to store data in two different
  ways: as structured and unstructured
 XMLType data is unstructured when
  stored as a single LOB column and
  structured when implemented as a set of
XML Storage in Oracle
   Structured XML storage is implemented as a set
    of objects. These objects can be implemented in
    a relational format through tables with referential
    constraints optionally implemented between the
   They can also be implemented by using an
    XMLSchema to decompose an XMLType
    document into a set of objects.
Storing and Retrieving XML Data
   There are many options available to us to get
    XML data into the database. Data can be
    inserted with SQL, PL/SQL, Java, and C
   We can also load data into the database using
    the SQL*Loader and Import/Export functions of
    XMLType tables. XML data can also be moved
    with Oracle Streams and can also use
    DBMS_XDB functions
Example: store and extract XML
data from Oracle
    insert into XMLTable values (1,
              <QUERY>Question 1</QUERY>
           <RESPONSE>Answer goes here.</RESPONSE>

select extractValue(xml_data, '/FAQ-LIST/QUESTION/RESPONSE') -- XPath

from XMLTable
where existsNode(xml_data, '/FAQ-LIST/QUESTION[QUERY="Question 1"]')
   = 1;
DB2 and XML
   DB2 9's pureXML feature has revolutionized
    support for XML data - handling XML as a new
    data type that is stored in a natural hierarchy -
    different from relational data.
   pureXML's seamless integration of XML with
    relational data speeds application development,
    improves search performance with highly
    optimized XML indexes, and is flexible because
    both SQL and XQuery can be used to query
    XML data.
DB2 and XML cont’d
   A new XML data type in DB2 9 that enables
    storing well-formed XML documents in their
    native hierarchical form within the column of a
   The XML document is stored on disk as a rich
    DOM-like, parsed tree representation, resulting
    in high performance
DB2 and XML cont’d
   DB2 9 does NOT treat XML data as if it wasn't
    XML data by stuffing it into a large object or
    shredding it into relational tables (as some other
    DBMSes do)
   Rich set of API (application programming
    interfaces) for all supported languages in DB2 9.
DB2 and XML cont’d
   DB2 9 has the natural ability to not only store the
    XML data as XML data, but also retrieve it from
    the data server.
   DB29 supports the new XQuery language
    developed by the World Wide Web Consortium
DB2 and XML cont’d
   While using XQuery to retrieve XML data from
    DB29, you use XPath.
   XPath is used to locate information within an
    XML hierarchical data set. Using different XPath
    expressions, we are able to retrieve different
    sets of data.
DB2 and XML cont’d
   For those who are more comfortable with the
    SQL API, they can leverage the open-standard
    SQL/XML extensions to retrieve this data.
   MySQL version 5.1.5 has functions for searching
    and changing XML documents.
   ExtractValue() function extracts a value from an
    XML string using XPath notation
   UpdateXML() function returns replaced XML
     CREATE TABLE x (doc VARCHAR(150));

        <title>A guide to the SQL standard</title>
Example cont’d
   mysql> SELECT EXTRACTVALUE(doc,'/book/author/initial') FROM x;

   mysql> select UpdateXML(doc,'/book/author/initial','!!') from x;
PostgreSQL 8.2.5 and XML
   PostgreSQL supports some but not all of these
    XML capabilities.
   Storage: PostgreSQL does not have a
    specialized XML data type. Users should store
    XML documents in ordinary TEXT fields.
   Import/Export: There is no facility for mapping
    XML to relational tables. An external tool must
    be used for this.
PostgreSQL 8.2.5 and XML
   Validation: /contrib/xml2 has a function called
    xml_is_well_formed() that can be used in a CHECK
    constraint to enforce that a field contains well-formed
   Indexing: /contrib/xml2 functions can be used in
    expression indexes to index specific XML fields.
   Searching: XPath searches are implemented
    using /contrib/xml2. It processes XML text
    documents and returns results based on the
    requested query.
PostgreSQL 8.2.5 and XML
   Transforming: /contrib/xml2 supports XSLT
   XML to SQL Mapping: This involves converting
    XML data to and from relational structures.
    PostgreSQL has no internal support for such
    mapping, and relies on external tools to do such
PostgreSQL 8.2.5 and XML
   Missing Features: Missing features include
    XQuery, SQL/XML syntax (ISO/IEC 9075-14),
    and an XML data type optimized for XML
   Future releases of PostgreSQL will continue to
    improve XML support.

To top