issues with repopulating XPathDocument with new XmlReader or XmlTextReader

Cant seem to solve this problem

I need to be able to re-use XmlReader and XPathDocument 
for an XSLT Transform.

Basically I have defined following interfaces:

Class Render

(Common and public inside the class)
XPathDocument XpDoc;
XmlReader XrDoc;

- Constructor Render
public Render(XmlReader CleanXmlDoc,string SeriesXSL)

- It Loads 2 things:
 the XML
 the XSL

these objects are used by the following Methods using 
Xsl.Transform method and other stuff

Methods:

public string RenderSectionPreview()
public string RenderHTML(String RenderMode)
public string RenderPDF(String RenderMode)

I was using 
XPathDocument XpDoc = new XPathDocument(XmlReader); 
inside the constructor and XpDoc was used as source for 
XSLT translations in RenderHTML and RenderPDF.

Everything was working fine.

Now I decided to add 2 more methods to allow us to use the 
same RenderObject (our custom class) and UPDATE the XML by 
using the following Method ReloadXML.

Also wanted to add a WriteXML object that would allow us 
to write the incoming XMLReader (for debug as well as 
saving it)

New Methods:

public int ReloadXML(XmlReader CleanXmlDoc1)
public int WriteXML(String RenderMode)

The problem is in this process we are calling the

XPathDocument XpDoc = new XPathDocument(XmlReader); 

with CleanXmlDoc1 (the new XML)

again.

We were hoping that the XpDoc would get populated with it 
and we could use the XpDoc again as before in the 
Xsl.Transform()

ANALYSIS:

After a lot of head breaking have come to the conclusion 
that this has something to do with XPathDocument or 
XmlReader and the current position of the cursor etc. or 
something like that ? BUT I MAY BE COMPLETELY WRONG.
Is it something like this ? What is the issue ?

I tried using MemoryStream to store the XmlReader and then 
use XPathDocument but logically I am still not able to re-
populate the XPathDocument XpDoc with a new XmlReader.

Kindly advise. Thanks.



0
xmlguy (13)
10/10/2003 3:33:53 AM
dotnet.xml 7266 articles. 0 followers. Follow

2 Replies
769 Views

Similar Articles

[PageSpeed] 33

If I understand everything correctly, then you problem is that you are
re-using the XmlReader that you attached to the MemoryStream.

An XmlReader is forward only, i.e. you cannot rewind it! You are on the
right track with using a MemoryStream though. You can rewind the
MemoryStream by setting Position = 0. Then you can attach a fresh
Xml(Text)Reader an re-read the stream.

Did I understand your problem and did this help?

-- 
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor

"xmlguy" <xmlguy@yahoo.com> wrote in message
news:008701c38edf$54469970$a001280a@phx.gbl...
> Cant seem to solve this problem
>
> I need to be able to re-use XmlReader and XPathDocument
> for an XSLT Transform.
>
> Basically I have defined following interfaces:
>
> Class Render
>
> (Common and public inside the class)
> XPathDocument XpDoc;
> XmlReader XrDoc;
>
> - Constructor Render
> public Render(XmlReader CleanXmlDoc,string SeriesXSL)
>
> - It Loads 2 things:
>  the XML
>  the XSL
>
> these objects are used by the following Methods using
> Xsl.Transform method and other stuff
>
> Methods:
>
> public string RenderSectionPreview()
> public string RenderHTML(String RenderMode)
> public string RenderPDF(String RenderMode)
>
> I was using
> XPathDocument XpDoc = new XPathDocument(XmlReader);
> inside the constructor and XpDoc was used as source for
> XSLT translations in RenderHTML and RenderPDF.
>
> Everything was working fine.
>
> Now I decided to add 2 more methods to allow us to use the
> same RenderObject (our custom class) and UPDATE the XML by
> using the following Method ReloadXML.
>
> Also wanted to add a WriteXML object that would allow us
> to write the incoming XMLReader (for debug as well as
> saving it)
>
> New Methods:
>
> public int ReloadXML(XmlReader CleanXmlDoc1)
> public int WriteXML(String RenderMode)
>
> The problem is in this process we are calling the
>
> XPathDocument XpDoc = new XPathDocument(XmlReader);
>
> with CleanXmlDoc1 (the new XML)
>
> again.
>
> We were hoping that the XpDoc would get populated with it
> and we could use the XpDoc again as before in the
> Xsl.Transform()
>
> ANALYSIS:
>
> After a lot of head breaking have come to the conclusion
> that this has something to do with XPathDocument or
> XmlReader and the current position of the cursor etc. or
> something like that ? BUT I MAY BE COMPLETELY WRONG.
> Is it something like this ? What is the issue ?
>
> I tried using MemoryStream to store the XmlReader and then
> use XPathDocument but logically I am still not able to re-
> populate the XPathDocument XpDoc with a new XmlReader.
>
> Kindly advise. Thanks.
>
>
>


