<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns="http://www.w3.org/1999/xhtml" 
	xmlns:msxsl="urn:schemas-microsoft-com:xslt"
	xmlns:Gen-it="http://mycompany.com/mynamespace"
	version="1.0">
<xsl:output method="text" encoding="us-ascii" indent="yes"/>

<xsl:variable name="ProjectName">SampleCase_</xsl:variable>
<xsl:variable name="Author">&lt;Gen-it&gt;</xsl:variable>
<xsl:variable name="CreationDate">24-01-2001</xsl:variable>

<xsl:template match="/">
<xsl:for-each select="//Class">public class <xsl:value-of select="Gen-it:CapFirst(Class.name)"/>
{
	<xsl:for-each select="Attribute">
	<xsl:apply-templates select="." mode="datatype"/><xsl:apply-templates select="." mode="variable"/> = new <xsl:apply-templates select="." mode="newdatatype"/>;
	</xsl:for-each>
	<xsl:for-each select="Attribute">
	public void set<xsl:value-of select="Gen-it:CapFirst(Attribute.name)"/>(<xsl:apply-templates select="." mode="datatype"/>value)
	{
		<xsl:apply-templates select="." mode="variable"/> = value;
	}
	public <xsl:apply-templates select="." mode="datatype"/>get<xsl:value-of select="Gen-it:CapFirst(Attribute.name)"/>()
	{
		return <xsl:apply-templates select="." mode="variable"/>;
	}</xsl:for-each>
}
</xsl:for-each>
</xsl:template>

<xsl:template match="Attribute" mode="datatype">
	<xsl:if test="substring(Gen-it:Lower(Attribute.datatype),1,7)='varchar'">String </xsl:if>
	<xsl:if test="substring(Gen-it:Lower(Attribute.datatype),1,7)='numeric'">Long </xsl:if>
	<xsl:if test="substring(Gen-it:Lower(Attribute.datatype),1,8)='datetime'">Date </xsl:if>
	<xsl:if test="substring(Gen-it:Lower(Attribute.datatype),1,4)='real'">Double </xsl:if>
	<xsl:if test="substring(Gen-it:Lower(Attribute.datatype),1,5)='text'">String </xsl:if>
</xsl:template>
<xsl:template match="Attribute" mode="newdatatype">
	<xsl:if test="substring(Gen-it:Lower(Attribute.datatype),1,7)='varchar'">String() </xsl:if>
	<xsl:if test="substring(Gen-it:Lower(Attribute.datatype),1,7)='numeric'">Long(0) </xsl:if>
	<xsl:if test="substring(Gen-it:Lower(Attribute.datatype),1,8)='datetime'">Date() </xsl:if>
	<xsl:if test="substring(Gen-it:Lower(Attribute.datatype),1,4)='real'">Double() </xsl:if>
	<xsl:if test="substring(Gen-it:Lower(Attribute.datatype),1,5)='text'">String() </xsl:if>
</xsl:template>
<xsl:template match="Attribute" mode="variable">
	<xsl:if test="substring(Gen-it:Lower(Attribute.datatype),1,7)='varchar'">str<xsl:value-of select="Gen-it:CapFirst(Attribute.name)"/></xsl:if>
	<xsl:if test="substring(Gen-it:Lower(Attribute.datatype),1,7)='numeric'">lng<xsl:value-of select="Gen-it:CapFirst(Attribute.name)"/></xsl:if>
	<xsl:if test="substring(Gen-it:Lower(Attribute.datatype),1,8)='datetime'">dat<xsl:value-of select="Gen-it:CapFirst(Attribute.name)"/></xsl:if>
	<xsl:if test="substring(Gen-it:Lower(Attribute.datatype),1,4)='real'">dbl<xsl:value-of select="Gen-it:CapFirst(Attribute.name)"/></xsl:if>
	<xsl:if test="substring(Gen-it:Lower(Attribute.datatype),1,5)='text'">str<xsl:value-of select="Gen-it:CapFirst(Attribute.name)"/></xsl:if>
</xsl:template>

<msxsl:script language="VBScript" implements-prefix="Gen-it">
	' <!-- Return the text of the node as all UPPERCASE -->
	Function Upper(nodelist) 
		Upper = UCASE(nodelist.nextNode().text)
	End Function
	' <!-- Return the text of the node as all lowercase -->
	Function Lower(nodelist) 
		Lower = LCASE(nodelist.nextNode().text)
	End Function
	' <!-- Return the text of the node with the first character converted to Uppercase -->
	Function CapFirst(nodelist) 
		dim strText
		dim strOutput
		strText = nodelist.nextNode().text
		strOutput = UCASE(Left( strText, 1))
		strOutput = strOutput + LCASE((Right( strText, LEN(strText)-1)))
		CapFirst = strOutput
	End Function
	' <!-- Return the text of the node plus spaces to create a string of the specified length -->
	Function FillSpace(nodelist, length) 
		dim strText
		dim strOutput
		strText = nodelist.nextNode().text
		strOutput = strText + String( length - LEN(strText) , " ")
		FillSpace = strOutput
	End Function
</msxsl:script>

</xsl:stylesheet>

