Reusing XPathExpression in multiple iterations

Is there some reason why I shouldn't be able to use the same XPathExpression
simultaneously in multiple iterations?  The test below illustrates the
problem.  It seems that creating two XPathNodeIterators with the same
expression creates a coupling between the iterators so they always point to
the same position.  Anyone care to comment?

[Test]
public void ReuseCompiledExpr()
{
 XmlDocument doc = new XmlDocument();
 doc.LoadXml( "<Top> <A> <A1/> <A2/> </A > <B/> </Top>" );

 XPathNavigator nav = doc.CreateNavigator();
 XPathExpression expr = nav.Compile( "*" );

 nav.MoveToFirstChild(); // /Top
 XPathNodeIterator iter1 = nav.Select( expr );
 iter1.MoveNext(); // /Top/A
 XPathNodeIterator iter2 = iter1.Current.Select( expr ); // Replace expr
with "*" and it works!
 iter2.MoveNext(); // /Top/A/A1
 iter2.MoveNext(); // /Top/A/A2
 Assert.IsTrue( iter1.MoveNext() ); // /Top/B  <--- Returns false!
}

---
Steve


0
6/1/2004 6:36:12 PM
dotnet.xml 7266 articles. 0 followers. Follow

1 Replies
565 Views

Similar Articles

[PageSpeed] 25

You have to call Clone explicitly: XPathNodeIterator iter2 = 
iter1.Current.Select( expr.Clone() ); // Replace expr
Because there are no guaranties about concurrent usage of XPathExpression is 
not really a bug, but a usability issue. We will consider fixing it in the 
next version.


"Steve Taylor" <NOxxxlazyxxx@SPAMhotmail.com> wrote in message 
news:%2385bRdASEHA.1388@TK2MSFTNGP09.phx.gbl...
> Is there some reason why I shouldn't be able to use the same 
> XPathExpression
> simultaneously in multiple iterations?  The test below illustrates the
> problem.  It seems that creating two XPathNodeIterators with the same
> expression creates a coupling between the iterators so they always point 
> to
> the same position.  Anyone care to comment?
>
> [Test]
> public void ReuseCompiledExpr()
> {
> XmlDocument doc = new XmlDocument();
> doc.LoadXml( "<Top> <A> <A1/> <A2/> </A > <B/> </Top>" );
>
> XPathNavigator nav = doc.CreateNavigator();
> XPathExpression expr = nav.Compile( "*" );
>
> nav.MoveToFirstChild(); // /Top
> XPathNodeIterator iter1 = nav.Select( expr );
> iter1.MoveNext(); // /Top/A
> XPathNodeIterator iter2 = iter1.Current.Select( expr ); // Replace expr
> with "*" and it works!
> iter2.MoveNext(); // /Top/A/A1
> iter2.MoveNext(); // /Top/A/A2
> Assert.IsTrue( iter1.MoveNext() ); // /Top/B  <--- Returns false!
> }
>
> ---
> Steve
>
> 


0
yanl (33)
6/1/2004 8:39:04 PM
Reply:

Similar Artilces:

Not able to import multiple Fidelity accounts
I have two Fidelity accounts, a brokerage and an Educational Account. When I try to set up these accounts in Money 2006, none of the Education Account information is imported. Money 2006 sets up the two accounts, but there is no balance or transaction history for the Educational Account. It seems as though Money sees there is an account but is not able to access anything. It looks like I'll have to enter and update all Educational transactions manually. Any suggestions on how to resolve this? Thanks, John Money 2006 Deluxe, IE 6, XP SP2. I have 3 accounts at Fidelity - it works...

Multiple DBs sharing tables
Can we set up multiple databases to share information like customers or items. We have five companies setup in five dbs and the item list is similar enough that we could use one list and customers may be repeated across companies as well. if I could "point" all dbs to a single customer and item table we would only have to enter info 1 time. When we moved over to GP we loaded all of the information from each company into an excel workbook and then that was loaded into G/P. That gave us the ability to clean things up!! "S Meyer" wrote: > Can we set up multiple data...

Multiple Item query
I've read a few posts on this query and it looks like creating a table where I input the item numbers in it and linking it to the query seems to be a good way to get a lot of items in a query. Now what If I have hundreds of numbers I want to look up? do I input all 100 numbers into the table? Or what if it's like 10 numbers but I want create seperate queries for different groups of numbers, should I have 1 table for one group of numbers? What would be the easiest way for a novice to do this? It is easier to fill the table with just the values you need for the query you want to run, t...

Multiple results with Count
Hello Everybody, In Access 2003, I am trying to get multiple results in a query using Count with the same column and table as my source of data. So far I have been unsuccessful in bringing two results of Count onto a same query. For example: I have a list of amounts paid to different employees in a column. I want to count the rows base on two different criteria (i) rows with amounts more than $1000 each and (ii) rows with amounts less than $500. I want to get the results of these two criteria in same query but in two different fields with distinct names. What would be the structure of ...

Circular references? I iterate You what?!
first thanks to everyone for their help....I have reinstalled office and I still cannot use the reply group option. Next I have this error =(E16+E18)--I16 was defined as a circular reference but for the life of me I cannot see why. Some of my other formulae are also "circular" In English this equation should be (Overtime + overtime carried over from previous month) minus minus the hours holiday Why it is cicular I have no idea. It works if I change the itiration. so my question is in what way is this circular and how does itiration work? Thanks in advance Danny Hard to say...

Combining Multiple Files
Is there a way to combing multiple publisher files into one document without just copy and paste? Not within Publisher. -- JoAnn Paules MVP Microsoft [Publisher] "jwl713" <jwl713@discussions.microsoft.com> wrote in message news:5F8CE321-6981-4665-87CA-3FFA58BB531E@microsoft.com... > Is there a way to combing multiple publisher files into one document > without > just copy and paste? It is the preferred method. From the Edit menu, open the Office Clipboard, depending on your configuration you can collect 24 items. -- Mary Sauer MSFT MVP http://office...

Multiple Charts within 1 Chart Sheet
How can I place 2,3, or 4 charts within 1 chart sheet? I'd prefer not to use the embedded chart approach. Thanks. They will be embedded, but in the chart sheet, not in a work sheet. Select a blank cell that is itself surrounded by blank cells, and press the F11 key to make a blank chart sheet. Now make the charts you want to place on the chart sheet, and in the last step of the wizard, Location, select As Object In and choose the chart sheet from the drop down list. To move an existing chart, right click on it, choose Location from the pop up menu, and choose As Object In and select the ...