0
10/10/2003 3:52:30 AM
I believe you got me right.

Now the question is ..

Is there a better way than using a MemoryStream as 
my "persistent" storage for the "current" Xml ?

Because I have two independent operations for that 
persistent storage.

1. Use it against transforms (Xslt)
2. Re-populate it with new Xml from another source.

What would be the best Objects to use ? 
Should I simply go with XmlDocument as the Storage.

Note: When I say "persistent" i mean for the "life and 
scope" of that object ( the instane of my class Render )

Kindly do advise.

Thanks,

XmlGuy

>-----Original Message-----
>If I understand everything correctly, then you problem is 
that you are
>re-using the XmlReader that you attached to the 
MemoryStream.
>
>An XmlReader is forward only, i.e. you cannot rewind it! 
You are on the
>right track with using a MemoryStream though. You can 
rewind the
>MemoryStream by setting Position = 0. Then you can attach 
a fresh
>Xml(Text)Reader an re-read the stream.
>
>Did I understand your problem and did this help?
>
>-- 
>HTH
>Christoph Schittko [MVP]
>Software Architect, .NET Mentor
>
>"xmlguy" <xmlguy@yahoo.com> wrote in message
>news:008701c38edf$54469970$a001280a@phx.gbl...
>> Cant seem to solve this problem
>>
>> I need to be able to re-use XmlReader and XPathDocument
>> for an XSLT Transform.
>>
>> Basically I have defined following interfaces:
>>
>> Class Render
>>
>> (Common and public inside the class)
>> XPathDocument XpDoc;
>> XmlReader XrDoc;
>>
>> - Constructor Render
>> public Render(XmlReader CleanXmlDoc,string SeriesXSL)
>>
>> - It Loads 2 things:
>>  the XML
>>  the XSL
>>
>> these objects are used by the following Methods using
>> Xsl.Transform method and other stuff
>>
>> Methods:
>>
>> public string RenderSectionPreview()
>> public string RenderHTML(String RenderMode)
>> public string RenderPDF(String RenderMode)
>>
>> I was using
>> XPathDocument XpDoc = new XPathDocument(XmlReader);
>> inside the constructor and XpDoc was used as source for
>> XSLT translations in RenderHTML and RenderPDF.
>>
>> Everything was working fine.
>>
>> Now I decided to add 2 more methods to allow us to use 
the
>> same RenderObject (our custom class) and UPDATE the XML 
by
>> using the following Method ReloadXML.
>>
>> Also wanted to add a WriteXML object that would allow us
>> to write the incoming XMLReader (for debug as well as
>> saving it)
>>
>> New Methods:
>>
>> public int ReloadXML(XmlReader CleanXmlDoc1)
>> public int WriteXML(String RenderMode)
>>
>> The problem is in this process we are calling the
>>
>> XPathDocument XpDoc = new XPathDocument(XmlReader);
>>
>> with CleanXmlDoc1 (the new XML)
>>
>> again.
>>
>> We were hoping that the XpDoc would get populated with 
it
>> and we could use the XpDoc again as before in the
>> Xsl.Transform()
>>
>> ANALYSIS:
>>
>> After a lot of head breaking have come to the conclusion
>> that this has something to do with XPathDocument or
>> XmlReader and the current position of the cursor etc. or
>> something like that ? BUT I MAY BE COMPLETELY WRONG.
>> Is it something like this ? What is the issue ?
>>
>> I tried using MemoryStream to store the XmlReader and 
then
>> use XPathDocument but logically I am still not able to 
re-
>> populate the XPathDocument XpDoc with a new XmlReader.
>>
>> Kindly advise. Thanks.
>>
>>
>>
>
>
>.
>
0
xmlguy (13)
10/10/2003 6:52:16 PM
Reply:

