Trying to evaluate xpath myself sort-of

Hi;

In our program we will get an XPath statement such as:
${data}/SalesProject[customer/CUSTCAT=${series}/customer/CUSTCAT]

Where ${data} and ${series} both stand for a XPathNavigator so each is 
basically a specific node in a list of nodes that another XPath statement is 
returning.

To evaluate this we basically build from the right to the left, stripping 
off ]) fromt he far right to keep it balanced. So we do:

string str = navSeries.SelectSingleNode("self::node()/customer/CUSTCAT");
object value = 
navData.SelectSingleNode("self::node()/}/SalesProject[customer/CUSTCAT=" + 
str);

And the above works great. But, the whle thing falls apart when the XPath 
passed in is:
count(${data}/SalesProject[customer/CUSTCAT=${series}/customer/CUSTCAT])

because that becomes count("abc") - if the first node that matches the inner 
part above is "abc".

So, any idea on how to handle this so that count will work? 

We are iterating through navSeries and for each navSeries entry we create 
and iterate through navData and for each of those iterations we need to run 
the inner XPath and return it's value (to place in a report).

-- 
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm


0
thielen (152)
11/16/2007 4:16:00 AM
dotnet.xml 7266 articles. 0 followers. Follow

4 Replies
434 Views

Similar Articles

[PageSpeed] 11

Hello Dave,

We need to perform more research on this issue . We will reply here as soon 
as possible. 
If you have any more concerns on it, please feel free to post here. 

Thanks for your understanding! 
Best regards, 

Wen Yuan
Microsoft Online Community Support 
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

0
v-wywang (104)
11/16/2007 1:32:14 PM
Hello Dave
Thanks for your waiting.

I'm sorry, but I'm not sure I have understood this issue completely. 
Could you say more about what you mean about evaluating the XPath yourself, 
please?

I think in order to do this you will need to build a parse tree of the 
expression then evaluate it accordingly.

i.e. 
count(${data}/salesproject[customer/custcat=${series}/customer/custcat]) 
would become (my made up syntax)

eval_expression = count
                eval_variable = ${data}  
                                eval_xpath = data/salesproject
                                                eval_expression = filter 
                                                                eval_xpath 
= customer/custcat
                                                                
eval_variable = ${series}
                                                                            
    eval_xpath = /customer/custcat

Walk the tree evaluating each XPath, expression or variable substitution.

Or

We could write code that knows how to replace ${} variables with the actual 
value then use XPathNavigator.Evaluate() to eval the expression.

Hope this helps.
Best regards,

Wen Yuan
Microsoft Online Community Support 
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

0
v-wywang (104)
11/19/2007 8:59:50 AM
Yes, I am doing what you suggest in breaking it out. The problem is, how do I 
know that count wants a list of nodes as opposed to the node value?

I would like to replace the ${var} value with the actual value - but it is 
to an XPathNavigator element so how do I get the xpath that represents the 
present node on for an XPathNavigator object?

-- 
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm




"WenYuan Wang [MSFT]" wrote:

> Hello Dave
> Thanks for your waiting.
> 
> I'm sorry, but I'm not sure I have understood this issue completely. 
> Could you say more about what you mean about evaluating the XPath yourself, 
> please?
> 
> I think in order to do this you will need to build a parse tree of the 
> expression then evaluate it accordingly.
> 
> i.e. 
> count(${data}/salesproject[customer/custcat=${series}/customer/custcat]) 
> would become (my made up syntax)
> 
> eval_expression = count
>                 eval_variable = ${data}  
>                                 eval_xpath = data/salesproject
>                                                 eval_expression = filter 
>                                                                 eval_xpath 
> = customer/custcat
>                                                                 
> eval_variable = ${series}
>                                                                             
>     eval_xpath = /customer/custcat
> 
> Walk the tree evaluating each XPath, expression or variable substitution.
> 
> Or
> 
> We could write code that knows how to replace ${} variables with the actual 
> value then use XPathNavigator.Evaluate() to eval the expression.
> 
> Hope this helps.
> Best regards,
> 
> Wen Yuan
> Microsoft Online Community Support 
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no rights.
> 
> 
0
thielen (152)
11/19/2007 4:38:02 PM
Hello Dave,
Thanks for your reply.

> how do I know that count wants a list of nodes as opposed to the node 
value?
We may check it by ourself. If eval_expression is "count", we need a list 
of nodes instead of node.

>how do I get the xpath that represents the present node on for an 
XPathNavigator object?
I'm afraid it is different to get XPath from current node. But we can 
retrieve it from the Root element. For example:

