|
next
|
 Subject: Xquery to find sample data file for testing Author: Neal Walters Date: 29 Jun 2005 10:42 AM
|
In a previous post entitled "XQuery on all XML Files in a Directory?",<br>
Ivan helped me use Xquery to read all files in a directory. <br>
<br>
Today, I'm tring to find a sample Amazon order that has more one line line item. The following code works, but I have two questions: <br>
<br>
declare namespace ext = "FileUtils";<br>
declare function ext:listFiles($path as xs:string) as xs:string* external;<br>
declare variable $dirname as xs:string := "file:///c:/Odimo/Amazon/FileDrop/WorldOfWatches/Order__89/Doc_Original_Backup/";<br>
<OrderReport><br>
{<br>
for $filename in fn:tokenize(ext:listFiles($dirname), ",")<br>
[fn:matches(., ".xml")]<br>
, $rootel in doc(fn:concat($dirname, "/", $filename))<br>
return<br>
<filename name='{$filename}'><br>
<OrderID>{$rootel//Message/OrderReport/AmazonOrderID}</OrderID><br>
<ItemCount>{count($rootel//Message/OrderReport/Item)}</ItemCount><br>
</filename><br>
}<br>
</OrderReport><br>
<br>
Question 1: <br>
Is there a way to limit the output to only those files (orders) that have a count >= 2 {count($rootel//Message/OrderReport/Item)? <br>
<br>
Question 2: <br>
if I don't put two slashes here: <br>
<OrderID>{$rootel//Message/OrderReport/AmazonOrderID}</OrderID> <br>
I don't get anything. Why doesn't one slash work between $rootel and Message? From Stylus Studio, I can open a source doc, go to tree view, <br>
and generate the following xpath: <br>
/AmazonEnvelope/Message[1]/OrderReport[1]/AmazonOrderID[1] <br>
<br>
Thanks! <br>
Neal Walters <br>
<a href="http://Biztalk-Training.com">http://Biztalk-Training.com</a> <br>
<br>
<br>
<br>
<br>
|
|
|