Similar Artilces:

Format issues
I have created a template in word which I call through a VB script from excel. The excel data is populated in the word every time I run this script. Everything works fine and the data get populated. I have a header in the template which is represents one of the fields in the excel sheet. The header shows the correct linked value for the first 10 pages but then on shows the variable name instead of the value. I have no idea why it does that? can someone help The code is as follows: For iCurrentRow = 1 To iLastRow If ActiveSheet.Range("B" & iCurrentRow...

Outlook issues after Exchange migration
We recently migrated Exchange 5.5 mailboxes to Exchange 2003 on a new domain. This was performed with the exmerge utility in a 2 step process. Now there are 2 issues with Oulook: 1) When a user types a recipient name into the address field, the name autocompletes as normal. But when the mail is sent, a message returns saying it is undeliverable. However, if the user goes into the Contacts folder and from there selects the same user to send a message to, it is successful. 2) If a user shares a calendar, specifying the user with whom to share and the level of permissions, all users in ...

Looking for new Portfolio management system
I have been using MSN Money Portfolio to track my investments and really like the software. However, to handle their new delux version they are requiring that you upgrade to IE 6 which my older slower computer will not handle very well. I am looking for new software that essentially performs the same functions. Any suggestions will be appreciated. ...

Taskbar issue
Hello All I'm hoping someone can help me with this long-standing problem with both XP and Vista on separate laptops and every computer I've had (except I think Win98). I'm thinking there may be no solution, but what it's worth a try. With both of my machines, I have the taskbar (as well as other toolbars) set out to maximum size - typically half the screen - and to auto hide. (This makes a great program and file launcher) The issue is that the operating system decides it wants open the taskbar on its own from time to time on its own. Various things prompt this, ma...

DST issue
I entered the catalog item: <Feature Name="Item" CatalogItemId="Item:MS:sysgen_timesvc_dst" /> and confirmed that the device has the registry key: HKLM\Software\Microsoft\Clock\AutoDST = 1 But the device still does not automatically adjust for DST. I set the timezone to Pacific, set the time to 3/14/2010 at 1:59AM, waited for one minute...and the time changed to 2:00AM instead of 3:00AM. What am I missing? Thanks. which OS version are you using? have you updated it with the relevant qfes which deal with the changing in DST starting day? -...

Can't change New Message Window Size
I have Windows Live Mail set to reduce the overall size. I did have New Message reduced so it doesn't take up the whole screen. Somehow that got changed and now it fills the whole page and decreasing the New Message window box does nothing. > Somehow that got changed and now it fills the whole page and decreasing > the New Message window box does nothing. Annoying isn't it? I always try to keep one spare open in case that happens. Then all I need to do is close the problem window, close the spare, and hope that the next window which opens will be in the...

Outlook/EX Email Issue
I'm running Windows XP with XP Professional. I cannot send email but I can recieve it using Outlook. There error says that Outlook was unable to access the SMTP server. I cannot access my email at HOME through the web email. What I can do is send/recieve email using Outlook Express AND I can access my email through my web email client outside my home. My ISP (SBC) says its not them and I'm somewhat inclined to agree with them? They say I could have a corrupted kernel32.dll file. I have turned off my Norton, deleted my account and set up a new one and re-installed XP professiona...

Extender Install Issues
GP 8.0 Extender install - I'm encountering the following: *Login to GP brings up screen: "Great Plains Extender needs to finish installing. This may take a few minutes". It has an OK button and clicking on this gets you into GP but it comes up everytime. How can we stop this from popping up all the time. *When creating a new Extender Window and I get select the Form, I get the following error: "A remove range operation on table 'PT_User_Defined_Window_Keys' failed accessing SQL data." Procedure or function zDP_EXT40101L_1 has too many arguments spec...