static public string getXpath(XPathNavigator xpn)
        {            
            StringBuilder sb = new StringBuilder();
            do
            {
                if (xpn.NodeType == XPathNodeType.Root)
                {
                    sb.Insert(0, "/");
                    break;
                }

                if (xpn.NodeType == XPathNodeType.Element)
                {
                    int position = getPosition(xpn.Clone());                
    
                    sb.Insert(0, 
string.Format("/{0}[{1}]",xpn.Name,position));
                    continue;
                }
            }
            while (xpn.MoveToParent());
            return sb.ToString();
        }

        static public int getPosition(XPathNavigator xpn)
        { 
            int position =1;
            while (xpn.MoveToPrevious())
                position++;
            return position;
        }


Hope this helps. Please feel free to update here again, if there is 
anything we can help with. We are glad to assist you.

Have a great day,
Best regards,

Wen Yuan
Microsoft Online Community Support 
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

0
v-wywang (104)
11/20/2007 11:22:49 AM
Reply:

Similar Artilces:

How do I delete rows based upon the content (without sorting the .
After importing an ASCII print file, I'm now trying to get rid of the headers and footers. Any suggestions on how to do this in a automated fashion? Try something like this: http://www.vbaexpress.com/kb/getarticle.php?kb_id=20 **** Hope it helps! **** ~Dreamboat Excel VBA Certification Coming Soon! www.VBAExpress.com/training/ ******************************** "cev" <cev@discussions.microsoft.com> wrote in message news:5C114D60-7FED-4B5E-BDCE-96F803BC83E5@microsoft.com... > After importing an ASCII print file, I'm now trying to get rid of the headers > and ...

trying this out
This is a test posting. On Tue, 13 Nov 2007 16:06:51 +0800, "hmmmm" <bobo123@dotdot.dyndns.org> wrote: >This is a test posting. > Please use microsoft.public.test or microsoft.public.test.here for your testing. This is a working newsgroup. If you have questions about an Access database, please post them. John W. Vinson [MVP] ...

I am trying to round up to the nearest 25 cents
I am trying to round a money value to the nearsest 25 cents and it keeps rounding to the nearest dollar HELP Try =CEILING(A1, 0.25) In article <2DB8F007-1E27-4A48-923B-C7D4D0238B5E@microsoft.com>, sypher <sypher@discussions.microsoft.com> wrote: > I am trying to round a money value to the nearsest 25 cents and it keeps > rounding to the nearest dollar HELP =ROUND(A1*4,0)/4 -- HTH Bob Phillips "sypher" <sypher@discussions.microsoft.com> wrote in message news:2DB8F007-1E27-4A48-923B-C7D4D0238B5E@microsoft.com... > I am trying to round a mone...

Trying to clear up Received but not invoiced report
I am trying to clean up the received not invoiced items. The problem began with entering a purchase order and then not matching the invoice to the items received agaisnt the purchase order. SO we thought that doing a returned transaction entery would solve the problem. The only thing is now the return shows up on our Received/ Not invoiced report. And the report is becoming a huge mess and difficult to use. What is the best way to clear up items that have been received but were not matched and already paid through the invoice entery? There is a knowledgebase article on this very thing av...

Sorting in Excel
Hi. I have in sheet1 in Excel 5 columns with data. The A column has names, the B age, the C skills, the D salary and the E a code number (as text). Every few days I add some new names at the end of A column (also the other data in B,C,D,E) and sometimes I delete a few names. I would like to find a formula to transfer all those data in sheet2, exactly the same way, but in ascending order by the name. (With few words I try to find a way to auto sort and transfer some data.) Th. I would do this by writing a macro to: 1. Clear space for a sorted copy of your table. 2. Copy the ...

send/receive (2nd try)
New computer. Microsoft XP Home. Microsoft Office XP Small Business 2002. Earthlink dial-up account. Two e- mail accounts. After opening Outlook, 1st send/receive (option 3, all accounts) usually prompts for both passwords, downloads messages, all good. Next time, though, no prompt for account 2, error cannot connect to server, account 1 usually gets messages. Every five minute send/receive option eventually degenerates to cannot connect to server errors for both accounts. Meanwhile internet browsing slows to a crawl. Any ideas? ...

How do I cancel a msg Outlook keeps trying to send unsuccessfully?
How do I cancel an "in process" email Outlook keeps trying to send unsuccessfully due to a huge email message I tried to send with way too many attachments? It's stuck in "send" mode, and as a result, I can't send any emails because Outlook cannot get past trying to send this message. How do I cancel a pending outbox transmission while it's trying to send? I've tried everything I can think of to no avail. Please help! Angelczech wrote on Fri, 12 March 2010 07:32 > How do I cancel an "in process" email Outlook keeps trying to send ...

Embed tags in email for purposes of sorting
Hi, I have a question that I couldn't find an answer to searching through the forum. I'm a bit new to outlook so my apolgies if I missed the answer in my search. I'm an architect and work on a large number of projects concurrently and would like to be able to automatically sort my email by project. Currently I have some rules set up but I get a lot of email from the same sources related to different projects. I can't find any real common thread to sort messages but would like to develop some method of sorting my email by project. One method I would like to try and that should...

trying to insert a 0 in front of zipcode
Hello, I do not use excel at all so i have no clue! I have a list of daycares that i want to create mailing labels with...about 700 of them but the problem is my zipcode column there needs to be a zero in front of all 700 zipcodes how to i insert a zero in front of them without having to type it into each box? the other question is can i print labels directly from excel or do i have to go thru ms word? thanks Greg One of these 1) format the cells with custom format 00000 2) format the cells with Special / Zip Codes 3) format the cells as Text 4) begin all zip codes with an sin...

