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

XslCompiledTransform not outputting to XmlDocument

Hi guys/gals,

Can you help with this? I am trying to use an XSL tranform with the new
XslCompiledTranform class. I want it to output to a XmlDocument, but
the document is empty after .Transform(...) but i Know thethe xsl and
source xml are fine becasue if I output the Transform to a file it
works fine. Here's what i'm doing:

// Output doc
XmlDocument xmlReg = new XmlDocument();

//Sort with Xslt
XslCompiledTransform xsl = new XslCompiledTransform();
xsl.Load("DocSortByDate.xsl");
xsl.Transform("DocList.xml",
null,xmlReg.CreateNavigator().AppendChild());
Any suggestions??

Many thanks,

Peter

May 15 '06 #1
3 7156


p-*********@iname.com wrote:

Can you help with this? I am trying to use an XSL tranform with the new
XslCompiledTranform class. I want it to output to a XmlDocument


You could Transform to a MemoryStream and reset its position to 0 after
the transformation and then load then stream into an XmlDocument instance.

Or check the MVP XML project and the XslReader which allows you to
consume the result of an XSLT transformation as an XmlReader and load
that into the XmlDocument instance:
<http://mvp-xml.sourceforge.net/api/2.0/T_Mvp_Xml_Common_Xsl_XslReader.html>
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
May 15 '06 #2
p-*********@iname.com wrote:
Can you help with this? I am trying to use an XSL tranform with the new
XslCompiledTranform class. I want it to output to a XmlDocument, but
the document is empty after .Transform(...) but i Know thethe xsl and
source xml are fine becasue if I output the Transform to a file it
works fine. Here's what i'm doing:


The problem with this code is that XmlWriter created by
xmlReg.CreateNavigator().AppendChild() won't get closed. Use different
pattern:

XmlDocument doc = new XmlDocument();
using (XmlWriter writer = doc.CreateNavigator().AppendChild()) {
xslt.Transform(input, (XsltArgumentList)null, writer);
}

--
Oleg Tkachenko [XML MVP, MCAD]
http://www.XmlLab.Net | http://www.XLinq.Net | http://blog.tkachenko.com
May 16 '06 #3
Many thanks, that worked perfectly!

Peter

May 16 '06 #4

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

Similar topics

1
by: Steve | last post by:
Using VB.NET 2.0 I have a simple routine that attempts transforms an XmlDocument with an XSLT stylesheet into HTML. Under the old 1.1 framework with XslTransform, everything worked fine. Now...
0
by: mrc | last post by:
How do I do the following using streams instead of actual files. I've tried it using memory streams for the input/and output but I don't seem to be able to get the output stream to contain...
1
by: S. David Kyle | last post by:
I am having a weird issue when I generate an input Html tag from a Xsl transformation. When the trasform is executed on the xsl below, the <inputtag has the closing slash removed in the first...
5
by: Steve | last post by:
I am using XslCompiledTransform to transform XML into Excel 2003 SpreadsheetML. In order to get the resulting XML file to open in Excel, we need the following two lines at the top of the file: ...
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)...
2
by: Simon Harvey | last post by:
Hi all, I'm having a real problem with getting an XMLWriter as a result of an xsl tranform I'm attempting. My code is: private void btnPerformTransform_Click(object sender, EventArgs e) {...
1
by: Mark | last post by:
I'm getting the error "The URI scheme is too long." in the code below. What is URI in this context? The XSL or the XML being transformed? Thanks! -Mark StringBuilder sb = new...
3
by: Andy Fish | last post by:
Hi, From reading the documentation, I get the impression that XslCompiledTransform should be faster than XslTransform on my test with a large complex document and a large complex XSLT, the...
1
by: =?Utf-8?B?Vmlub2Q=?= | last post by:
Hi, I am having a problem doing the transform. Actually i am migrating the code from XslTranform class into XslCompiledTransform class. Here is the code that i am using in .net 1.1 private...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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,...

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.