Possible Report Issue
Hi. I'm working on a database for a safety audit. The auditors would like to be able to use some of the tables and subtables as a sort of checklist for the audits. The table/subtable structure is as follows: Topic -->Subtopic -->ProgramArea -->ProgramRequirement I decided to create a report that will output that data. However, the report is only outputting information if there are ProgramRequirements already entered for a given ProgramArea. Is there a way to get it to output the ProgramArea and ProgramRequirement even if blank? Or am I going about th...

Adobe issues
We are running GP 9.0, using Windows 7, just installed Adobe 8.0 and are unable to send documents to PDF from GP - the PDF option remains grayed out. We have folowed the KB articles that are available, no success. Do we need to install Adobe 9.0 due to running Windows 7? Is GP 9.0 compatible with Adobe 9? Thank you for any assistance.. Hi Susan, I have a client using Adobe 9 on Windows 7. However, they are on GP 10.0 It is working succesfully. -- Geoff James "Susan" wrote: > We are running GP 9.0, using Windows 7, just installed Adobe 8.0 and are ...

Programmatically navigating form to New Record
Hi I have a mainform and with a subform (NOT linked). I'm trying to implement mainform navigation when the subform has focus. eg: When a control on the subform has focus, pressing PageUp should move one record up on the main form. I have done this using mainform.Recordset.MoveFirst (MoveNext, MovePrevious, MoveLast). This all works fine. Problem is that when on the last record - pressing PageDown should take me to a new record on the main form. Docmd.GotoRecord ... acNext ----- is not suitable because my mainform itself is contained in a "master" form (mainform is also a subf...

Issue with formula is Pivot table
I have the following formula in a pivot table: =IF(ISBLANK(Qtr[-1]),IF(ISNUMBER(Qtr[-2]),(Qtr[-2]*-0.08)+Qtr[-2], "),IF(ISBLANK(Qtr[-2]),0,Qtr[-1])) First to the issues that I am experiencing. First, the formula wa originally added as the one below but then updated to the formula abov to correctly reflect what I was trying to accomplish. =IF(ISBLANK(Qtr[-1]),IF(Qtr[-2]<>0,(Qtr[-2]*-0.08)+Qtr[-2], "),IF(ISBLANK(Qtr[-2]),0,Qtr[-1])) This issue is the original formula appears in the very first cell o the pivot table and then periodically through out the column. So, yo see ...

install on a new computer?
I bought the Office suite with Publisher and it is installed on my desktop, working well. Now, I just bought a laptop and would like to use Publisher on it too. How do I load the program onto my new laptop? (Please dont tell me I have to buy the program again!) Jim Did Office come with the purchase of your desktop? -- JoAnn Paules MVP Microsoft [Publisher] Tech Editor for "Microsoft Publisher 2007 For Dummies" "The Weidner Publishing Group" <weidner-arlhs@earthlink.net> wrote in message news:FFA8758F-AC59-44C5-9525-04E810E5963C@microsoft.com... >I...

aDD A NEW BUTTON
How do I add a button to a tool bar in Excel 2K? What I want tofor a user to click on this button and it will cause another program to run. ...

force new page criteria
My report shows monthly meeting information [date, event, location, time, etc] grouped/sorted by date, then time. How can I get the report to start a new page for each week, beginning on Mondays? I just have the table of information and the report, no query. Thanks!! Create a query from your table and add a calculate field. TheMonday: DateAdd("d", vbmonday - DatePart("w", [MeetDate]), [MeetDate]) That will create a date field that is the Monday of the week the date is in. Then add a Group to your sorting an grouping for TheMonday. Set the Force New Page property i...

Hyperlink Issue #2
I have an issue with hyperlinks. When you click on the hyperlink on a webpage it returns an error stating that the the "item could not be created". Outlook 2000/Windows 2000 ...

