Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Alternative to XSL

Status
Not open for further replies.

tektipster79

Programmer
Oct 1, 2007
34
0
0
US
We have currently been using XSLT to transform data from SQL into an XML format we need, and have found performance to be slow. Instead of traversing an XML file with XPATH we have decided to create classes to represent the nodes (using xsd to generate the classes). Is there an easier or more performant way than using XSLT to get the XML I need to deserialize into the classes? Basically, is there a better way to map the database elements to the schema for the XML file?
 
xmlreader/writer are the fastest one-way objects to generate or consume xml. one-way meaning you can't use xPath.

this is my understanding of the objects. I have used them directly.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Are you creating the xml in the sql statement using FOR XML?


If you using the 3.5 framework you could look at
LINQ to SQL or LINQ to XML

I avoid XLST Transformations whenever possible. What is the reasoning behind using that.

I've found the fastest way to populate objects from SQL Server is using a datareader.
 
Thanks for the suggestions. There are quite a number of classes, 75 or so, so I'll need to think of an elegant way to populate each class from the result sets that are returned from the stored proc. The stored procedure is not currently sending the results back as XML.
 
Oh and I did try to convince my boss to let me use LINQ, but he didn't see enough benefit to warrant getting the whole team to switch to VS 2008 :(
 
I can not tell you how much better 2008 is then 2005. The new language features are so sweet it's not even funny.
 
I know, I'm so sad we can't use it for this project, it would be SOOO much easier!!
 
stsuing, what is the best way to populate the generated classes from a sqldatareader? i'm having trouble figuring out how to match up the columns i'm getting back from sql to the generated classes. the sproc returns a few result sets and it's not in XML.
 
I would just google it. Just remember the reader can bring back multiple sets depending on execution order of your sql. If you run your query in sql server you'll see the result sets and the order of them and the column heading. You'll have to call NextResult or something like that on the reader to get the next result. Remember to close the reader as fast as possible, since it's a live connection.

This link does it, and there will be others out there

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top