Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Problem with an XQuery statement

From: Cameron.MacNeil.024@-----.---
To: NULL
Date: 6/6/2008 4:37:00 AM
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!


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent