Subject: Re: [xsl] Where (how) to use XML/XSLT in my .Net Project From: Brandon Ibach <brandon.ibach@xxxxxxxxxxxxxxxxxxx> Date: Thu, 24 Feb 2011 14:04:33 -0500 |
An XSLT transform is an XML document containing instructions for how to build an XML document from input data, much like your "control" file. The advantage with XSLT is that it's standard, very mature and the code needed to execute it is already written! You'd have the choice between the XSLT processor built into the .NET framework, which implements XSLT 1.0 and Saxon, which implements XSLT 2.0. The trick in your case would be that XSLT requires XML as input (or something that can be represented in a similar hierarchical model). Fortunately, XML was heavy in the minds of the designers of .NET, so it is pretty pervasive in the framework. The System.Xml.XmlDataDocument class can turn a System.Data.DataSet into an in-memory XML document object, to which you can then apply your XSLT transform. If you need to pull data from multiple DataSets, you should be able to wrap each one in an XmlDataDocument and apply the transform to the "main" one, supplying the others as "parameters", which will appear as variables in your XSLT transform. -Brandon :) On Thu, Feb 24, 2011 at 9:09 AM, Jeffry Proctor <jpgmt@xxxxxxxxxxxxx> wrote: > C# ASP.Net 3.5 (2008) > XSLT 2.0 developed: SaxonicaHE, production: SaxonPE > MSSQL > XML Accord Standard, <TXLife/>, <TXLifeRequest/> > The project will query SQL data from a few data sources, then use an XML and/or > XSLT to build an output XML file. Later on the same XML will be sent to a > webservice. > The project's code will not know how to build the output file, instead it will > rely on an XML/XSLT control file to tell it what to do. > My dilemma lies in that I'm not sure if I should have the control file be an > XML, XSLT or ?? > > Below is a possible avenue using XML to instruct the c#.Net project what nodes > need to be constructed and where to map the data. > > ...this pseudo example.... > <Control> > <TXLife> > <Obj_Name>Policy</Obj_Name> > <!-- comment: 1=true, 0=false --> > <Obj_Complex>1</Obj_Complex> > <!-- comment: attribute value 1=term, 2=Disability, 3=..... --> > <Obj_Attribute value="1">tc</Obj_Attribute> > <Parent_Name>Olife</Parent_Name> > <!-- comment: Object Elements... --> > <Obj_Elements>PolicyAmount,Term,Modal</Obj_Elements> > <!-- comment: Source/Result Name/Value Pair mapping --> > <Source_ResultNV sc="uPolAmount">PolicyAmount</Source_ResultNV> > <Source_ResultNV sc="uPolYears">Term</Source_ResultNV> > <Source_ResultNV sc="uPmtMode">PremiumModal</Source_ResultNV> > </Obj_Name> > <Obj_Name...etc for each simple or complex element /> > </TXLife> > </Control> > The project will then build the result XML based on the above and any subsequent > additions/changes to the control file, will (if all is well) result in a > different result XML file, with no need to change the c# code. > I suppose that my question is if a control XML file is a good direction or if > XSLT can do it all, map data into the XML output and not rely on my c# .Net code > to know how to form or map the data into the result XML. > TIA > JeffPGMT...
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Where (how) to use XML/XSLT i, Jeffry Proctor | Thread | [xsl] I would like to know how I ca, ycao5 |
Re: [xsl] Table columns - fixed spa, Murray McDonald | Date | Re: [xsl] pulling object at their c, Brandon Ibach |
Month |