<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:key name="contest" match="games/game" use="concat(hometeam, visitor)"/>
	<!--creates a key based on unique hometown-visitor element concatenation-->
	<xsl:template match="/">
		<games> <!--creates a root element in the output for well-formed XML-->
			<xsl:for-each select="games/game[ generate-id(.) = generate-id( key('contest', concat(hometeam, visitor) ) [1] ) ]">
				<!--takes the first element of each group-->
				<contest teams="{concat(hometeam, ' vs ',visitor)}">
				<!--based on the key, creates a <contest> element by which...-->
				<xsl:for-each select="key('contest', concat(hometeam, visitor))">
					<bettingoffice name="{bettingoffice}"> <!--betting office and...-->
					<xsl:copy-of select="quote1 | quotedraw | quote2"/> <!--quote values will be grouped-->
					</bettingoffice>
				</xsl:for-each>
				</contest>
			</xsl:for-each>
		</games>
	</xsl:template>
</xsl:stylesheet>




	
<!-- Stylus Studio meta-information - (c) 2004-2005. Progress Software Corporation. All rights reserved.
<metaInformation>
<scenarios ><scenario default="yes" name="Scenario1" userelativepaths="yes" externalpreview="no" url="games.xml" htmlbaseurl="" outputurl="" processortype="internal" useresolver="yes" profilemode="0" profiledepth="" profilelength="" urlprofilexml="" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext="" validateoutput="no" validator="internal" customvalidator=""/></scenarios><MapperMetaTag><MapperInfo srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/><MapperBlockPosition></MapperBlockPosition><TemplateContext></TemplateContext><MapperFilter side="source"></MapperFilter></MapperMetaTag>
</metaInformation>
-->