XBRL.php
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;
	}
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;
	}
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 ; }
This is a complementary one for SEC extension taxonomies.  It first loads the US_GAAP_2015
compiled taxonomy then adds the extension taxonomy given as parameter one

Compiles a taxonomy into an a collection of arrays then convert to JSON and save to a file.

@param string $taxonomy_file The name of the taxonomy file (xsd) to load
@param string $className The name of the XBRL taxonomy class to load
@param string $namespace The namespace of the extension taxonomy.
@param string $output_basename A name to use as the base for output files. 'xxx' will result in 'xxx.zip' and 'xxx.json' output files. If a name is not supplied, the basename of the schema file will be used.
@param string $compiledPath
@return boolean|XBRL <false, XBRL>
This is a complementary one for SEC extension taxonomies . It first loads the US_GAAP_2015 compiled taxonomy then adds the extension taxonomy given as parameter one