473,668 Members | 2,357 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Transforming a typed dataset

Hello,

I need to reorder a Typed DataSet in memory using an Xsl Transform.

Most of the examples use stream which write to the hard disk or xml
file. I want to do this in memory and then write the resulting Typed
Dataset into a Session object which will be reused on multiple
postbacks
and then finally saved when editing is done. Get various problems
depending
on what objects I use, rather than go through each one I will post
what I
have and see if anyone can suggest where to go from here.

Xsl is simple, reordering (this is done becuase onitemupdate of
datagrid I delete element then add a new one. this is because there
are different types of columns and the use="optional" in the xsd file
didn't give me an extra method to remove by column
row.MultipleSel ect.Delete() Anyhow this is peripheral as I am already
down the alley which I hope isn't blind.

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:styleshe et xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output omit-xml-declaration="ye s"/>
<xsl:template match="/*">
<Test>
<xsl:for-each select="/Test/Question">
<xsl:sort select="@id" order="ascendin g" data-type="number"/>
<xsl:copy-of select="."/>
</xsl:for-each>
</Test>
</xsl:template>
</xsl:stylesheet>

Method for reordering DataSet:

try
{
XmlDataDocument xmlDoc = new XmlDataDocument (ds);

XslTransform xslTran = new XslTransform();
xslTran.Load(Se rver.MapPath("Q uestionSort.xsl t"));

System.IO.Memor yStream s = new System.IO.Memor yStream();
System.Xml.XmlT extWriter w = new XmlTextWriter( s,
System.Text.Enc oding.Default );

xslTran.Transfo rm(xmlDoc, (XsltArgumentLi st)null,w,(XmlR esolver)null);

s.Position = 0; //reset position of the in-memory stream.
StreamReader r = new StreamReader(s) ;

Test dsnew = new Test();
dsnew.ReadXml( r.ReadToEnd() );

//this method saves to session object
setDataSet(Sess ionTestName, dsnew);
}
catch (Exception ex)
{
ex = ex;
}

Thanks,
matt
Nov 12 '05 #1
1 4144
After ploding through reams of demo code writing out to the
Response.Output Stream ....I pieced various bits of newsgroup snippets
to produce this which works.....repro duced here for frantic google
searchers.
try
{
XmlDataDocument xmlDoc = new XmlDataDocument (ds); //ds is input
dataset
XslTransform xslTran = new XslTransform();
xslTran.Load(Se rver.MapPath("Q uestionSort.xsl t"));

System.IO.Memor yStream memstr = new System.IO.Memor yStream();
System.Xml.XmlT extWriter writer = new XmlTextWriter( memstr,
System.Text.Enc oding.Default );

xslTran.Transfo rm(xmlDoc,
(XsltArgumentLi st)null,writer, (XmlResolver)nu ll);

writer.Flush();

memstr.Position = 0;

Test dsnew = new Test(); //this is my typed dataset
dsnew.ReadXml( memstr );

setDataSet(Sess ionTestName, dsnew); //here I save the transformed
dataset to the session object
}
catch (Exception ex)
{
ex = ex;
}

ma************@ gmail.com (Matthew Baskey) wrote in message news:<df******* *************** ****@posting.go ogle.com>...
Hello,

I need to reorder a Typed DataSet in memory using an Xsl Transform.

Most of the examples use stream which write to the hard disk or xml
file. I want to do this in memory and then write the resulting Typed
Dataset into a Session object which will be reused on multiple
postbacks
and then finally saved when editing is done. Get various problems
depending
on what objects I use, rather than go through each one I will post
what I
have and see if anyone can suggest where to go from here.

Xsl is simple, reordering (this is done becuase onitemupdate of
datagrid I delete element then add a new one. this is because there
are different types of columns and the use="optional" in the xsd file
didn't give me an extra method to remove by column
row.MultipleSel ect.Delete() Anyhow this is peripheral as I am already
down the alley which I hope isn't blind.

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:styleshe et xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output omit-xml-declaration="ye s"/>
<xsl:template match="/*">
<Test>
<xsl:for-each select="/Test/Question">
<xsl:sort select="@id" order="ascendin g" data-type="number"/>
<xsl:copy-of select="."/>
</xsl:for-each>
</Test>
</xsl:template>
</xsl:stylesheet>

Method for reordering DataSet:

try
{
XmlDataDocument xmlDoc = new XmlDataDocument (ds);

XslTransform xslTran = new XslTransform();
xslTran.Load(Se rver.MapPath("Q uestionSort.xsl t"));

System.IO.Memor yStream s = new System.IO.Memor yStream();
System.Xml.XmlT extWriter w = new XmlTextWriter( s,
System.Text.Enc oding.Default );

xslTran.Transfo rm(xmlDoc, (XsltArgumentLi st)null,w,(XmlR esolver)null);

s.Position = 0; //reset position of the in-memory stream.
StreamReader r = new StreamReader(s) ;

Test dsnew = new Test();
dsnew.ReadXml( r.ReadToEnd() );

//this method saves to session object
setDataSet(Sess ionTestName, dsnew);
}
catch (Exception ex)
{
ex = ex;
}

Thanks,
matt

Nov 12 '05 #2

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

Similar topics

1
6079
by: Job Lot | last post by:
I am confused how strongly typed dataset is different from un-typed dataset. Is there any good link explaining pros and cons of both? Which one should be used preferably?
5
7461
by: DraguVaso | last post by:
Hi, Something I don't understand about a Typed DataSet: When a value in the DataSet is DBNull, it throws this error: "Cannot get value because it is DBNull". But aren't Typed DataSets invented to make life easier, to be able to get to tge Tables and Values with less code, in less time? But with this thing you need to add a Try-Catch around every statement when using the value, add for each value a default value in your DataSet (and...
1
2115
by: Linesh Gajera | last post by:
Hi Guys i having the same problem with Strongly typed dataset, I have created a stronsetly typed dataset by draging table from Server explorer and now i have retreived xml from SQL server 2000 and tried to populate dataset but it populates 0 rows even though ml contains rows. If i use regular Dataset instead of Typed dataset, then everything works just fine..please help me as soon as possible, here is my code snippet. I think you have...
1
1712
by: Nedu N | last post by:
Hi All, I am facing problem in copying content of table from a untyped dataset into to a table inside the typed dataset. I wanted to copy the data into typed dataset in order to ease the further processing using typed references. DataSet ds = getDataFromDB(); - i am getting the dataset ds from a webservice I have got MyXSD which decsribes the shcema for the table which i am getting from the webservice
2
2249
by: BeanTownBizTalkGuru | last post by:
Trying to get some feedback. Here's the scenerio. We are processing XML data which we generated a typed dataset to represent the XML document being processed. After procesing is complete we would like to add/update/delete the data in multiple databases. Here lies the disconnect. The XML representation is seperated from the physical model(s) in the database there for the typed datasets are drastically different. What is the best...
1
1243
by: Trond | last post by:
I have a class MessageController that has a method GetMessagesDataset that connects to a database SPROC. When done it returns a dataset. Then in my ASP.NET for i do this: msgController = new MessagesController(); DataSet dsMessages = new Dataset(); dsMessages = msgController.GetMessagesDataset();
12
5300
by: Whoever | last post by:
Hi, I'm trying to return an XmlDocument or XmlNode converted from a typed dataset. public XmlNode whatever() { MyTypedDataSet ds = new MyTypedDataSet(); return new XmlDataDocument(ds); }
3
2750
by: Freeon | last post by:
Hi, I am looking for a way to sort a strong typed dataset. It would seem the most straightforward way is to use a dataview. The only problem is when I use the dataview I seem to loose the strong typed properties from my original dataset Anyone that can point me to an example of how to sort my dataset and maintain the use of my typed properties would be greatly appreciated Thank, Freeon
1
9354
by: Optimus | last post by:
Hi everyone, I currently develop an application in vs.net 2005 with vb.net. I was trying to use typed dataset and I've got in trouble for converting untyped dataset into Typed DataSet. I don't know why I cannot perform this casting operation properly. First off, I've got my Typed DataSet named "AuthInfo" declared and I then created an instance of that class. What I'd like to do next is to perform querying through the method...
0
8459
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8374
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8791
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8575
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7398
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6206
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4202
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2018
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1783
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.