473,685 Members | 2,906 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

xpath to sql translation

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
Jul 20 '05 #1
8 7579
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.
Jul 20 '05 #2
On Wed, 01 Dec 2004 14:24:45 +0100, Tjerk Wolterink
<tj***@wolterin kwebdesign.com> 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
Jul 20 '05 #3
Jeff Kish wrote:
On Wed, 01 Dec 2004 14:24:45 +0100, Tjerk Wolterink
<tj***@wolterin kwebdesign.com> 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
assumption s 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.
Jul 20 '05 #4
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
Jul 20 '05 #5
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 <tj***@wolterin kwebdesign.com> wrote in message news:<41******* *************** @news.wanadoo.n l>...
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.

Jul 20 '05 #6
On 1 Dec 2004 18:44:50 -0800, te**********@co mpu-tech-inc.com (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
Jul 20 '05 #7
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 <tj***@wolterin kwebdesign.com> wrote in message news:<41******* *************** @news.wanadoo.n l>...
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.
Jul 20 '05 #8
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 <tj***@wolterin kwebdesign.com> wrote in message news:<41******* *************** *@news.wanadoo. nl>...
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.

Jul 20 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
6821
by: bdinmstig | last post by:
I refined my attempt a little further, and the following code does seem to work, however it has 2 major problems: 1. Very limited support for XPath features Basic paths are supported for elements, attributes, ".", and "..", plus also the "" predicate format is supported - however, only one predicate per path step is supported, and expr must be a relative path. 2. Poor performance
0
1920
by: gael.pegliasco | last post by:
Hi, How are you dear and nice helper :) ? I'm trying to test xpath with this simple program : import xml.dom.minidom from xml.xpath.Context import Context import xml.xpath
14
12168
by: inquirydog | last post by:
Hi- One frusterating thing for me with xsl is that I don't know how to make xslt throw some sort of exception when a value-of path does not exist. For instance, suppose I have the following line in xslt <xsl:value-of select="/blah/q" /> and my xml document does not have a node /blah/q. The output would
10
6116
by: Phani | last post by:
Hi all, I am new to XPath. I have a doubt in it. My xml is like this: <UserInfo> <Contacts> <Name>Chris Bob</Name> </Contacts>
7
1806
by: steve bull | last post by:
I have the following code snippet to read the colorRange attributes for the colorRangeSwatch in the xml file listed below. string expr = "/swatches/colorRangeSwatch/colorRange"; XmlElement crsElement = (XmlElement)m_colorRangeSwatchDoc.SelectSingleNode(expr); bool fr = bool.Parse(crsElement.GetAttribute("fixed").ToString()); The element returned is always the 1st, All Blue Colors, why doesn't the expression...
0
1272
by: Gramps | last post by:
Hi I am using C# and performing an XSL translation on a DOM like so XslTransform oXSL = new XslTransform(); oXSL.Load(Filename); oXMLOut=new XmlDocument() oXMLOut.Load(oXSL.Transform(oXMLIn,null)) where oXMLIn is an input parameter
5
4204
by: laks | last post by:
Hi I have the following xsl stmt. <xsl:for-each select="JOB_POSTINGS/JOB_POSTING \"> <xsl:sort select="JOB_TITLE" order="ascending"/> This works fine when I use it. But when using multiple values in the where clause as below
5
7926
by: Gnic | last post by:
Hi , I have an XmlDocument instance, I want to find a node in the xml, but I don't know it's path until runtime, for example <aaa> <bbb name="x"/> <aaa attr="y"> <ccc>sometext</ccc> </aaa>
3
3316
by: SD | last post by:
Hi, How can i get all the nodes with attribute Name = "Publisher" or Name="Administrator" using XPath query and C# for this xml doc? <GetRoleCollectionFromUser xmlns=\"http://schemas.microsoft.com/sharepoint/soap/directory/\"> <Roles> <Role ID=\"1073741826\" Name=\"Reader\" Description=\"....\" Type=\"2\" />
0
8507
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8773
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7589
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6431
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5792
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4302
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4523
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2938
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.