By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,991 Members | 1,737 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,991 IT Pros & Developers. It's quick & easy.

How to XSL-transform documents into a place-holder on the form?

P: n/a
I'm using an ASP.NET form to display data from my database table, and
I'm doing it in the following way:

XmlDataDocument doc = new XmlDataDocument(mydataSet);
XPathNavigator nav = doc.CreateNavigator();
XslTransform xslTran = new XslTransform();
xslTran.Load("Transform.XSL");
xslTran.Transform(nav, null, Response.Output, null);

This produces me a nice HTML page with enhanced formatting specified
within Transform.XSL, and streams the result into the output.

The problem is the result is written into the output without any
control of where and how it will be formatted. I want to use some sort
of a place-holder that I could visually place on the form at design
time to set sizes and align with other UI elements on the form.
The question is - what could be such a place-holder into which I
could redirect all the output, and how can I use it?
Method Transform writes out into a stream, so, whatever place-holder
must expose its stream object or something, methinks....

Anyways,
- Suggested by some people control System.Web.UI.WebControls.Xml
won't do, as it doesn't support XSL formatting.
- Writing resulting HTML into a file and then reading it in as mere
text - sounds more like a nonsense.

Other than that, I gave up looking...

Please somebody help me!!!

Nov 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
I got it right with this code:

In aspx
<asp:Xml ID="Xml1" runat="server" EnableViewState="False"
TransformSource="~/Dealer/DealerMaster.xsl" Visible="False"></asp:Xml>

In C#

private void ShowDealer(string dealerID)
{

lblMessage.Text = "";

try

{

string commandText = string.Format("exec Dealer_Master_XSP_DealerID
@DealerID={0}", dealerID);

string connect =
ConfigurationManager.ConnectionStrings["OperationsSqlXmlConnectionString"].ConnectionString;

Xml1.Visible = true;

Xml1.XPathNavigator = XPathXML(connect, commandText);

Xml1.TransformSource = "DealerMaster.xsl";

}

catch (Exception ex)

{

lblMessage.Text = ex.Message;

}

}

private System.Xml.XPath.XPathNavigator XPathXML (string connectionString,
string commandText)

{

SqlXmlCommand mySqlXmlCommand = new SqlXmlCommand(connectionString);

mySqlXmlCommand.RootTag = "root";

mySqlXmlCommand.CommandType = SqlXmlCommandType.Sql;

mySqlXmlCommand.CommandText = commandText;

XmlReader xmr = mySqlXmlCommand.ExecuteXmlReader();

System.Xml.XPath.XPathDocument xpd = new
System.Xml.XPath.XPathDocument(xmr);

return xpd.CreateNavigator();

}

<vi************@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
I'm using an ASP.NET form to display data from my database table, and
I'm doing it in the following way:

XmlDataDocument doc = new XmlDataDocument(mydataSet);
XPathNavigator nav = doc.CreateNavigator();
XslTransform xslTran = new XslTransform();
xslTran.Load("Transform.XSL");
xslTran.Transform(nav, null, Response.Output, null);

This produces me a nice HTML page with enhanced formatting specified
within Transform.XSL, and streams the result into the output.

The problem is the result is written into the output without any
control of where and how it will be formatted. I want to use some sort
of a place-holder that I could visually place on the form at design
time to set sizes and align with other UI elements on the form.
The question is - what could be such a place-holder into which I
could redirect all the output, and how can I use it?
Method Transform writes out into a stream, so, whatever place-holder
must expose its stream object or something, methinks....

Anyways,
- Suggested by some people control System.Web.UI.WebControls.Xml
won't do, as it doesn't support XSL formatting.
- Writing resulting HTML into a file and then reading it in as mere
text - sounds more like a nonsense.

Other than that, I gave up looking...

Please somebody help me!!!

Nov 19 '05 #2

P: n/a
So, to go through this step-by-step,...

Instead of setting DocumentSource with XML contents, you set property
XPathNavigator. First off, XML control in ASP.NET doesn't have
property XPathNavigator, so I don't understand how this even
compiles...

I don't quite understand the meaning of each line in method XPathXML,
but it looks like you're using SQL Server natural XML data
presentation, and then something else... I'm using both SQL and JET
databases, so cannot quite use the suggested technique...

Your methodology doesn't allow for any transformation parameters like
we can pass in method Transform of XslTransform. I'm using such to
pass parameters-objects for data columns pre-processing.

On the overall, doesn't seems feasible to be adapted to my needs.

I appreciate the answer anyway, thank you.

Anyone can throw in not as controversial an example?

Cheers!

Nov 19 '05 #3

P: n/a
don't pass the response stream to transform, pass a string stream, then you
can pass the string to a passholder.

StringWriter sr = new StringWriter();
XmlDataDocument doc = new XmlDataDocument(mydataSet);
XPathNavigator nav = doc.CreateNavigator();
XslTransform xslTran = new XslTransform();
xslTran.Load("Transform.XSL");
xslTran.Transform(nav, null, sr, null);

HtmlGenericControl ctl = new HtmlGenericControl("div");
ctl .InnerHtml = sr.ToString();
Page.Controls.Add(ctl); // or add to a placeholder
-- bruce (sqlwork.com)

<vi************@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
I'm using an ASP.NET form to display data from my database table, and
I'm doing it in the following way:

XmlDataDocument doc = new XmlDataDocument(mydataSet);
XPathNavigator nav = doc.CreateNavigator();
XslTransform xslTran = new XslTransform();
xslTran.Load("Transform.XSL");
xslTran.Transform(nav, null, Response.Output, null);

This produces me a nice HTML page with enhanced formatting specified
within Transform.XSL, and streams the result into the output.

The problem is the result is written into the output without any
control of where and how it will be formatted. I want to use some sort
of a place-holder that I could visually place on the form at design
time to set sizes and align with other UI elements on the form.
The question is - what could be such a place-holder into which I
could redirect all the output, and how can I use it?
Method Transform writes out into a stream, so, whatever place-holder
must expose its stream object or something, methinks....

Anyways,
- Suggested by some people control System.Web.UI.WebControls.Xml
won't do, as it doesn't support XSL formatting.
- Writing resulting HTML into a file and then reading it in as mere
text - sounds more like a nonsense.

Other than that, I gave up looking...

Please somebody help me!!!

Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.