473,406 Members | 2,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Transform Method on Demand.

Hi.

I am using the transform method to create an HTML file using an existing XML Document and an XLST. I need to use XPath to extract
a node from my XML Document and my XLST document will format the node into something readable to my users.

My code works, however, I will be having multiple users calling my routines at the same time. So I don't want to create a "hard"
copy of my html file and place on my server. Because every time a new user calls the routine it will overwrite the html file.
I'd rather have the html file be virtual on each users web browser.

My question is, I'm not sure where I need to change my code. I have tried several variations of the XslTransform sending
different parameters but nothing is getting me the desired result. And I am unsure if it is my XslTranform call, or if I need to
change my writer class or if my webform actually needs additional objects to "virtually" display the html file. I am at a lose as
to where I look for the answer.

Thank you in advance for any help. Below please find my code behind for my form that actually creates an HTML file on my web server.

//Read in textbox value
string userInput = TextBox1.Text.Trim();

// Create a resolver with default credentials.
XmlUrlResolver resolver = new XmlUrlResolver();
resolver.Credentials = System.Net.CredentialCache.DefaultCredentials;
XslTransform xslt = new XslTransform();
xslt.Load(Server.MapPath("XSLTFile.xsl"),resolver) ;

XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("XMLFile.xml"));

//Get Node 1
XmlNodeList N1NodeList = doc.DocumentElement.SelectNodes("//N1");
XmlNode N1 = N1NodeList.Item(0);

//using XPath to search a node for the user Inputted Value
string y = "//N2[N2C1 = '" + userInput + "']";
XmlNodeList testNodeList = doc.DocumentElement.SelectNodes(y);

string x = testNodeList.Count.ToString(); // If NodeList exists
int i = testNodeList.Count;

if (i >= 1) //need to throw error if group id is not found.
{
XmlNode testNode = testNodeList.Item(0);

//Move within the tree.
testNode.PrependChild(busDate);

XmlDocument tmpDoc = new XmlDocument();
tmpDoc.LoadXml(testNode.OuterXml);
// Now big question. Multi-threading - multiple users -- writing a file to system. Rather have it dynamic.
XmlTextWriter writer = new XmlTextWriter(Server.MapPath("asucPartial.html"), null);
xslt.Transform(tmpDoc,null,writer,resolver);
writer.Close();

Label1.Text = "done";

}
else
{
x = "Record Not Found.";
Label1.Text = x;
}
}
Nov 12 '05 #1
2 1171
Hello!
// Now big question. Multi-threading - multiple users -- writing a
file to system. Rather have it dynamic.
XmlTextWriter writer = new
XmlTextWriter(Server.MapPath("asucPartial.html"), null);
xslt.Transform(tmpDoc,null,writer,resolver);
writer.Close();


Just write it to Response.OutputStream if you're using ASPX or ASHX. It
will be directly sent to the client.

--
Pascal Schmitt
Nov 12 '05 #2

THANK YOU.

Pascal Schmitt wrote:
Hello!
// Now big question. Multi-threading - multiple users -- writing
a file to system. Rather have it dynamic.
XmlTextWriter writer = new
XmlTextWriter(Server.MapPath("asucPartial.html"), null);
xslt.Transform(tmpDoc,null,writer,resolver);
writer.Close();

Just write it to Response.OutputStream if you're using ASPX or ASHX. It
will be directly sent to the client.

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: edgekaos | last post by:
Is method 2 valid? Method 1: wstring input = L"STRING"; wstring output = input; transform(output.begin(), output.end(), output.begin(), towupper); Method 2: wstring input = L"STRING";...
2
by: Anthony Bouch | last post by:
Can anyone tell me why I receive the following compiler warning after having recently upgraded to VS.Net 2003 and .Net 1.1? Warning CS0618: 'System.Xml.Xsl(System.Xml.XPath.IXPathNavigable,...
6
by: Stephen Cook | last post by:
Having worked through the problems around enabling the document function using an XmlUrlResolver I started work on building a useful class to hide the intricacies. Trying to generalise the process...
5
by: z. f. | last post by:
Hi, is there a sample code for a program that accept input xml file name, input xsl file name and output result file name and outputs the resulting xml? TIA, z.
2
by: Greg Merideth | last post by:
I have an XSL file that I am using to transform some XML data using this method below. The problem is that if I use an embedded .XSL file in the .NET assembly, I get an error indicating that the...
5
by: Greg Collins [MVP] | last post by:
I have an ASP.NET page that uses a tag: <asp:Xml id="foo" runat="server" DocumentSource="rss.xml" TransformSource="rss20.xsl" /> This creates a Web page from an XML file that was generated by...
1
by: Mike Hofer | last post by:
I've got two statements in my code that are both generating weird, weird, weird messages: The first one was, Dim document As System.Xml.XmlDocument Dim navigator As...
12
by: InvalidLastName | last post by:
We have been used XslTransform. .NET 1.1, for transform XML document, Dataset with xsl to HTML. Some of these html contents contain javascript and links. For example: // javascript if (a &gt; b)...
24
by: Mike Hofer | last post by:
Please forgive the cross-post to multiple forums. I did it intentionally, but I *think* it was appropriate given the nature of my question. I'm working on an open source code library to help...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.