XBRL-US-TaxonomyPackage.php
public function saveTaxonomy( $cacheLocation )
	{
		$entryPoints = $this->getSchemaEntryPoints();
		$originalSchemaFile = $this->schemaFile;
		$originalNamespace = $this->schemaNamespace;

		$context = XBRL_Global::getInstance();
		if ( ! $context->useCache )
		{
			$context->useCache = true;
			$context->cacheLocation = $cacheLocation;
			$context->initializeCache();
		}

		try
		{
			foreach ( $entryPoints as $index => $entryPoint )
			{
				if ( $context->findCachedFile( $entryPoint ) )
				{
					$this->errors[] = "The schema file '{$this->schemaFile}' already exists in the cache.";
					continue;
				}

				// Get the namespace
				$this->schemaFile = $entryPoint;
				$this->schemaNamespace = null;
				// Find the schema document
				$content = trim( $this->getFile( $this->getActualUri( $this->schemaFile ) ) );

				$result = $this->processSchemaDocument( $context, $content, false );
				$this->setUrlMap();

				if ( ! $result )
				{
					$this->errors[] = "Unable to process the schema document";
					return false;
				}

				// Look for the non-schema file
				$firstFolder = $this->getFirstFolderName();
				$this->traverseContents( function( $path, $name, $type ) use( &$context, $firstFolder )
				{
					if ( $type == PATHINFO_DIRNAME ) return true;
					$extension = pathinfo( $name, PATHINFO_EXTENSION );
					if ( ! in_array( $extension, array( 'xml', 'xbrl', 'xsd' ) ) ) return true;
					$path = $path ? "$path$name" : "$name";
					$content = $this->getFile( $path );
					if ( $firstFolder )
					{
						$path = preg_replace( "|^$firstFolder/|", '/us-gaap/' . $this->taxonomyYear . "/", $path );
					}
					$uri = XBRL::resolve_path( $this->schemaFile, $path ); // $common = $this->getCommonRootFolder( $path, $this->schemaFile );
					if ( $context->findCachedFile( $uri ) ) return true;
					$context->saveCacheFile( $uri, $content );
					return true;
				} );

			}
		}
		catch( \Exception $ex )
		{
			$this->errors[] = $ex->getMessage();
		}
		finally
		{
			$this->schemaFile = $originalSchemaFile;
			$this->schemaNamespace = $originalNamespace;
		}
	}
public function saveTaxonomy( $cacheLocation )
	{
		$entryPoints = $this->getSchemaEntryPoints();
		$originalSchemaFile = $this->schemaFile;
		$originalNamespace = $this->schemaNamespace;

		$context = XBRL_Global::getInstance();
		if ( ! $context->useCache )
		{
			$context->useCache = true;
			$context->cacheLocation = $cacheLocation;
			$context->initializeCache();
		}

		try
		{
			foreach ( $entryPoints as $index => $entryPoint )
			{
				if ( $context->findCachedFile( $entryPoint ) )
				{
					$this->errors[] = "The schema file '{$this->schemaFile}' already exists in the cache.";
					continue;
				}

				// Get the namespace
				$this->schemaFile = $entryPoint;
				$this->schemaNamespace = null;
				// Find the schema document
				$content = trim( $this->getFile( $this->getActualUri( $this->schemaFile ) ) );

				$result = $this->processSchemaDocument( $context, $content, false );
				$this->setUrlMap();

				if ( ! $result )
				{
					$this->errors[] = "Unable to process the schema document";
					return false;
				}

				// Look for the non-schema file
				$firstFolder = $this->getFirstFolderName();
				$this->traverseContents( function( $path, $name, $type ) use( &$context, $firstFolder )
				{
					if ( $type == PATHINFO_DIRNAME ) return true;
					$extension = pathinfo( $name, PATHINFO_EXTENSION );
					if ( ! in_array( $extension, array( 'xml', 'xbrl', 'xsd' ) ) ) return true;
					$path = $path ? "$path$name" : "$name";
					$content = $this->getFile( $path );
					if ( $firstFolder )
					{
						$path = preg_replace( "|^$firstFolder/|", '/us-gaap/' . $this->taxonomyYear . "/", $path );
					}
					$uri = XBRL::resolve_path( $this->schemaFile, $path ); // $common = $this->getCommonRootFolder( $path, $this->schemaFile );
					if ( $context->findCachedFile( $uri ) ) return true;
					$context->saveCacheFile( $uri, $content );
					return true;
				} );

			}
		}
		catch( \Exception $ex )
		{
			$this->errors[] = $ex->getMessage();
		}
		finally
		{
			$this->schemaFile = $originalSchemaFile;
			$this->schemaNamespace = $originalNamespace;
		}
	}
public function saveTaxonomy ( $ cacheLocation ) { $ entryPoints = $ this -> getSchemaEntryPoints ( ) ; $ originalSchemaFile = $ this -> schemaFile ; $ originalNamespace = $ this -> schemaNamespace ; $ context = XBRL_Global :: getInstance ( ) ; if ( ! $ context -> useCache ) { $ context -> useCache = true ; $ context -> cacheLocation = $ cacheLocation ; $ context -> initializeCache ( ) ; } try { foreach ( $ entryPoints as $ index => $ entryPoint ) { if ( $ context -> findCachedFile ( $ entryPoint ) ) { $ this -> errors [ ] = "The schema file '{$this->schemaFile}' already exists in the cache." ; continue ; } // Get the namespace
 $ this -> schemaFile = $ entryPoint ; $ this -> schemaNamespace = null ; // Find the schema document
 $ content = trim ( $ this -> getFile ( $ this -> getActualUri ( $ this -> schemaFile ) ) ) ; $ result = $ this -> processSchemaDocument ( $ context , $ content , false ) ; $ this -> setUrlMap ( ) ; if ( ! $ result ) { $ this -> errors [ ] = "Unable to process the schema document" ; return false ; } // Look for the non-schema file
 $ firstFolder = $ this -> getFirstFolderName ( ) ; $ this -> traverseContents ( function ( $ path , $ name , $ type ) use ( & $ context , $ firstFolder ) { if ( $ type == PATHINFO_DIRNAME ) return true ; $ extension = pathinfo ( $ name , PATHINFO_EXTENSION ) ; if ( ! in_array ( $ extension , array ( 'xml' , 'xbrl' , 'xsd' ) ) ) return true ; $ path = $ path ? "$path$name" : "$name" ; $ content = $ this -> getFile ( $ path ) ; if ( $ firstFolder ) { $ path = preg_replace ( "|^$firstFolder/|" , '/us-gaap/' . $ this -> taxonomyYear . "/" , $ path ) ; } $ uri = XBRL :: resolve_path ( $ this -> schemaFile , $ path ) ; // $common = $this->getCommonRootFolder( $path, $this->schemaFile );
 if ( $ context -> findCachedFile ( $ uri ) ) return true ; $ context -> saveCacheFile ( $ uri , $ content ) ; return true ; } ) ; } } catch ( \ Exception $ ex ) { $ this -> errors [ ] = $ ex -> getMessage ( ) ; } finally { $ this -> schemaFile = $ originalSchemaFile ; $ this -> schemaNamespace = $ originalNamespace ; } }
Save the taxonomy for all entry points
Save the taxonomy for all entry points