473,413 Members | 1,799 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,413 software developers and data experts.

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

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
3 1813
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mikael Petterson | last post by:
Hi, I am trying to produce the following in javacode; public void action<An actionName>(String value1, int value 2....,Coordinator c) throws Exception; The arguments to the actionXXX could...
0
by: Lewis G. Pringle, Jr. | last post by:
Folks: I have some XML text I'm tranforming from one schema to another. Both schemas have their own notion of 'address' (as well as many other contepts). XSL seems to be mainly suited to...
4
by: Kasp | last post by:
Below is a XSL that I can barely understand being a newbie to XSL world. Can someone let me know what do these 3 lines do exactly? - <xsl:attribute name="MemberKey"> <xsl:number level="multiple"...
4
by: Jean-Christophe Michel | last post by:
Hi, In a complex merging of two (non ordered) xml files i need to keep track of the elements of the second tree that were already merged with first tree, to copy only unused elements at the end....
5
by: Tom Alsberg | last post by:
Hi there... I'm recently trying to get a bit acquainted with XML Schemas and XSL. Now, I have a few questions about XSL stylesheets and templates: * Is there a way to "enter" a child element...
5
by: Axial | last post by:
Question: How to select columns from Excel-generated XML when some cells are empty. I've found examples where rows are to be selected, but I can't seem to extrapolate from that to selecting...
0
by: james | last post by:
Hi there! I'm trying to convert an HTML file to CSS and I have problems reading the CSS attributes. For example: for table attribute: <xsl:attribute-set name="table.data"> <xsl:attribute...
0
by: Nathan | last post by:
Hi, I seem to having a peculiar problem with the display of odd and even pages in XSL-FO. Here is a small background of the problem. My xsl stylesheet mentions my fo:layout-master-set as ...
6
by: virgiloz | last post by:
I'm new to XML but an old hand at c++ lisp and vba programming. I'm trying to process the following xml data: <abilities> <ability> <name>Strength</name> <abbr>STR</abbr>...
0
by: Leira | last post by:
Hi, I have a problem with grouping. My source XML has <record> elements that have a @name and a @group attribute. It looks something like this: <root> <result> <record name="test1"...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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.