Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / July 2007

Tip: Looking for answers? Try searching our database.

XPath question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
--- - 06 Jul 2007 15:50 GMT
I've got a data schema which represents an xml document like:
...
<purchases>
<purchase>
     <category></category>
     <item></item>
     <price></price>
</purchase>
</purchases>
...

There can be an unlimited number of purchases.

I'd like to create a repeating table which lists all the categories
and sums up the prices.  Something similar to the SQL statement:
Select category, sum(price) from purchases group by category.

Is this possible with my existing schema?

I've though about adding another repeating element:
<category_name></category_name>

And adding categories as purchase/category is modifed, then I can
create a repeating table of category_name, with an expression box to
sum up the totals.  This is where the problem came up.  With a schema
like I've shown, I can't seem to get what I want.  I tried an XPath
expression like sum(../../purchase[category=category_name]/price), but
infopath complains that purchase/category_name cannot be found.  It
appears that items referenced in the []'s are relative to purchase?
instead of the initial context of the xpath.  Can anyone help?
Greg Collins [InfoPath MVP] - 06 Jul 2007 23:34 GMT
category_name can't be found because it's not there. It's looking for it to be a sibling to category the way you wrote your XPath. You need to give it a more explicit pointer to the location of that field.

As for the list you want... you will need to have a repeating section bound to purchase, but filtered to only show a unique list of categories. Then it would should the category name, and do the sum like you are trying to figure out.

Signature

Greg Collins [Microsoft MVP]
Visit Braintrove ( http://www.braintrove.com )
Visit InfoPathDev ( http://www.InfoPathDev.com )

--- - 09 Jul 2007 15:59 GMT
On Jul 6, 6:34 pm, "Greg Collins [InfoPath MVP]"
<gcollins_AT_msn_DOT_com> wrote:
> category_name can't be found because it's not there. It's looking for it to be a sibling to category the way you wrote your XPath. You need to give it a more explicit pointer to the location of that field.
That's the problem I'm having, how do I explicitly reference the
initial category_name?  The context for the XPath expression starts
with the category_name node, I then back up the tree and descend into
the purchase node.  How do I refer to the original node?

> As for the list you want... you will need to have a repeating section bound to purchase, but filtered to only show a unique list of categories. Then it would should the category name, and do the sum like you are trying to figure out.

How do I specify a unique filter?  The only filter options I seem to
have available are XPath expressions, and I have no idea how to
express uniqueness with XPath.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.