private function includeSchemas( $taxonomy_schema, $xmlDocument, $targetNamespace, $depth )
	{
		$includes = $xmlDocument->children( "http://www.w3.org/2001/XMLSchema" )->include;
		if ( ! $includes ) return false;

		$basenames = array();
		foreach ( $includes as $key => $include )
		{
			if ( ! property_exists( $include->attributes(), 'schemaLocation' ) ) continue;
			$basename = basename( (string) $include->attributes()->schemaLocation );
			$basenames[] = $basename;

			$includeFile = XBRL::resolve_path( $taxonomy_schema, (string) $include->attributes()->schemaLocation );
			$includeDocument = $this->getXml( $includeFile, $this->context );

			// Check the file exists
			if ( ! $includeDocument )
			{
				if ( XBRL::isValidating() )
				$this->log()->taxonomy_validation( "5.1", "The xml schema document referenced in the 'include' tag is not valid",
					array(
						'include' => "'$basename'",
					)
				);

				return null;
			}

			// Check the target namespace is the same if one is provided
			$namespace = (string) $includeDocument['targetNamespace'];
			if ( ! empty( $namespace ) && $namespace != $targetNamespace )
			{
				if ( XBRL::isValidating() )
				$this->log()->taxonomy_validation( "5.1", "The namespace of the schema file to include is not the same as that if the main schema file",
					array(
						'expected' => "'$targetNamespace'",
						'actual' => "'$namespace'",
					)
				);

				return null;
			}

			$this->includedFiles[] = $includeFile;
			$this->context->schemaFileToNamespace[ $includeFile ] = $targetNamespace;
			$this->context->schemaFileToNamespace[ basename( $includeFile ) ] = $targetNamespace;

			// Note the use of the schemaLocation variable of *$this* because the component of the
			// included file are really being added to the current schema.
			$this->including = true;
			// $taxonomy = $this->loadSchema( $this->schemaLocation, $includeDocument, $targetNamespace, $depth + 1 );
			$taxonomy = $this->loadSchema( $includeFile, $includeDocument, $targetNamespace, $depth + 1 );
			$this->including = false;
		}

		return true;
	}