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

Transform problem in ASP.NET v2.0

Hi,

I have a function from one component that returns an XmlDocument object. I
have another function in another component that takes an XmlDocument as a
property. I have written an XSLT to transform the Xml from the first function
to the format expected by the second function.

But I don't see how I can call the tranformation process in .NET 2.0. It
says that I have to use the XslCompiledTransform class in .NET 2.0, but the
transform function of this class has 14 overloads and none of them accepts
XmlDocument as either input or output parameter. (huh?) The overload that
comes closest to what I need uses an XmlReader and XmlWriter object as
parameters, but how to get my source XmlDocument into the reader and how to
extract the result from the writer? (Without saving it to file first and then
reading it again from file of course)

Any help appreciated. I'm most familiar with VB.NET programming.

Cedric
Nov 12 '05 #1
4 1648


Cedric wrote:
But I don't see how I can call the tranformation process in .NET 2.0. It
says that I have to use the XslCompiledTransform class in .NET 2.0, but the
transform function of this class has 14 overloads and none of them accepts
XmlDocument as either input or output parameter.


Here is the documentation:
<http://msdn2.microsoft.com/en-us/library/ms163429(en-US,VS.80).aspx>
There are several methods that take an object implementing
IXPathNavigable documented here:
<http://msdn2.microsoft.com/en-us/library/h30hxzdh>
XmlDocument is one class that implements that interface, even in .NET 1.1.
So any of those methods can take an XmlDocument instance as the argument.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Nov 12 '05 #2
Martin,

I have looked at this documentation before and am unable to find how to get
my XmlDocument class object to an object of class that is accepted by one of
the transform signatures, and afterwards to get the parsed document back to
an XmlDocument object.

What frustrates me is that I have done this before in ASP 3.0 with MSXML
4.0, where it was a piece of cake: have a document and apply an XSLT to it.
But in .NET, nothing works with the XmlDocument class.

Cedric
"Martin Honnen" wrote:


Cedric wrote:
But I don't see how I can call the tranformation process in .NET 2.0. It
says that I have to use the XslCompiledTransform class in .NET 2.0, but the
transform function of this class has 14 overloads and none of them accepts
XmlDocument as either input or output parameter.


Here is the documentation:
<http://msdn2.microsoft.com/en-us/library/ms163429(en-US,VS.80).aspx>
There are several methods that take an object implementing
IXPathNavigable documented here:
<http://msdn2.microsoft.com/en-us/library/h30hxzdh>
XmlDocument is one class that implements that interface, even in .NET 1.1.
So any of those methods can take an XmlDocument instance as the argument.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

Nov 12 '05 #3


Cedric wrote:
I have looked at this documentation before and am unable to find how to get
my XmlDocument class object to an object of class that is accepted by one of
the transform signatures, and afterwards to get the parsed document back to
an XmlDocument object. But in .NET, nothing works with the XmlDocument class.


I think you need to take a course in .NET framework object-oriented
programming then to understand that the framework defines interfaces and
classes implementing such interfaces.
And as I said in my previous response:
There are several methods that take an object implementing
IXPathNavigable documented here:
<http://msdn2.microsoft.com/en-us/library/h30hxzdh>
XmlDocument is one class that implements that interface, even in .NET 1.1.
So any of those methods can take an XmlDocument instance as the argument.


So use one of the methods that take an IXPathNavigable argument. That is
an interface and the XmlDocument class implements that interface which
for you means you simply create your XmlDocument instance and then pass
that to the method where the method signature says it wants an
IXPathNavigable.

Pseudo-code C# example for .NET 2.0 that uses an XmlDocument as the input:

XmlDocument xmlDocument = new XmlDocument();
xmlDocument.LoadXml("<gods><god>Kibo</god></gods>");

XslCompiledTransform xsltProcessor = new XslCompiledTransform();
xsltProcessor.Load(@"someStylesheet.xml");

xsltProcessor.Transform(xmlDocument, null, Console.Out);

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Nov 12 '05 #4

"Martin Honnen" wrote:

Pseudo-code C# example for .NET 2.0 that uses an XmlDocument as the input:

XmlDocument xmlDocument = new XmlDocument();
xmlDocument.LoadXml("<gods><god>Kibo</god></gods>");

XslCompiledTransform xsltProcessor = new XslCompiledTransform();
xsltProcessor.Load(@"someStylesheet.xml");

xsltProcessor.Transform(xmlDocument, null, Console.Out);


Martin,

I have been going to some extra material but cannot find how to get the
result back into an XmlDocument. Your example also uses the console.out.
Plenty of examples with XmlWriter and how to save it to disc, but none where
they do any post processing or where they pass it as an argument to another
function.

Any help appreciated.

Cedric
Nov 12 '05 #5

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

Similar topics

5
by: Alex Vinokur | last post by:
Functor-parameters in the for_each() and transform() algorithms are passed by value. Might it make sense to have also algorithms for_each2() and transform2() which pass Functor-parameters by...
0
by: Xiaolei Li | last post by:
first off, i'm a total newbie at this stuff so excuse any wrong usage of terminology or whatever else. i have a XSL to transform a Document such that all "text" nodes will have a "SPAN" inserted...
2
by: John Lehmann | last post by:
I have an interesting problem. I am performing an XSL transform using the System.Xml.Xsl.Transform class. I have a database that contains the XSL style sheet string. And it seems to work pretty...
9
by: Patrick Guio | last post by:
Dear all, I am trying to use the std::transform algorithm to to the following vector< vector<char> >::iterator ik = keys.begin(); // key list iterator vector< vector<char> >::iterator is = ik;...
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...
3
by: Jason S | last post by:
Hello Group, I am just about tearing my hair out with this one and thought someone may have some insight. I have a transform that wasn't working so I grabbed the nearest debugger (xselerator)...
4
by: schneider | last post by:
Anyone know if there is a way to dynamicly create a Xslt template/s and use them as an xml transform with-out use files for the Xslt? All the methods I see use files. I want to create a Xslt...
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...
4
by: Dean Card | last post by:
Okay, so here is the situation. I have need to do some on-the-fly image creation. I have everything working great except for the last part of it, applying a perspective type transform to the...
6
by: Vijai Kalyan | last post by:
Hello, I am trying to use std::transform to take in a collection of strings, transform them and insert the result into an output container. So, I wrote something like this: std::wstring...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
1
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,...

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.