Sort WBS Codes
I have WBS codes exported from project, how do I sort so that eg 1.8.3 comes before 1.8.10. Obviously text sorting will put the 1.8.10 first. If you add some columns after the column with the WBS codes, you ca select the WBS column and do a Text To Columns funtion from the dat menu. Choose delimited and select a period as the delimitor. The sort by the new columns. You can then delete these columns. You may want to copy the WBS column first so you don't have to paste i back together after the sort. -- Message posted from http://www.ExcelForum.com Hi John you may apply the proce...

error message when trying to install WMP 10 or 11
My operating system is Windows XP Home Edition 2002. I'm trying to download either WMP 10 or 11 and I get a message saying it was not possible to complete setup, see webhelp for more assistance, however there is no additional information when I click Web help. the Error message is 8007F0DA. Can anyone help me? Thanks. On Tue, 30 Mar 2010 07:54:01 -0700, Nate <Nate@discussions.microsoft.com> wrote: > >My operating system is Windows XP Home Edition 2002. I'm trying to download >either WMP 10 or 11 and I get a message saying it was not possible to &g...

Try or TRY
Hello, Will there be any opitmization or ... when we use INT or TRY macros instead of int or try ? Which one is better to be used? Thanks, JSmith "JSmith" <jsmithmitra@yahoo.com> wrote in message news:%23G1sOVdoEHA.692@TK2MSFTNGP12.phx.gbl... > > Hello, > > Will there be any opitmization or ... when we use INT or TRY macros instead > of int or try ? Which one is better to be used? http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_exceptions.3a_.converting_from_mfc_exception_macros.asp -- Jeff Partch [VC++ MVP] FYI, TRY ...

error message when trying to delete messages in inbox
I cannot delete messages in my email inbox. When attempting to delete messages, Outlook says "The messaging interface has returned an unknown error. If the problem persists, restart Outlook. I continue to get the message even though I restarted Outlook. My mail works fine, but I just cannot delete anything. Does someone know a solution? Can you delete them if you hold shift as you delete? How many items are in the deleted items folder? Are you using any type of AV scanner on the message store? -- Diane Poremsky [MVP - Outlook] Author, Teach Yourself Outlook 2003 in 24 Hours Coa...

Problem trying to export e-mail messages
When I go into Windows Mail and export my messages, the export completes but then I go and the folders don't match my existing e-mail folders. There are folders showing which I had deleted months ago. Could it be a corrupt file? How can I just transfer the e-mail messages I need to a new PC with Windows 7? Thanks> Windows Mail uses internal mail folder names that may not correspond exactly to the folder name in the user interface. What are you doing with your Windows Mail messages in Windows 7? Windows Mail was not designed to run on Windows 7. --=20 Gary VanderMole...

try/catch vs TRY/CATCH
Hi, What is in your opinion the preferred way of doing exception handling for MFC objects (such as the CFile)... the try/catch mechanism or the MFC based TRY/CATCH macros? Thanks Adeel Use try/catch. I don't recall what TRY/CATCH does but, basically, that was provided before VC++ had full support fro try/catch. -- Jonathan Wood SoftCircuits Programming http://www.softcircuits.com "Adeel" <dontWantSpam@All> wrote in message news:ORLqQz3fGHA.4568@TK2MSFTNGP03.phx.gbl... > Hi, > > What is in your opinion the preferred way of doing exception handling for ...

