<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
	
	<xsl:output method="text" encoding="us-ascii" />
	
	<xsl:template match="/">
		<xsl:apply-templates/>
	</xsl:template>
	
	<xsl:template match="class">
		
	<!--     class declaration     -->
	<!--===========================-->
		<xsl:text>public class </xsl:text>
		<xsl:value-of select="@name"/>
		<xsl:if test="./extends">
			<xsl:text> extends </xsl:text>
			<xsl:value-of select="./extends/@name"/>
		</xsl:if>
		<xsl:if test="./implements">
			<xsl:text> implements </xsl:text>
			<xsl:for-each select="implements">
				<xsl:if test="position()!=1">
					<xsl:text>, </xsl:text>
					<xsl:value-of select="@name"/>
				</xsl:if>
			</xsl:for-each>
		</xsl:if>
		<xsl:text> {</xsl:text>
		<xsl:call-template name="CRLF"/>
		<xsl:call-template name="CRLF"/>
		
		
		
	<!--     field declaration     -->
	<!--===========================-->
		<xsl:for-each select="field">
			<xsl:text>	public </xsl:text>
			
			<!-- field type -->
			<xsl:choose>
				<!-- use the item type directly -->
				<xsl:when test="@maxOccurs=1">
					<xsl:value-of select="@itemType" />
				</xsl:when>
				<!-- fixed number. Use array -->
				<xsl:when test="string(@maxOccurs)=string(@minOccurs)">
					<xsl:value-of select="@itemType" />
					<xsl:text>[]</xsl:text>
				</xsl:when>
				<!-- otherwise use Vector just for now -->
				<xsl:otherwise>
					<xsl:text>Vector</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
			
			
			<xsl:text> </xsl:text>
			<xsl:value-of select="@name"/>
			
			
			<!-- default initialization -->
			<xsl:choose>
				<xsl:when test="@maxOccurs=1">
					<xsl:text> = null</xsl:text>
				</xsl:when>
				<!-- fixed number. Use array -->
				<xsl:when test="string(@maxOccurs)=string(@minOccurs)">
					<xsl:text> = new </xsl:text>
					<xsl:value-of select="@itemType" />
					<xsl:text>[</xsl:text>
					<xsl:value-of select="@maxOccurs" />
					<xsl:text>]</xsl:text>
				</xsl:when>
				<!-- otherwise use Vector just for now -->
				<xsl:otherwise>
					<xsl:text> = new java.util.Vector()</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
			
			<xsl:text>;</xsl:text>
			<xsl:call-template name="CRLF"/>
			<xsl:call-template name="CRLF"/>
		</xsl:for-each>
		
		
		<!-- the set field method -->
		<xsl:text><![CDATA[
		/**
		 * sets the specified object to the specified field.
		 *
		 * This method is called to unmarshall objects from XML.
		 */
		public void setField( Object item, com.sun.tahiti.runtime.ll.NamedSymbol fieldName ) {
			
		]]></xsl:text>
		
		
	</xsl:template>
	
	
	
	
<!-- utility methods -->
<!--=================-->
<!--=================-->
	<xsl:template name="CRLF">
<xsl:text>
</xsl:text>
	</xsl:template>
</xsl:stylesheet>