Outlook Web Access OWA Issue - Login Prompt for Images
Dear Outlook 2003 / Exchange 2003 Users, Starting over the last two weeks (possibly after an update on the Exchange server), all of my users are starting to encounter the same issue when using Outlook Web Access (using IE6 on XP Pro systems). We have images in our signature block, and now when someone replies using Webmail to an e-mail originally sent via Outlook 2003, a login prompt appears for each image in the e-mail. Every time you cancel the login box, a red x image box appears, until all of the images that should be there are represented by the red x boxes. For the record, this has w...

Update Issues
Has anyone experienced any problems with XP Pro updates sent in Feb.? My Lenovo T61p has performed flawlessly for 2+years but suddenly started turning off and now stays on but freezes-up. I can’t detect a virus and seems like the Feb. updates are all that has changed. I plan to uninstall them….between freeze-ups, unless someone has a better thought. Thanks >Has anyone experienced any problems with XP Pro updates sent in Feb.? My >Lenovo T61p has performed flawlessly for 2+years but suddenly started turning >off and now stays on but freezes-up. I can�t detect a ...

~ issue
I am currently using Outlook Express 6 and have noticed that for the second time (did a format the first time thinking I had a virus!) that when I have downloaded the 330994 April 2003, Security update for Outlook Express 6 SP1 that anytime I make a change to my address book and reboot I get an icon on my desktop that is named "~" and it basically is my entire address book. Has anyone else experienced this problem and how do I remedy it? Thank you for any help! Sue In reviewing the Outlook Express newsgroups, this is reported as a known issue w/ no fix from Microsoft (report...

Multiple Outlook Mailboxes issues with 3.0
I have a large number of users who have more than one outlook mailboxes, When I open an email from one of the addtional mailboxes, I get an error message that tells me "Only Items in the default Outlook store can be promoted to Microsoft CRM." Does anyone know if this can be worked around?? ...

SSRS upload new report getting error: Microsoft.Crm.CrmException
What is the deal with CRM 3.0 and adding new reports through CRM 3.0? I dont have a shared Data Source. I have set full permissions for <domain>/crm and nt service. Has anyone figured out why this is like this? Thanks, Jeff Below is the error from the trace log: AppReportsMenu.BuildReportsMenu at AppReportsMenu.BuildReportsMenu(Menu reportsMenu, ReportVisibility visibility, String clientId, Int32 objectTypeId) at AppFormMenuBar.BuildToolbar() at AppFormMenuBar.Execute(PrivilegeCheck privilegeCheck, String formName) at AppFormMenuBar.Execute(PrivilegeCheck privilegeCheck) at Oppor...

chkdsk issue
Whenever I run chkdsk /r, it finds quite a few errors and corrects them. An example is a lot of orphaned files. Then, if I run it again right away, it does the same thing and finds the sa,e orphaned files. What causes this and how can I correct it? Thank you. On 14 May 2010, five256@NOwhere.com wrote in microsoft.public.windows.vista.general: > Whenever I run chkdsk /r, it finds quite a few errors and corrects > them. An example is a lot of orphaned files. Then, if I run it > again right away, it does the same thing and finds the sa,e > orphaned files. What causes...

RSS Sync issue
Hi, I discovered that Outlook is not syncing all my RSS-Feeds. When i tried to export into an OPML list, the same issue which are not synced are not exported as well. Anyone idea ? Thanks Hans ...

Public Folder Replication issue #3
I have a single domain which is linked across a VPN to two sites. At both sites I have a DC and an Exchange box. The issue I am having is on Server A, I can see and access all public folders, on Server B I cannot see one folder and two other folders have no data. I have checked to ensure they are set up for replication and even in ESM it shows they are "In Sync" or "Local Modified". Any suggestions on how to resolve this would be greatly appreciated. Douglas Hiser In each public folder's properties do you have both servers showing as having replicas? Do yo...

Domain name issue migrating 5.5 to Exchange 2003
We are prepairing to migrate Echange 5.5 to Exchange 2003. This has come up as an issue: Our domain is cornerstone instead of cornerstone.com Our email address is "firstname.lastname@cornerstonegrp.com" instead of: "firstname.lastname@cornerstone.com" ...