How to sort CListCtrl without changing the per-item data?
Hi, I'm using visual c++ 6. I want to sort the CListCtrl. But I don't want to use SetItemData because I want to use the per-item data in another place. Can I sort the CListCtrl without changing the per-item data? Thanks in advanced. You could use a virtual list control and then just sort your external data (any way you want actually). Tom "bucher" <bucher@xxxx.com> wrote in message news:eQ3r7AUkHHA.4676@TK2MSFTNGP02.phx.gbl... > Hi, > > I'm using visual c++ 6. I want to sort the CListCtrl. But I don't want to > use SetItemData because I ...

Trying to finish up a worksheet function (if/or??)
Okay, here are the details and the exact data: A12 thru A17 = Income Source (text, user defined [examples would be Social Security, Pension, etc.]) B12 thru B17 = Amount Received (will be currency in $dddd.cc format) C12 thru C17 = Tax Deductible? (currenty have a drop-down list option, YES or NO) A18 = Subtotal (text) B18 = Subtotal (calculated sum of above columns) C18= [empty] A20 = Choose an Investor (text) B20 = Investor name (from drop down list) C20 = Mark up amount (i.e., 125%, would like it to auto fill from the investor chosen) A22 = Total (text) B22 = Total (calculated su...

Run Time error when trying to use DMax on a line value
Please can someone help me with run time error I am getting when I try to use a DMax function on a LineID control in a subform. I have a main form frmDeliveries and a subform sfrmDeliveryDetails They are linked on master and child by a DeliveryID control. On the sfrmDeliveryDetails BeforeUpdate I entered : Private Sub Form_BeforeInsert(Cancel As Integer) Me![LineID] = Nz(DMax("[LineID]", "[sfrmDeliveryDetails]"), 0) + 1 End Sub (which I modified from a previous posting) When I try to enter a selection from a Productscombo on the sfrmDeliveriesDetails I get a Run Ti...

Try that critical pack from Microsoft Corporation
--zyqwganxt Content-Type: multipart/related; boundary="ozwztwhan"; type="multipart/alternative" --ozwztwhan Content-Type: multipart/alternative; boundary="gmqsphxspxalotm" --gmqsphxspxalotm Content-Type: text/plain Content-Transfer-Encoding: quoted-printable MS User this is the latest version of security update, the "October 2003, Cumulative Patch" update which fixes all known security vulnerabilities affecting MS Internet Explorer, MS Outlook and MS Outlook Express as well as three new vulnerabilities. Install now to help protect your computer. Thi...

97 to 2002 now cannot sort records
I converted to 2002 and now i cannot sort records in access 2002. If I take the database to a machine running access97 works fine. Anybody got any suggestions??? ...

trying to email with publisher
Can someone please help me configure this thing!!! I can send a regular email through Windows mail with no problem. I cannot configure Outlook, even though I am using the same info as I used in windows mail. And, most importantly.... I cannot send a Publisher email in either one!!! What in the worl am I doing wrong? They won't go directly to windows mail, even though I have it as my default mail. They continue to go into Outlook even though I have it NOT as my default. They won't send from Outlook, And when I import them into Windows mail, they won't send. Arrrggghhhh! I am...

Sort shapes in a stencil (Visio 2002-Any version is fine as well)
Hi all , Is there any way to sort the shapes in a stencil based on its name. Or if it can be sorted aat all on any property please let me know . Thanks in advance. Biju If you have the stencil open for edit, you can manually reorder the shape masters by dragging them. There is no property to sort by. -- Mark Nelson Microsoft Corporation This posting is provided "AS IS" with no warranties, and confers no rights. "Biju Mathew" <exx_2000@yahoo.com> wrote in message news:%23jo%232YWAEHA.2040@TK2MSFTNGP12.phx.gbl... > Hi all , > Is there any way to sort the...

sort & move
using Office 97 SR2 How do I sort and have the cell references also move, e.g. similar to a cut/paste which moves the referenced cells? ...

I am trying to write a macro using If...Then
I am trying to write a macro that will look at the value in column G. If that value is blank or zero, then select the entire row and delete it. Then I want it to populate columns A with a number "111119" and column H with "TEXT" Here's what I tried, but it's not working. (There are other sorts, etc. that precede this item in the macro, that seem to be working fine.) If Range("g:g") < 1 = true Then ActiveWorkbook.Worksheets("Tab3 Upload").Rows.Select Selection.Delete End If If Range("b:b") >...

Sorting
Is it possible to have an empty row appear between items in a sort? i.e all my Bill's are grouped then an empty row before all my Fred's. one way. you could insert a row for each with just the name in a white font. Regards Bill K "Tammy" <anonymous@discussions.microsoft.com> wrote in message news:1b8201c4aca1$2a9338a0$a401280a@phx.gbl... > Is it possible to have an empty row appear between items > in a sort? i.e all my Bill's are grouped then an empty row > before all my Fred's. ...