I am confused as to why you cannot directly use the field `@@episode_number@@` rather than using built-in function in your DWT. If it is in the component it should be accessible. Otherwise I would recommend posting your component xml to give a better idea. And, indeed as @Eric mentions the DWT is evaluated inside to outside, so the innermost repeating region is evaluated before evaluating outer repeat regions or any references.


    <?xml version="1.0" encoding="utf-8"?><episodes><!-- TemplateBeginRepeat name="episodes" --><episode>   <episode_id>EPS_@@GetIdFromTcmUri(Component.ID)@@_@@episode_number@@</episode_id>
    <title>@@title@@</title>
    <media_links>
      <!-- TemplateBeginRepeat name="media_links" -->
      <media_link>
        <asset_id>Asset_EPS_@@episode_number@@</asset_id>
        <media_filepath>@@media_filepath@@</media_filepath>
        <media_type>@@media_type@@</media_type>
      </media_link>
      <!-- TemplateEndRepeat -->
    </media_links></episode><!-- TemplateEndRepeat --></episodes>

Component xml


    <Content xmlns="uuid:01cee2f6-035c-4ced-b225-abde4ceded5e">
    	<episodes>
    		<episode_number>5</episode_number>
    		<media_links>
    			<Link>Link5.1</Link>
    		</media_links>
    		<media_links>
    			<Link>Link5.2</Link>
    		</media_links>
    	</episodes>
    	<episodes>
    		<episode_number>6</episode_number>
        		<media_links>
    			<Link>Link6.1</Link>
    		</media_links>
    	</episodes>
    </Content>

Series DWTBB


    <?xml version="1.0" encoding="utf-8"?>
    <episodes>
	<!-- TemplateBeginRepeat name="episodes" -->
	<episode>
		<episode_id>EPS__@@episode_number@@</episode_id>
        <title>@@title@@</title>
		<media_links>
			<!-- TemplateBeginRepeat name="media_links" -->
			<media_link>
				<asset_id>Asset_EPS_@@episode_number@@</asset_id>
				<media_filepath>@@Link@@</media_filepath>
				<media_type>@@FieldPath@@</media_type>
			</media_link>
			<!-- TemplateEndRepeat -->
		</media_links>
	</episode>
	<!-- TemplateEndRepeat -->
    </episodes>