469,282 Members | 2,078 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

XSLT Dataset - need help by transform

Hi,

May some one could help me.

I want to transform data, coming from SQL Server and loaded to a dataset
wiuth xslt.

After that, I want convert it by a xslt style sheet, and store it back or in
a new dataset.

SqlXmlAdapter ad = new SqlXmlAdapter(cmd);

ad.Fill(dsXML);

XslTransform tf = new XstTransform();

tf.Load( @"..\..\MapServices.xsl" );

DataSet ds = new DataSet();

ds.ReadXml(tf.Transform(###What do need here###);

There is no output file or input file, is just in memory a string or a
dataset.

Thank you

Matthias


Nov 12 '05 #1
3 3040
"Matthias Marx" <ma**@matthiasmarx.com> wrote in message news:es**************@TK2MSFTNGP14.phx.gbl...
ad.Fill(dsXML);
XslTransform tf = new XstTransform();
tf.Load( @"..\..\MapServices.xsl" );
DataSet ds = new DataSet();
ds.ReadXml(tf.Transform(###What do need here###); : : There is no output file or input file, is just in memory a string or a
dataset.


XslTransform( ) returns void, so it needs to be on a separate line
from the ReadXml( ) call. One solution would use the StringReader
and StringWriter classes from the System.IO namespace, like this:

StringWriter sw = new StringWriter( );
tf.Transform( new XmlDataDocument( dsXML), null, new XmlTextWriter( sw));
ds.ReadXml( new StringReader( sw.ToString( )));
Derek Harmon
Nov 12 '05 #2
Derek Harmon wrote:
XslTransform( ) returns void, so it needs to be on a separate line
from the ReadXml( ) call. One solution would use the StringReader
and StringWriter classes from the System.IO namespace, like this:

StringWriter sw = new StringWriter( );
tf.Transform( new XmlDataDocument( dsXML), null, new XmlTextWriter( sw));
ds.ReadXml( new StringReader( sw.ToString( )));


Yes, but this requires an interim string buffer and
serializing/reparsing of the transformation result. Actually one can
avoid both using XslTransform.Transform() methods, which return
XmlReader. Then it's just

ds.ReadXml(tf.Transform(new XmlDataDocument(dsXML), null));

--
Oleg Tkachenko [XML MVP, MCP]
http://blog.tkachenko.com
Nov 12 '05 #3
"Oleg Tkachenko [MVP]" <oleg@no_!spam!_please!tkachenko.com> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl...
Derek Harmon wrote:
XslTransform( ) returns void, so it needs to be on a separate line
from the ReadXml( ) call. One solution would use the StringReader
: : Actually one can avoid both using XslTransform.Transform() methods, which
return XmlReader.


I stand corrected, there are in fact two overloads of Transform( ) in
1.0 which do return an XmlReader. My mistake, I hadn't noticed them
and took for granted all of its overloads returned void. Clearly, the
overload returning an XmlReader directly would perform much better. :-)
Derek Harmon
Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Wil | last post: by
2 posts views Thread by Patrick J. Schouten | last post: by
reply views Thread by Brendan Reynolds | last post: by
7 posts views Thread by Doug Heeren | last post: by
4 posts views Thread by | last post: by
3 posts views Thread by Ian Roddis | last post: by
3 posts views Thread by thomas.porschberg | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.