User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the XML, XSLT and XPATH section within the Software Development category of DaniWeb, a massive community of 455,973 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,828 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our XML, XSLT and XPATH advertiser: Programming Forums
Views: 4617 | Replies: 32
Reply
Join Date: Oct 2007
Posts: 31
Reputation: ssahil11 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
ssahil11 ssahil11 is offline Offline
Light Poster

Re: Xquery in DB2

  #21  
Dec 28th, 2007
I have a problem while selecting XML data. The XML data elements have different namespaces and my query could not retrieve all records. How do I retrieve all XML records using XQuery. The XQuery I am trying out is as given below.

XQuery db2-fn:xmlcolumn('BUSINESSES.XMLINFO')/businessesname
Reply With Quote  
Join Date: Oct 2007
Posts: 31
Reputation: ssahil11 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
ssahil11 ssahil11 is offline Offline
Light Poster

Re: Xquery in DB2

  #22  
Jan 2nd, 2008
I have a problem while selecting XML data. The XML data elements have different namespaces and my query could not retrieve all records. How do I retrieve all XML records using XQuery. The XQuery I am trying out is as given below.

XQuery db2-fn:xmlcolumn('BUSINESSES.XMLINFO')/businessesname
Reply With Quote  
Join Date: Oct 2007
Posts: 76
Reputation: dilasing is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
dilasing dilasing is offline Offline
Junior Poster in Training

Re: Xquery in DB2

  #23  
Jan 3rd, 2008
The problem here is due to the company namespaces. You need to rewrite your XQuery as given below.

XQuery db2-fn:xmlcolumn('BUSINESSES.XMLINFO')/*:businessesname
Reply With Quote  
Join Date: Oct 2007
Posts: 31
Reputation: ssahil11 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
ssahil11 ssahil11 is offline Offline
Light Poster

Re: Xquery in DB2

  #24  
Jan 4th, 2008
Is there a way I can return XML data for selected namespace?
Reply With Quote  
Join Date: Oct 2007
Posts: 76
Reputation: dilasing is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
dilasing dilasing is offline Offline
Junior Poster in Training

Re: Xquery in DB2

  #25  
Jan 8th, 2008
DB2 treats XQuery as a first-class language, allowing users to write Xquery expressions directly rather than requiring that users embed or wrap XQueries in SQL statements. DB2's query engine processes XQueries natively, meaning that it parses, evaluates, and optimizes XQueries without ever translating them into SQL behind the scenes. You can check http://www.ibm.com/developerworks/db...-0603saracco2/ to know how to use several popular SQL/XML expressions to query DB2 XML data XQuery.
Reply With Quote  
Join Date: Oct 2007
Posts: 31
Reputation: ssahil11 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
ssahil11 ssahil11 is offline Offline
Light Poster

Re: Xquery in DB2

  #26  
Jan 17th, 2008
Can any one explain about the expressions that XQuery provides?
Reply With Quote  
Join Date: Oct 2007
Posts: 76
Reputation: dilasing is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
dilasing dilasing is offline Offline
Junior Poster in Training

Re: Xquery in DB2

  #27  
Jan 21st, 2008
XQuery provides several different kinds of expressions that may be combined in any way you like. Each expression returns a list of values that can be used as input to other expressions. The result of the outermost expression is the result of the query.
There are manly two important kinds of XQuery expressions:

i) FLWOR expressions
ii) Path expressions.


A FLWOR expression is much like a SELECT-FROM-WHERE expression in SQL -- it is used to iterate through a list of items and to optionally return something that is computed from each item. A Path expression, on the other hand, navigates through a hierarchy of XML elements and returns the elements that are found at the end of the path.


Like a SELECT-FROM-WHERE expression in SQL, an XQuery FLWOR expression may contain several clauses that begin with certain keywords. The following keywords are used to begin clauses in a FLWOR expression:
· for: Iterates through an input sequence, binding a variable to each input item in turn
· let: Declares a variable and assigns it a value, which may be a list containing multiple items
· where: Specifies criteria for filtering query results
· order by: Specifies the sort order of the result
· return: Defines the result to be returned
For example FLWOR expression to retrieve client fax data:
xquery for $y in db2-fn:xmlcolumn('CLIENTS.CONTACTINFO')/Client/fax return $y
A Path expression in XQuery consists of a series of "steps," separated by slash characters. In its simplest form, each step navigates downward in an XML hierarchy to find the children of the elements returned by the previous step. Each step in a path expression may also contain a predicate that filters the elements that are returned by that step, retaining only elements that satisfy some condition.

For example Path expression to retrieve client fax data:

xquery
db2-fn:xmlcolumn('CLIENTS.CONTACTINFO')/Client/fax
Reply With Quote  
Join Date: Oct 2007
Posts: 31
Reputation: ssahil11 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
ssahil11 ssahil11 is offline Offline
Light Poster

Re: Xquery in DB2

  #28  
Jan 24th, 2008
We are storing contact information of clients as XML document in a DB2 table. In the XML document we are storing zip code also. How can I retrieve the XML documents of contact information of persons who live under particular zip code?
Reply With Quote  
Join Date: Oct 2007
Posts: 76
Reputation: dilasing is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
dilasing dilasing is offline Offline
Junior Poster in Training

Re: Xquery in DB2

  #29  
Jan 30th, 2008
The XQuery where clause enables you to filter results based on the value of the zip element in your XML documents. Consider we stored below mentioned xml document in CONTACTINFO column of CLIENTS table.
<client>
<Address>
<street>5401 Julio Ave.</street>
<city>San Jose</city>
<state>CA</state>
<zip>95116</zip>
</Address>
<Phone>
<work>4084630000</work>
<home>4081111111</home>
<cell>4082222222</cell>
</phone>
<fax>4087778888</fax>
<email>test@yahoo.com</email>
</client>
Below example explains how to obtain only the addresses of the customers who live in zip code 95116 using FLWOR expression.
xquery
for $y in db2-fn:xmlcolumn('CLIENTS.CONTACTINFO')/Client/Address
where $y/zip="95116"
return $y
The “for” clause binds the variable “$y” to each address in turn. The “where” clause contains a small path expression that navigates from each address to its nested zip element. The “where” clause is true (and the address is retained) only if the value of this zip element is equal to 95116.
The same result could be obtained by adding a predicate to the path expression,

xquery db2-fn:xmlcolumn('CLIENTS.CONTACTINFO')/Client/Address[zip="95116"]

You can get the e-mail information for customers who live in a specific zip code in New York City (10011) or anywhere in the city of San Jose using following queries:

Using FLWOR expression:
xquery
for $y in db2-fn:xmlcolumn('CLIENTS.CONTACTINFO')/Client
where $y/Address/zip="10011" or $y/Address/city="San Jose"
return $y/email

Using path expression:
xquery
db2-fn:xmlcolumn('CLIENTS.CONTACTINFO')/Client[Address/zip="10011"
or Address/city="San Jose"]/email;

For more information you can follow the link:

http://www.ibm.com/developerworks/db...m-0604saracco/
Reply With Quote  
Join Date: Oct 2007
Posts: 31
Reputation: ssahil11 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
ssahil11 ssahil11 is offline Offline
Light Poster

Re: Xquery in DB2

  #30  
Feb 6th, 2008
I am using DB2 and storing the contact information of people in an XML column. I need to transform the resultant XML data in to HTML format. Can anyone help me?
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb XML, XSLT and XPATH Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the XML, XSLT and XPATH Forum

All times are GMT -4. The time now is 9:14 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC