public function rebuildLabelsByHRef()
	{
		$labels =& $this->context->labels[ XBRL_Constants::$defaultLinkRole ];
		$locators =& $labels['locators'];

		if ( isset( $labels['arcs'] ) )
		{
			$reverseArcs = array();

			foreach ( $labels['arcs'] as $from => $to )
			{
				foreach ( $to as $labelLabel => $items )
				{
					$reverseArcs[ $labelLabel ] = $from;
				}
			}

			if ( isset( $labels['labels'] ) )
			{
				$labelsByHref = array();

				foreach ( $labels['labels'] as $roleKey => $languageLabels )
				{
					foreach ( $languageLabels as $lang => $langLabels )
					{
						foreach ( $langLabels as $labelLabel => $items )
						{
							if ( ! isset( $items['id'] ) ) continue;

							// Lookup the label in the arcs array
							if ( ! isset( $reverseArcs[ $labelLabel ] ) )
							{
								$this->log()->warning( "Ooops. Label $labelLabel not found in the arcs array" );
								continue;
							}

							$label = $reverseArcs[ $labelLabel ];

							/*
							if ( ! isset( $locators[ $label ] ) )
							{
								$this->log()->warning( "Ooops. Label $label not found in the locators array" );
								continue;
							}

							$parts = explode( '#', $locators[ $label ] );
							*/

							$parts = explode( '#', $label );
							if ( ! isset( $labelsByHref[ $parts[0] ] ) )
							{
								$labelsByHref[ $parts[0] ] = array();
							}

							$labelsByHref[ $parts[0] ][ $items['id'] ][] = array(
								'role'	=> $roleKey,
								'label'	=> $labelLabel,
								'lang'	=> $lang,
							);
						}
					}
				}

				$labels['labelshref'] = $labelsByHref;
				unset( $labelsByHref );
			}

			unset( $reverseArcs );
		}

		unset( $locators );
		unset( $labels );
	}