posts - 218, comments - 222, trackbacks - 68

My Links

News




I am a Microsoft Certified Application Developer MCAD Chartered Member (C# .Net) and born in Bangladesh.
I work for Ocean Informatics Pty Ltd as a Senior Developer - Analyst.
I am also co-founder and core developer of Pageflakes (acquired by LiveUniverse) www.pageflakes.com
and most recently created SmartCodeGenerator

My Articles
Flexible and Plugin based .Net Application..
Mass Emailing Functionality with C#, .NET 2.0, and Microsoft® SQL Server 2005 Service Broker'
Write your own Code Generator or Template Engine in .NET
Smart Code Generator .NET: Usage Overview
Smart Code Generator .NET: Architectural Overview
Smart Code Generator .NET: using with NAnt and Cassini

Archives

Free Programming Language Training

Check out this Article for Xml based codegeneration with SCG

I uploaded this new article in the Unedited Section of CodeProject.

Abstract

This article describes how we can use XML as a metadata source for SCG Templates. It also shows step-by-step instructions of how to generate strongly typed objects from XSD and use it in the templates to generate text based output. ASP.NET developers can also use this paper as reference to transform XML using ASP.NET scripts and avoid XSLT.

Introduction

We all agree that XML's primary purpose is to facilitate the sharing of data across different systems. However, the same XML can also be used as a powerful input for template generation tools. CodeSmith fans might be already familiar with XmlProperty and can be already seen in a variety of examples. In this article I am going to illustrate how to use XML as a metadata source for SCG templates. XML provides a text-based means to describe and apply a tree-based structure to information and SCG facilitates writing logic and code in your favorite .NET language (C#, Vb.Net etc). By combining these two technologies, we can generate meaningful input & output for a system which was very complex to achieve earlier. In the code generation world, XML is now highly used as a metadata source to generate business objects, data access layers and even user interfaces. The other practice is to generate different application layers based on database structure, but XML is becoming more popular as it provides more flexibility in integrating logic as a metadata source for templates. For example, in this example I defined the class name and its properties, and also specified to generate a UI with a gridview component and paging support. Notice this would have been a bit messy to define in a database structure.

  <?xml version="1.0" encoding="utf-8" ?>
  <BusinessObjects xmlns="http://www.smartcodegenerator.com">
    <class name="Student">
      <properties>
        <property name="Id" type="String" maxSize="36" />
        <property name="Name" type="String" maxSize="96" />        
      </properties>
      <userinterface generate="true">
        <uicomponent>GridView</uicomponent>
        <gridview paging ="true" rownum="20">          
        </gridview>
      </userinterface>
    </class>    
  </BusinessObjects>


Lets see how to use XML in SCG template.

How to use XML metadata in SCG templates

Print | posted on Thursday, April 26, 2007 12:04 AM |

Feedback

No comments posted yet.

Post Comment

Title  
Name  
Email
Url
Comment   
Please add 5 and 1 and type the answer here:

Powered by: