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.