Linking a multiple spreadsheets to a master spreadsheet
I have looked for the solution to this, but have had no luck. I need to link multiple excel spreadsheets to a master spreadsheet, where each sheet on the master would represent one external spreadsheet. If the info on the external spreadsheets are changed, the master should reflect those changes and visa versa. I am using Excel 2007. If someone could point me in the right direction that would be great. Thanks! Excel doesn't work like this. It can pull the values from one cell to another via a formula, but it can't easily push the data from one cell to another (no matter where it'...

Setting up online services for multiple accounts at same bank
I'm having trouble establishing automatic updates for multiple accounts at the same bank. Specifically, I can't seem to automatically download transactions for my credit and my wife's credit both held with MBNA. I can set one up just fine, but Money doesn't seem to let me set the second one up. At least not intuitively. Any ideas? Thanks In microsoft.public.money, phudrick wrote: >I'm having trouble establishing automatic updates for multiple accounts at >the same bank. Specifically, I can't seem to automatically download >transactions for my cred...

Multiple Journal Entries
Frequently one of our users gets multiple listings in Journal from a single event. It doesn't seem to be related to the event and can be listed up to 11 times (the record). He is running Outlook 2003 on an XP sp1 Stinkpad. Our network is Novell/MS with Exchange 2000. We've tried updating client, re-installing Outlook, uninstalling ActiveSync, uninstalling Palm Desktop and hotsync, and several other time-consuming non-solutions. Any ideas? One more thing, he synchronizes all folders upon disconnection each evening. Thanks, Goatscape ...

Loading Data into Multiple sheets in 1 book
Loading Data into Multiple sheets in 1 book Hi All I have 2 questions 1. I am trying to automatically create a workbook with a number of sheets in it with different data. I see how the command mode allows you to feed data to a (one/first) sheet (C:\Program Files\Microsoft Office\Office\excel.exe" H:\':DETAIL.XFER.SHORT.FILENAME) but how do you get data to sheets 2 3 4 etc in the workbook? 2. Can you format the data going into the work sheet such that some of the data would have bold text? Thanks in advance Ralph Typically you do not import data into Excel via the command line. ...

How to generate a report from multiple lists in Excel 2003?
I have a workbook that I am trying to use as an accessory order form for a wireless phone company. The workbook is comprised as multiple worksheets, one for each manufacturer. There is a column that denotes the quantity of each item ordered. I would like to generate an order summary at the end of the workbook that is easily printable for our wharehouse staff to fill orders. If anyone has any suggestions, they would be greatly appreciated, as I have been racking my brain over this for about a week. -Thank You ...

macro to delete multiple rows
I have recorded, then modified, the following macro, which unprotects the sheet, aks if you are sure you want to delete the row, deletes the current row, copies down a cell in column A that numbers the row, and protects the sheet. Works fine, but if the user wants to delete not only the current row, but multiple rows below it also, the macro must be repeated. How can I accomplish deleting multiple rows, as indicated by the user? For example, rows 18 thru 20, or 29 thru 33, etc, or of course, just the current row, with the message box prompting the user for the number of rows to delete. Thanks...

Automating multiple signatures on new messages in Outlook 2003
I've set up three signatures for three separate accounts, and assigned them to the appropriate accounts. Whenever I click on "NEW" for a new message, it uses the default account and default signature. If I want to change accounts I click "Accounts" and select the account I want, but the default signature stays on the message, and I have to manually delete it and insert the one from the account the message is now using. This seems like a bug, but maybe it's a feature. Any suggestions? Thanks! Are you using Word as the editor? When I click on my account...

send attachment to multiple recipients, but viewable only to one
Hi there... Possibly a bit of an odd request... I want to know if it is possible to send an attachment in an email to a number of people, but to specify that only one of the recipients would be able to open it... Basically I want to be able to demonstrate that an attachment has been sent, but not have it read by everyone it has been sent to. I'm using Outlook 2003... Any help would be very greatfully recieved! Thanks in advance... Chris Not sure if this is what you're looking for... One option would be to set the file with a password to open and send the password only to the ind...

IMAP Access to Multiple Mailbox using PINE
Hi all, We are running Exchange 2003, we need to be able to allow users using PINE to access multiple mailboxes (read only), this was possible in 5.5, which we can configure PINE with "AnotherUser" "{exchange.domain.com}Other Users/AnotherUser/inbox", and grant use reviewer rights to that mailbox But this doesn't seem to work anymore in 2003. How can we do this? Many Thanks, Yang ...

How do I print multiple pages on 1 sheet of A4 in Publisher 2002
Hi all, This is something that I have not been able to figure out but I expect is straight forward or impossible to do. I have a small page size (4" x 6") and so two of these pages will fit neatly onto an A4 sheet of paper. I can see how to print multiple COPIES of a page onto a single sheet, but I can't figure out how to print multiple pages onto a single sheet. If I choose to only print a single copy per page, Publisher decides to plonk the page in the middle on the A4 sheet. I can't see any option to get more than one page printed side by side. Any Ideas Chris ...

multiple postcode criteria selection
I want to be able to select multiple postcodes for a selection criteria. These are British 'main' postcodes. eg: SW3, SW5, NW2, NW7, N1, N2 and so on... Ideally I would like to be able to input as many as I need to (with sensible limits), they will most likely be limited to a maximum of 6. this is my exisiting SQL: (which omly allows for 1 postcode criteria) SELECT tbl_Points.Point_ID, tbl_Points.Run_point_Venue, tbl_Points.Run_point_Address, tbl_Points.Run_Point_Postcode, tbl_Points.Run_Point_Postcode AS pcode1, tbl_Points.LeaveBy1, tbl_Points.LeaveBy2, tbl_Points...

Multiple Connectors
We are running 3 servers in one of our sites. I have one IMC set to deliver all of our outgoing email to our email gateway. We now need to put an IMC on another server to deliver email for just one domain. I have tried to do this but all of the email still goes through the other connector. The original connector has address space * with cost 5 and the new one has our-domain.com with cost 1. Is there something else that I have to do? ...

selecting multiple cells with ctrl key
When selecting cells using the ctrl key I can select 6 cells and on the 7th cell nothing happens and the cells I've already selected are deselected. What's happening?! ...

Using exchage to get multiple pop3 accounts
I would like to set up an account that not only gets my local mail, but also goes out and checks my yahoo mail, my comcast mail, etc.... Can anyone tell me if I can do this through exchange? Thanks Unless you're using a POP connector (not recommended), no, but you can set up the other accounts in Outlook, presuming you're using OL2002 or 2003. James Mckillop wrote: > I would like to set up an account that not only gets my > local mail, but also goes out and checks my yahoo mail, my > comcast mail, etc.... Can anyone tell me if I can do this > through exchange? Than...

How to modify multiple users mailbox quota limits...
Hello All....belive it or not I am an Exhcnge Admin. with zero scripting ability or know-how...but working on that part myself. Anyway, I have approx. 3000 users and need to modify about 400 of those mailboxes so the the sytem policy will not affect them. For example, we are implementing a uniform quota for all users, exceot for those that are currently over the limit. We are going to give them a week to prune their mailbox and only set the warning limit for them as well. Then after the week, we want to bring up to par with everyone else and have them use the policy like everyone el...

combine multiple spreadsheets into one workbook
i have approx 800 individual excel files. i want to put them all into one excel workbook - creating one workbook with 800 worksheet tabs. Is this possible without opening them all and dragging them into the one workbook one at a time? Jen - You may run into a limit on the # of tabs in a workbook. Not sure about that. Even if there isn't a limit, you are looking at an enormous amount of memory required to open such a workbook. However, if you want to try, look at Ron de Bruin's add in that will merge workbooks http://www.rondebruin.nl/merge.htm "Jen" wro...

Unprotecting multiple worksheets w/ Macro
I am protecting with a macro, multiple worksheets in a workbook with a macro. I can't get the unprotect of multiple worksheets to work. Does anyone have a working macro to do this. _____________ Tippy Sub UnprotectSheets() Dim sh as Worksheets for each sh in ThisWorkbook.Worksheets if sh.ProtectContents or sh.ProtectScenarios or _ sh.ProtectDrawingObjects then sh.unprotect Password:="ABCD" end if Next End Sub -- Regards, Tom Ogilvy <tippy@att.net> wrote in message news:c7vlpv0sqb9eov641aj31ohnqnps7hvgvm@4ax.com... > I am protecting with a macro,...

Conditional Formatting Across Multiple Cells
I have data file that I want to conditional format Red/Green fill based on >= conditional on a single row of data. In Excel 2003 it was fairly simple to lock a row but not a column and by selecting all the cells to format it would change the column relative to the cell. Just having an issue transitioning to conditional formatting in 2007. Sample Data a b c d 1 goal 10 245 125 2 day1 8 200 76 3 day2 8 250 125 4 day3 15 250 130 5 day4 15 300 150 6 day5 0 100 0 7 Avg 9 220 96 Cells Rows 2 - 7 should be conditional on Row ...