472,805 Members | 988 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,805 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 1353

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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.