[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

Need simple xquery help

adstech adstech at bresnan.net
Thu Dec 20 14:48:57 PST 2007


  Need simple xquery help
Given: 

Example.xml
____________________________________________________________________
<?xml version="1.0"?>
<pmcatalog>
	<manufacture>
		<mfg img="manufacturerlogos/arnelsonlogo.gif"
mfgID="G-mf-A.R._N-641" name="Nelson">
			<pmdata>
				<pmgroup>
					<keyword>pgroup8</keyword>
					<product>
						<pmn modelid="234">
						</pmn>
					</product>
				</pmgroup>
				<pmgroup>
					<keyword>pgroup1</keyword>
					<product>
						<pmn modelid="345">
						</pmn>
					</product>
				</pmgroup>
				<pmgroup>
					<keyword>pgroup2</keyword>
					<product>
						<pmn modelid="456">
						</pmn>
					</product>
				</pmgroup>
			</pmdata>
		</mfg>
		<mfg img="manufacturerlogos/barns.gif" mfgID="barnsid"
name="Barns">
			<pmdata>
				<pmgroup>
					<keyword>pgroup7</keyword>
					<product>
						<pmn modelid="567">
						</pmn>
					</product>
				</pmgroup>
				<pmgroup>
					<keyword>pgroup10</keyword>
					<product>
						<pmn modelid="890">
						</pmn>
					</product>
				</pmgroup>
				<pmgroup>
					<keyword>pgroup22</keyword>
					<product>
						<pmn modelid="556">
						</pmn>
					</product>
				</pmgroup>
			</pmdata>
		</mfg>
	</manufacture>
</pmcatalog>
____________________________________________________________________


The following query returns ALL the 'mfgs' - I don't understand why the
"where" doesn't restrict it to only the Nelson entry.

for $pmgroup in
doc("file:example.xml")/pmcatalog/manufacture/mfg/pmdata/pmgroup
where contains($pmgroup/keyword, "pgroup8") 
return $pmgroup/../../../mfg

1)  This returns mfg for Barns as well.  I don't understand.
2)  If I want to return a Node WITHOUT its children - how can I achieve
this?  The desired results for my query would be:

<mfg img="manufacturerlogos/arnelsonlogo.gif" mfgID="G-mf-A.R._N-641"
name="Nelson">
	<pmn modelid="234"></pmn>
	<pmn modelid="345"></pmn>
	<pmn modelid="456"></pmn>
</mfg>


I realize that I can "CONSTRUCT"  OUTPUT via:

return <mfg img='{$ pmgroup /../../../@img/string()}' mfgID='{$ pmgroup
/../../../@mfgID/string()}' name='{$ pmgroup /../../@name/string()}' >
etc...

But how does one retrieve only the node "header" (for lack of a term to use)
- without its subsequent children.  Picking and choosing nodes with their
attributes without the children.

Hopefully someone can show me the error of my ways :)
Thanx
Walt



PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.