public static function compileExtensionXSD( $taxonomy_file, $className, $namespace = null, $output_basename = null, $compiledPath = null )
	{
		if ( ! filter_var( $taxonomy_file, FILTER_VALIDATE_URL ) ) $taxonomy_file = str_replace( '\\', '/', $taxonomy_file );

		$taxonomy = XBRL::loadExtensionXSD( $taxonomy_file, $className, $namespace, $compiledPath );
		if ( ! $taxonomy ) return false;

		$namespace = $taxonomy->getNamespace();

		// This is the folder in which the generated zip file will be saved.
		$pathinfo = pathinfo( $taxonomy_file );
		$output_path = is_null( $compiledPath )
			? ( isset( $pathinfo['dirname'] ) ? $pathinfo['dirname'] : "." )
			: $compiledPath;

		// Get the basename from the taxonomy if one is not supplied but if one is, make sure only the basename is used even if a full path has been specified.
		$output_basename = $output_basename === null ? $pathinfo['filename'] : basename( $output_basename );

		// Now remove the existng labels, arcs and locators so the saved file only contains the extension components
		if ( ! isset( $taxonomy->labels[ XBRL_Constants::$defaultLinkRole ] ) )
		{
			XBRL_Log::getInstance()->err( "There are no labels in the extension taxonomy" );
			return false;
		}

		// Grab the extension taxonomy labels
		// Normally the labels are held within the context but when an extension
		// taxonomy is being processed, a copy of the extension taxonomy labels
		// is held in the XBRL instance prepresenting the extension taxonomy.
		// See the end of the processLabelLinkbase() function in class XBRL.
		$labels =& $taxonomy->labels[ XBRL_Constants::$defaultLinkRole ];

		// Put them into the context
		$taxonomy->context->labels[ XBRL_Constants::$defaultLinkRole ] = $labels;

		// Delete the other schemas
		// $taxonomy->context->importedSchemas = array( $namespace => $taxonomy );
		$taxonomy->context->importedSchemas = array_diff_key( $taxonomy->context->importedSchemas, $taxonomy->previouslyImportedSchemas );

		// Create and save the JSON
		$json = $taxonomy->toJSON( $taxonomy->baseTaxonomy );

		file_put_contents( "$output_path/$output_basename.json", $json );
		$zip = new ZipArchive();
		$zip->open( "$output_path/$output_basename.zip", ZipArchive::CREATE | ZipArchive::OVERWRITE );
		$zip->addFile( "$output_path/$output_basename.json", "$output_basename.json" );

		if ( $zip->close() === false )
		{
			XBRL_Log::getInstance()->err( "Error closing zip file" );
			XBRL_Log::getInstance()->err( $zip->getStatusString() );
		}

		return $taxonomy;
	}