开发者

Converting Linq to XSLT

Is there a way to convert LINQ queries into XSLT? the same way LINQ can be converted to SQL?

I mean if i have a solid well defined XML(Conforms to an XSD) is开发者_运维问答 there a way to compile the stuff under System.Linq.Expressions into XSLT in regard to that XML?

Thank you.

To Dimitries request I'll try to elaborate a little... Basically I have some data in one place (it's basically to chunks of xml serializable data), and I need to process them, I need to combine and process them.

Both the incoming original data , and the output result data, are XML serializable, and conform to a well defined XSD.

I want to generate the processing logic dynamically - someplace else. And allow my user to change and play around with the processing. I can represent the processing it self easily with Expression trees. Expression trees are similar to parse trees and can capture program code. This is the way linq to SQL works it converts expression trees to SQL queries.

Since all the income data and the output are both a well defined XML I can do the transformation easily with XSLT, but I'm not familiar with XSLT enough to write a dynamic XSLT generator. So I thought I could build the transformations in C# and convert them into XSLT.... again its not general purpose C#, but probably specific queries over a well defined data provider.

For the example sake:

(Not real code)

var schemas = XSchemaSet.Load("a","b");
var doc = XDocument.Load("File",schemas);

var result = from node in doc.Nodes
             where node.Name == "Cats" || node.Name == "Dogs"
             select (new Node(){Name = "Animal Owner", Value = node.Owner)
var newDoc = new XDocument().AddNodes(result);
newDoc.Validate(schemas);

Basically I want something that will function like that... I can write that in a single linq query if I use IQueryable.Aggregate


Yes, you can implement your own query provider, which uses XSLT internally, if you can figure out how to query with XSLT.


Why not just use Linq2XML? It operates on XDocument and XElement

or alternatively if you want people to define transforms using xlst why not just execute an xslt against the document in code?

I dont see how having a Linq2XSLT would help solve a problem without recreating it in a different form

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