473,396 Members | 1,689 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Problem with an XQuery statement

Hi folks, hopefully you'll be able to help me with this problem I'm
having.

I have a bunch of xml files with format similar to the following:

<?xml-stylesheet href='syntax.xsl' type='text/xsl'?>
<syntax xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="syntax.xsd">
<syntaxrule>
<syntaxelement>function</syntaxelement>
<terms>
<non_terminal>keyword</non_terminal>
<non_terminal>open_paren</non_terminal>
<non_terminal>level_expression</non_terminal>
<sequence min="0" max="1">
<definitions>
<terms>
<non_terminal>comma</non_terminal>
<non_terminal>member_expression</non_terminal>
</terms>
</definitions>
</sequence>
<non_terminal>close_paren</non_terminal>
</terms>
</syntaxrule>
</syntax>

All of these xml files are stored in a db2 database. Also inside the
database are other terms that I can match up with the non_terminal
tags in these xml files. I used xquery to replace the <non_terminal>
tags with terminal ones where applicable:

<?xml-stylesheet href='syntax_xquery.xsl' type='text/xsl'?>
<syntax xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<syntaxrule>
<syntaxelement>function</syntaxelement>
<terms>
<terminal>period</terminal>
<terminal>(</terminal>
<non_terminal>level_expression</non_terminal>
<sequence min="0" max="1">
<defintions>
<terms>
<non_terminal>comma</non_terminal>
<non_terminal>member_expression</non_terminal>
</terms>
</definitions>
</sequence>
<terminal>)</terminal>
</terms>
</syntaxrule>
</syntax>

The problem I'm having is that my xquery statement will only look at
the non_terminal fields directly under the syntaxrule/terms tags, and
not the ones under the sequence/definitions/terms tags. Does anyone
know how I could adjust the query to find all of the non_terminal
tags? My XQuery code is shown below.

"XQUERY let $keyword := db2-fn:sqlquery('SELECT SYNTAX_ELEMENT FROM
SYNTAX_ELEMENTS WHERE CATEGORY = ''symbol'' or CATEGORY =
''keyword''') for $element in db2-fn:sqlquery('SELECT SYNTAX_ELEMENT
FROM SYNTAX_ELEMENTS WHERE CATEGORY = ''function'' AND ELEMENT_NAME =
''" + elementName + "''') return <syntaxrule>{$element/syntaxrule/
syntaxelement} <terms>{for $term in $element/syntaxrule/terms/* return
if (count(for $keyterm in $keyword where $keyterm/syntaxrule/
syntaxelement = $term return $keyterm) >= 1) then for $keyterm in
$keyword where $keyterm/syntaxrule/syntaxelement = $term return
<terminal>{data($keyterm/syntaxrule/terms)}</terminal> else $term}</
terms></syntaxrule>"

Thanks alot!
Jun 27 '08 #1
0 1382

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

Similar topics

0
by: Benjamin G. Jones | last post by:
I am having a very basic problem with XQuery. I want to use an XQuery API in Java (either Saxon or Qexo), and I have an XQuery expression that works as expeced from the command line if I specify...
0
by: Tony Lavinio | last post by:
Dear Stylus Studio Friends, The new year is scarcely one month old, but we already have lots to report! For starters, there's Stylus Studio 6 Release 2. The latest release of Stylus Studio...
0
by: Stylus Studio | last post by:
DataDirect XQuery(TM) is the First Embeddable Component for XQuery That is Modeled after the XQuery API for Java(TM) (XQJ) BEDFORD, Mass.--Sept. 20, 2005--DataDirect Technologies...
8
by: Clamps | last post by:
So I've been reading about XQuery, but cannot find a dll or namespace download to use the technology in vs.net 2002 or 2003. Any directions would be great. -- "If I'm the president, we're going...
1
by: amessimon | last post by:
Hi I'm having a problem querying an XML document using Xquery, i dont know if this is the right place to post, but i couldnt find an xquery newsgroup. Ive also posted in the xml group. Ive not...
2
by: tammo.mueller | last post by:
Hi, I'm trying to execute a xquery statement and I get always errors. It seems that only the prolog section is giving me errors. If I want to declare a namespace the xquery processor is coming...
4
by: Suma | last post by:
I dont know xquery , so i was thinking someone in the forum will help me out with this easy question Suppose I have an instance document given below <Root> <Author Name='Alice' NumberOfBooks =...
4
by: Pascal Sartoretti | last post by:
Hello, I want to process big files (e.g. 100 MB) with XQuery. Are there XQuery processors that work in a "SAX-like" way (and not DOM-like), i.e. which don't assume that they have everything in...
0
by: engelenfrederik | last post by:
Hello all, I ran into an interesting SQL/XML question yesterday. A customer wants to make a part of the relational data available through a webservice as XML. This seemed like the perfect...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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,...

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.