Hello. I am looking for a mechanism to transform dataobjects into HTML. The elements in the dataobject are of both, simple and complex types. I have tried playing with HtmlTextWriter for rendering but got stuck with complex types.
Mine is an ASP.Net website project. I have to avoid using server side controls (and therefore do away with built in binding capabilities) as the front end processing is done with the help of jQuery. I need to just churn out basic HTML for my dataobjects and the rest of enrichment (content arrangement and styling) will be done at the frontend.
I am looking for a simple solution (I found Spring.Net an overkill and overwhelming and NHAML also very confusing).
Further, my application is expected to grow over a period of time so I need to have some respect for performance. Therefore I am avoiding bringing XML/XSLT in the picture.
For eg. A Person object will be something like this:
String: Name
Int: Age
Complex Type: Address (includes Street, City, Zip)
Array of Type "Qualification" : Qualifications (includes Degree, Passing Year, Grades)
Desired output is:
<p id="userName" class="userName">John</p>
<p id="age" class="age">35</p>
<div id="address" class="address">
<p id="street" class="street">Express Highway</p>
<p id="city" class="city">Mumbai</p>
<p id="zip" class="zip">400101</p>
</div>
<div id="qualifications" class="qualifications">
<div id="qualification1" class="qualification">
<p id="degree1" class="degree">B.Sc.</p>
<p id="year1" class="year">1990</p>
<p id="grade1" class="grade">A</p>
</div>
<div id="qualification2" class="qualification">
<p id="degree2" class="degree">M.Sc.</p>
<p id="year2" class="year">1992</p>
<p id="grade2" class="grade">A</p>
</div>
</div>
A point to note here is that a mapper would be required to map the properties from the source dataobject, add some metadata to it (like HTML element attributes, etc) and then carry out the transformation.