<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<!--
DTD for converting a flat XML collection of Business Information 
to a nested XML collection with renaming of tags.	

This XSLT Created in May 2003 by Anna Maclachlan & Mike Cote,
 National Research Council of Canada, 
 updated February 2004.

Designed for use with data from the Government of New Brunswick, Canada: 
  The 2002 Biznet Directory of Manufacturers and Selected Services to Industry 
  available at http://biznet.gnb.ca/ManuDirectory/
-->
	
<xsl:template match="/Import">
   	<BIZNET_ENTS>
		<xsl:apply-templates select="Row"/> 
	</BIZNET_ENTS>
</xsl:template>


<xsl:template match="Row">
   	<BIZNET_ENT>  	  
	   	<xsl:apply-templates select="ENT_NUM"/>
	   	<xsl:apply-templates select="OPER_NAME"/>
		<xsl:apply-templates select="YEAR_ESTA"/>
		<xsl:apply-templates select="PHYS_INDUSTRIAL_REGION"/>
		<xsl:apply-templates select="EXPORTER"/>
		<xsl:apply-templates select="NAICS_SEQUENCE"/>		
		<xsl:apply-templates select="PHONE"/>		
		<xsl:apply-templates select="LANG_SPOK"/>
		<xsl:apply-templates select="LANG_WRIT"/>		
		<xsl:apply-templates select="CURRENT_EMPLOYMENT_MAX"/>
	</BIZNET_ENT>
</xsl:template>


<xsl:template match="ENT_NUM">
		<NUMBER><xsl:value-of select="."/></NUMBER>
</xsl:template>

<xsl:template match="OPER_NAME">
		<NAME><xsl:value-of select="."/></NAME>
</xsl:template>

<xsl:template match="YEAR_ESTA">
		<ESTABLISHED><xsl:value-of select="."/></ESTABLISHED>
</xsl:template>

<xsl:template match="PHYS_INDUSTRIAL_REGION">
		<INDUSTRIAL_REGION><xsl:value-of select="."/></INDUSTRIAL_REGION>
</xsl:template>

<xsl:template match="EXPORTER">
		<EXPORT><xsl:value-of select="."/></EXPORT>
</xsl:template>

<xsl:template match="NAICS_SEQUENCE">
		<NAICS_INDUSTRY_SECTOR><xsl:value-of select="."/></NAICS_INDUSTRY_SECTOR>
</xsl:template>

<xsl:template match="PHONE">
		<CONTACT>
			<PHONE><xsl:value-of select="."/></PHONE>
			<xsl:apply-templates select="../FAX"/>
			<xsl:apply-templates select="../E_MAIL"/>
			<xsl:apply-templates select="../WEB_SITE"/>	
			<xsl:apply-templates select="../CNTCT_TITL"/>	
			<xsl:apply-templates select="../MAIL_ENG"/>
			<xsl:apply-templates select="../PLNT_ENG"/>
		</CONTACT>
</xsl:template>

<xsl:template match="FAX">
		<FAX><xsl:value-of select="."/></FAX>
</xsl:template>

<xsl:template match="E_MAIL">
		<E_MAIL><xsl:value-of select="."/></E_MAIL>
</xsl:template>

<xsl:template match="WEB_SITE">
		<WEB_SITE><xsl:value-of select="."/></WEB_SITE>
</xsl:template>


<xsl:template match="CNTCT_TITL">
		<CONTACT_PERSON>
			<PERSON_TITLE><xsl:value-of select="."/></PERSON_TITLE>
			<xsl:apply-templates select="../CNTCT_FIRS"/>
			<xsl:apply-templates select="../CNTCT_LAST"/>
			<xsl:apply-templates select="../CNTCT_WORK_ENG"/>				<xsl:apply-templates select="../CNTCT_WORK_FR"/>
		</CONTACT_PERSON>
</xsl:template>


<xsl:template match="CNTCT_FIRS">
		<FIRSTNAME><xsl:value-of select="."/></FIRSTNAME>
</xsl:template>

<xsl:template match="CNTCT_LAST">
		<LASTNAME><xsl:value-of select="."/></LASTNAME>
</xsl:template>

<xsl:template match="CNTCT_WORK_ENG">
		<POSITION_ENG><xsl:value-of select="."/></POSITION_ENG>
</xsl:template>

<xsl:template match="CNTCT_WORK_FR">
		<POSITION_FR><xsl:value-of select="."/></POSITION_FR>
</xsl:template>

<xsl:template match="MAIL_ENG">
		<MAILING_ADDRESS>
			<ADDRESS_LINE1_ENG><xsl:value-of select="."/></ADDRESS_LINE1_ENG>
			<xsl:apply-templates select="../MAIL_FRN"/>
			<xsl:apply-templates select="../MAIL_PLACE"/>
			<xsl:apply-templates select="../MAIL_PROV"/>	
			<xsl:apply-templates select="../MAIL_POST"/>	
		</MAILING_ADDRESS>
</xsl:template>

<xsl:template match="MAIL_FRN">
		<ADDRESS_LINE1_FR><xsl:value-of select="."/></ADDRESS_LINE1_FR>
</xsl:template>

<xsl:template match="MAIL_PLACE">
		<CITY><xsl:value-of select="."/></CITY>
</xsl:template>

<xsl:template match="MAIL_PROV">
		<PROVINCE><xsl:value-of select="."/></PROVINCE>
</xsl:template>

<xsl:template match="MAIL_POST">
		<POSTAL_CODE><xsl:value-of select="."/></POSTAL_CODE>
</xsl:template>

<xsl:template match="PLNT_ENG">
		<PLANT_ADDRESS>
			<ADDRESS_LINE1_ENG><xsl:value-of select="."/></ADDRESS_LINE1_ENG>
			<xsl:apply-templates select="../PLNT_FRN"/>
			<xsl:apply-templates select="../PLNT_PLACE"/>
			<xsl:apply-templates select="../PLNT_CNTY"/>	
		</PLANT_ADDRESS>
</xsl:template>

<xsl:template match="PLNT_FRN">
		<ADDRESS_LINE1_FR><xsl:value-of select="."/></ADDRESS_LINE1_FR>
</xsl:template>

<xsl:template match="PLNT_PLACE">
		<CITY><xsl:value-of select="."/></CITY>
</xsl:template>

<xsl:template match="PLNT_CNTY">
		<COUNTY><xsl:value-of select="."/></COUNTY>
</xsl:template>


<xsl:template match="LANG_SPOK">
		<LANGUAGE_SPOK><xsl:value-of select="."/></LANGUAGE_SPOK>
</xsl:template>

<xsl:template match="LANG_WRIT">
		<LANGUAGE_WRIT><xsl:value-of select="."/></LANGUAGE_WRIT>
</xsl:template>

<xsl:template match="CURRENT_EMPLOYMENT_MAX">
		<CURRENT_EMPLOYMENT>
			<MAX><xsl:value-of select="."/></MAX>
			<xsl:apply-templates select="../CURRENT_EMPLOYMENT_MIN"/>	
		</CURRENT_EMPLOYMENT>
</xsl:template>

<xsl:template match="CURRENT_EMPLOYMENT_MIN">
		<MIN><xsl:value-of select="."/></MIN>
</xsl:template>

</xsl:stylesheet>