xpath to sql translation

Discussion in 'XML' started by Terry P, Nov 30, 2004.

  1. Terry P

    Terry P Guest

    Are there any tools (java classes, tag libraries) which can translate
    xpath statements into a SQL query?

    Given an xpath query which has a predicate that filters node values or
    attributes, I want help constructing the Where clause of a SQL
    statement that will mirror the expressions and functions contained in
    the predicate.

    Such a tool may require an XML to DB mapping or it would need to make
    assumptions about the structure of the document and the tables.

    Thanks for any advice.

    Terry
    Terry P, Nov 30, 2004
    #1
    1. Advertising

  2. Terry P wrote:
    > Are there any tools (java classes, tag libraries) which can translate
    > xpath statements into a SQL query?
    >
    > Given an xpath query which has a predicate that filters node values or
    > attributes, I want help constructing the Where clause of a SQL
    > statement that will mirror the expressions and functions contained in
    > the predicate.
    >
    > Such a tool may require an XML to DB mapping or it would need to make
    > assumptions about the structure of the document and the tables.
    >
    > Thanks for any advice.
    >
    > Terry


    What sory of database are you talking about?
    A ordinary relational database? Or an XML-database.
    Xml-databases are new and not very fast, but there is extensive research in xml-database-system.
    Those system support xpath and xquery as query languages.

    I'f you want to map xpath onto sql, then your're right: you need some
    rules about how xml is mapped onto the relational database.
    With those rules you could map xpath expression to sql expressions.

    I don't know wether they exists. I myself have my own mapping rules,
    rather simplistic rules but it does the job for me.
    Tjerk Wolterink, Dec 1, 2004
    #2
    1. Advertising

  3. Terry P

    Jeff Kish Guest

    On Wed, 01 Dec 2004 14:24:45 +0100, Tjerk Wolterink
    <> wrote:

    >Terry P wrote:
    >> Are there any tools (java classes, tag libraries) which can translate
    >> xpath statements into a SQL query?
    >>
    >> Given an xpath query which has a predicate that filters node values or
    >> attributes, I want help constructing the Where clause of a SQL
    >> statement that will mirror the expressions and functions contained in
    >> the predicate.
    >>
    >> Such a tool may require an XML to DB mapping or it would need to make
    >> assumptions about the structure of the document and the tables.
    >>
    >> Thanks for any advice.
    >>
    >> Terry

    >
    >What sory of database are you talking about?
    >A ordinary relational database? Or an XML-database.
    >Xml-databases are new and not very fast, but there is extensive research in xml-database-system.
    >Those system support xpath and xquery as query languages.
    >
    >I'f you want to map xpath onto sql, then your're right: you need some
    >rules about how xml is mapped onto the relational database.
    >With those rules you could map xpath expression to sql expressions.
    >
    >I don't know wether they exists. I myself have my own mapping rules,
    >rather simplistic rules but it does the job for me.

    I was under the (mistaken?) assumption that eventually xpath will let you
    query multiple data sources, i.e. databases included.

    Is this true?
    Jeff Kish
    Jeff Kish, Dec 1, 2004
    #3
  4. Jeff Kish wrote:
    > On Wed, 01 Dec 2004 14:24:45 +0100, Tjerk Wolterink
    > <> wrote:
    >
    >
    >>Terry P wrote:
    >>
    >>>Are there any tools (java classes, tag libraries) which can translate
    >>>xpath statements into a SQL query?
    >>>
    >>>Given an xpath query which has a predicate that filters node values or
    >>>attributes, I want help constructing the Where clause of a SQL
    >>>statement that will mirror the expressions and functions contained in
    >>>the predicate.
    >>>
    >>>Such a tool may require an XML to DB mapping or it would need to make
    >>>assumptions about the structure of the document and the tables.
    >>>
    >>>Thanks for any advice.
    >>>
    >>>Terry

    >>
    >>What sory of database are you talking about?
    >>A ordinary relational database? Or an XML-database.
    >>Xml-databases are new and not very fast, but there is extensive research in xml-database-system.
    >>Those system support xpath and xquery as query languages.
    >>
    >>I'f you want to map xpath onto sql, then your're right: you need some
    >>rules about how xml is mapped onto the relational database.
    >>With those rules you could map xpath expression to sql expressions.
    >>
    >>I don't know wether they exists. I myself have my own mapping rules,
    >>rather simplistic rules but it does the job for me.

    >
    > I was under the (mistaken?) assumption that eventually xpath will let you
    > query multiple data sources, i.e. databases included.
    >
    > Is this true?
    > Jeff Kish


    XPath is a language to query xml documents, or multiple xml documents, it returns a node-set.
    It cannot query ordinary relational based databases, i think.

    But you can query multiple data-sources [multiple xml files, using the document() function].
    And maybe in the future you can also query XML-based databases with XPath,

    But xpath is a rather simple query language for xml, XQuery is much more powerfull.
    Tjerk Wolterink, Dec 1, 2004
    #4

  5. > But xpath is a rather simple query language for xml, XQuery is much
    > more powerfull.


    Xquery is a superset of Xpath 2 but the extra features are mainly
    related to element construction rather than querying.


    David
    David Carlisle, Dec 1, 2004
    #5
  6. Terry P

    Terry P Guest

    Tjerk,
    Thanks for the response.
    In particular, I expect to be using a DB2 database with XML Extenders
    (IBM). I may need this on different platforms - Linux, ISeries,
    Win2000.

    A Java/SQL solution may be best. I am hoping for something like a
    Java class that can parse the XPath and create the Where clause of a
    SQL query. Special SQL functions might be used to emulate the
    standard XPath functions.

    XPath has been around for a while, so I am surprised that I have not
    been able to find "off the shelf" tools to do this.

    Terry


    Tjerk Wolterink <> wrote in message news:<41adc5e4$0$30715$>...
    > Terry P wrote:
    > > Are there any tools (java classes, tag libraries) which can translate
    > > xpath statements into a SQL query?

    ....>
    > > Terry

    >
    > What sory of database are you talking about?
    > A ordinary relational database? Or an XML-database.
    > Xml-databases are new and not very fast, but there is extensive research in xml-database-system.
    > Those system support xpath and xquery as query languages.
    >
    > I'f you want to map xpath onto sql, then your're right: you need some
    > rules about how xml is mapped onto the relational database.
    > With those rules you could map xpath expression to sql expressions.
    >
    > I don't know wether they exists. I myself have my own mapping rules,
    > rather simplistic rules but it does the job for me.
    Terry P, Dec 2, 2004
    #6
  7. Terry P

    Jeff Kish Guest

    On 1 Dec 2004 18:44:50 -0800, (Terry P) wrote:

    >Tjerk,
    >Thanks for the response.
    >In particular, I expect to be using a DB2 database with XML Extenders
    >(IBM). I may need this on different platforms - Linux, ISeries,
    >Win2000.
    >
    >A Java/SQL solution may be best. I am hoping for something like a
    >Java class that can parse the XPath and create the Where clause of a
    >SQL query. Special SQL functions might be used to emulate the
    >standard XPath functions.
    >
    >XPath has been around for a while, so I am surprised that I have not
    >been able to find "off the shelf" tools to do this.
    >

    <snip>
    If you go to http://xquery.com/ you see this blurb:

    "what is xquery?"
    "XQuery is a technology under development by the World Wide Web Consortium
    (W3C) that's designed to query collections of XML data -- not just XML files,
    but anything that can appear as XML, including relationtional databases.
    XQuery has broad support from IBM, Microsoft, and Oracle as well as
    application server vendors such as BEA and Software AB."

    I may of misquoted, and this may be accurate or not I don't know. It is by
    Jason Hunter who I believe has a good reputation in these matters.

    HTH


    Jeff Kish
    Jeff Kish, Dec 2, 2004
    #7
  8. Terry P wrote:
    > Tjerk,
    > Thanks for the response.
    > In particular, I expect to be using a DB2 database with XML Extenders
    > (IBM). I may need this on different platforms - Linux, ISeries,
    > Win2000.
    >
    > A Java/SQL solution may be best. I am hoping for something like a
    > Java class that can parse the XPath and create the Where clause of a
    > SQL query. Special SQL functions might be used to emulate the
    > standard XPath functions.
    >
    > XPath has been around for a while, so I am surprised that I have not
    > been able to find "off the shelf" tools to do this.
    >
    > Terry
    >
    >
    > Tjerk Wolterink <> wrote in message news:<41adc5e4$0$30715$>...
    >
    >>Terry P wrote:
    >>
    >>>Are there any tools (java classes, tag libraries) which can translate
    >>>xpath statements into a SQL query?

    >
    > ...>
    >
    >>>Terry

    >>
    >>What sory of database are you talking about?
    >>A ordinary relational database? Or an XML-database.
    >>Xml-databases are new and not very fast, but there is extensive research in xml-database-system.
    >>Those system support xpath and xquery as query languages.
    >>
    >>I'f you want to map xpath onto sql, then your're right: you need some
    >>rules about how xml is mapped onto the relational database.
    >>With those rules you could map xpath expression to sql expressions.
    >>
    >>I don't know wether they exists. I myself have my own mapping rules,
    >>rather simplistic rules but it does the job for me.


    I've never seen an Xpath to SELECT [] FROM [] WHERE clause translation.
    And it is not easy to do that,
    because you have to have rules in how you store xml in a relational database.

    I think that's also the reason there are no tools to do that.
    So can't help you there.
    Tjerk Wolterink, Dec 2, 2004
    #8
  9. Terry P

    Terry P Guest

    Tjerk,

    We have found a couple of products on IBM's Alphaworks site. One of
    them uses the "DB2 XML Extenders" mapping of XML<=>SQL. The other
    seems to create a default mapping based on SQL metadata.

    Both of them are limited to Linux & Windows. While we may use these,
    our main RDB is DB2 for ISeries. So we are still checking.

    If you are curious, the links are:
    http://www.alphaworks.ibm.com/tech/xtable
    http://www.alphaworks.ibm.com/tech/db2uriaccess

    Thanks for your help,

    Terry

    Tjerk Wolterink <> wrote in message news:<41af773a$0$69638$>...
    > Terry P wrote:
    > > Tjerk,
    > > Thanks for the response.
    > > In particular, I expect to be using a DB2 database with XML Extenders
    > > (IBM). I may need this on different platforms - Linux, ISeries,
    > > Win2000.
    > >

    ....
    > >>>Terry
    > >>
    > >>What sory of database are you talking about?
    > >>A ordinary relational database? Or an XML-database.
    > >>Xml-databases are new and not very fast, but there is extensive research in xml-database-system.
    > >>Those system support xpath and xquery as query languages.
    > >>
    > >>I'f you want to map xpath onto sql, then your're right: you need some
    > >>rules about how xml is mapped onto the relational database.
    > >>With those rules you could map xpath expression to sql expressions.
    > >>
    > >>I don't know wether they exists. I myself have my own mapping rules,
    > >>rather simplistic rules but it does the job for me.

    >
    > I've never seen an Xpath to SELECT [] FROM [] WHERE clause translation.
    > And it is not easy to do that,
    > because you have to have rules in how you store xml in a relational database.
    >
    > I think that's also the reason there are no tools to do that.
    > So can't help you there.
    Terry P, Dec 3, 2004
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marvin_123456

    "Memory leak" in javax.xml.xpath.XPath

    Marvin_123456, Jul 29, 2005, in forum: Java
    Replies:
    4
    Views:
    1,963
    jan V
    Jul 29, 2005
  2. Alastair Cameron
    Replies:
    1
    Views:
    7,390
    SQL Server Development Team [MSFT]
    Jul 8, 2003
  3. Anna
    Replies:
    0
    Views:
    514
  4. goog
    Replies:
    0
    Views:
    503
  5. Jakub =?UTF-8?B?S3XFum1h?=

    SQL to HQL translation problem

    Jakub =?UTF-8?B?S3XFum1h?=, Sep 23, 2007, in forum: Java
    Replies:
    2
    Views:
    952
    Lars Enderin
    Sep 23, 2007
Loading...

Share This Page