SourceForge Logo NCodeGen


NCodeGen

Documentation

Community

Related

NCodeGen Templates


You can write your templates in VTL (Velocity Template Language) or XSLT.
Third party template languages like CodeSmith (ASP.NET like) can be used by implementing ITransfomationEngine interface

Velocity Templates


XML Manipulation


NCodeGen unique feature : You can manipulate XML (input) very easy like late-bound languages. Compare it with using DOM.

<Database>
	<Tables>
		<Table Name="ProcessDefinitions"/>
	</Tables>
</Database>

-----------------------------------------------------

#foreach ($Table in $Input.Database.Tables) 
	$Table.Name
#end

Loops
#foreach ($file in $project.GetSourceFiles())				
	<includes name="${file.RelativePath}"/>
#end
Conditional
#if ($Remove == "true")
public void Remove(string key)
{
	items.Remove(key) ;
}
#end
Macros
#macro (FieldToParameter $field)
	[$field.Name] [$field.Type] ($!field.Size)
#end

#macro (ParametersDefinition $table)
	#set ($comma = "")
	#foreach ($field in $table.Fields) 
		$comma 
		$FieldToParameters($field)
		#set ($comma = ",")
	#end
#end

CREATE PROCEDURE [dbo].[$spName]
(
#ParametersDefinition($Table)
)
....

For more information about writing Velocity templates see Velocity User's Guide


Copyright © 2004, Edris Hasani Nasab
SourceForge.net Logo