<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body><section><h1>5.  Reference Resolution</h1><blockquote><p>This section defines the process of resolving a URI reference within
a context that allows relative references so that the result is a
string matching the &lt;URI&gt; syntax rule of Section 3.</p></blockquote><p>この章は相対参照が認められている文脈の URI 参照を解決して
3章の <code class="URI">ABNF</code> 構文規則に一致する文字列を得る処理を定義します。</p><section><h1>5.1.  Establishing a Base URI</h1><blockquote><p>The term &quot;relative&quot; implies that a &quot;base URI&quot; exists against which
the relative reference is applied.  Aside from fragment-only
references (Section 4.4), relative references are only usable when a
base URI is known.  A base URI must be established by the parser
prior to parsing URI references that might be relative.  A base URI
must conform to the &lt;absolute-URI&gt; syntax rule (Section 4.3).  If the
base URI is obtained from a URI reference, then that reference must
be converted to absolute form and stripped of any fragment component
prior to its use as a base URI.</p></blockquote><p><q>相対</q>という語は、相対参照が適用される<q>基底 URI</q>
が存在することを暗に示しています。相対参照は、素片だけの参照は別として、
基底 URI が分かっている時だけ利用できます。基底 URI
は構文解析器が相対かもしれない URI 参照を構文解析する前に確立されていなければなりません。
基底 URI は <code class="ABNF">absolute-URI</code> 構文規則に適合しなければなりません。
基底 URI が URI 参照から得られたものであるなら、その参照は完全形に変換し、
素片部品があれば落としてから基底 URI として使わなければなりません。</p><blockquote><p>The base URI of a reference can be established in one of four ways,
discussed below in order of precedence.  The order of precedence can
be thought of in terms of layers, where the innermost defined base
URI has the highest precedence.  This can be visualized graphically as follows:</p></blockquote><p>参照の基底 URI は次に優先順で取り上げる4つの方法のいずれかにより確立できます。
優先順は層のようなものとして考えることができ、
一番内側で定義された基底 URI が一番高い優先度を持ちます。
これは次のように図形的に視覚化できます。</p><blockquote><pre>         .----------------------------------------------------------.
         |  .----------------------------------------------------.  |
         |  |  .----------------------------------------------.  |  |
         |  |  |  .----------------------------------------.  |  |  |
         |  |  |  |  .----------------------------------.  |  |  |  |
         |  |  |  |  |       &lt;relative-reference&gt;       |  |  |  |  |
         |  |  |  |  `----------------------------------'  |  |  |  |
         |  |  |  | (5.1.1) Base URI embedded in content   |  |  |  |
         |  |  |  `----------------------------------------'  |  |  |
         |  |  | (5.1.2) Base URI of the encapsulating entity |  |  |
         |  |  |         (message, representation, or none)   |  |  |
         |  |  `----------------------------------------------'  |  |
         |  | (5.1.3) URI used to retrieve the entity            |  |
         |  `----------------------------------------------------'  |
         | (5.1.4) Default Base URI (application-dependent)         |
         `----------------------------------------------------------'</pre></blockquote><section><h1>5.1.1.  Base URI Embedded in Content</h1><blockquote><p>Within certain media types, a base URI for relative references can be
embedded within the content itself so that it can be readily obtained
by a parser.  This can be useful for descriptive documents, such as
tables of contents, which may be transmitted to others through
protocols other than their usual retrieval context (e.g., email or USENET news).</p></blockquote><p>媒体型によっては相対参照の基底 URI を内容自体に埋め込むことができ、
構文解析器がすぐに得ることができるようになっています。
これは記述的な文書、例えば通常の取出しの文脈以外のプロトコル
(例えば電子メイルや USENET ニュース) で転送されるかもしれないような、
目次のような文書に有用でしょう。</p><blockquote><p>It is beyond the scope of this specification to specify how, for each
media type, a base URI can be embedded.  The appropriate syntax, when
available, is described by the data format specification associated
with each media type.</p></blockquote><p>各媒体型でどう基底 URI を埋め込むかを規定するのはこの仕様書の適用範囲外です。
適切な構文は、定義されていれば各媒体型に関するデータ書式仕様書で説明されています。</p></section><section><h1>5.1.2.  Base URI from the Encapsulating Entity</h1><blockquote><p>If no base URI is embedded, the base URI is defined by the
representation's retrieval context.  For a document that is enclosed
within another entity, such as a message or archive, the retrieval
context is that entity.  Thus, the default base URI of a
representation is the base URI of the entity in which the
representation is encapsulated.</p></blockquote><p>基底 URI が埋め込まれていなければ、基底 URI は表現の取出しの文脈によって定義されます。
他の実体、例えばメッセージや保管庫に囲まれた文書では、
その実体が取出し文脈です。従って、表現がカプセル化されている実体の基底 URI
が表現の既定の基底 URI となります。</p><blockquote><p>A mechanism for embedding a base URI within MIME container types
(e.g., the message and multipart types) is defined by MHTML
[RFC2557].  Protocols that do not use the MIME message header syntax,
but that do allow some form of tagged metadata to be included within
messages, may define their own syntax for defining a base URI as part
of a message.</p></blockquote><p>MIME 包含子型 (<code class="MIME">message</code> 型と <code class="MIME">multipart</code> 型)
に基底 URI を埋込む仕組みは MHTML で定義されています。 MIME
メッセージ頭部構文を使わないプロトコルでメッセージ中に何らかの形の札付きメタデータを記述できるものは、
メッセージの一部として基底 URI を定義するための構文を定義して構いません。</p></section><section><h1>5.1.3.  Base URI from the Retrieval URI</h1><blockquote><p>If no base URI is embedded and the representation is not encapsulated
within some other entity, then, if a URI was used to retrieve the
representation, that URI shall be considered the base URI.  Note that
if the retrieval was the result of a redirected request, the last URI
used (i.e., the URI that resulted in the actual retrieval of the
representation) is the base URI.</p></blockquote><p>基底 URI が埋込まれておらず、表現が他の実体にカプセル化されているのでもなく、
表現の取出しに URI が使われたのであれば、その URI を基底 URI
と考えます。なお、取出しが再指向された要求の結果であるなら、
最後に使われた URI (つまり表現の実際の取出しに至った URI)
が基底 URI です。</p></section><section><h1>5.1.4.  Default Base URI</h1><blockquote><p>If none of the conditions described above apply, then the base URI is
defined by the context of the application.  As this definition is
necessarily application-dependent, failing to define a base URI by
using one of the other methods may result in the same content being
interpreted differently by different types of applications.</p></blockquote><p>前述の条件のどれもが当てはまらなければ、基底 URI
は応用の文脈によって定義されます。この定義は必然的に応用依存ですから、
他の方法のどれかによって基底 URI 
を定義することに失敗した場合は同じ内容が応用の種類によって違って解釈されてしまうことになるかもしれません。</p><blockquote><p>A sender of a representation containing relative references is
responsible for ensuring that a base URI for those references can be
established.  Aside from fragment-only references, relative
references can only be used reliably in situations where the base URI
is well defined.</p></blockquote><p>相対参照を含む表現の送信者はその参照の基底 URI が確立できることを保証する責任があります。
素片だけの参照は別として、相対参照は基底 URI
がよく定義された状況でのみ信用して使用することができます。</p></section></section><section><h1>5.2.  Relative Resolution</h1><blockquote><p>This section describes an algorithm for converting a URI reference
that might be relative to a given base URI into the parsed components
of the reference's target.  The components can then be recomposed, as
described in Section 5.3, to form the target URI.  This algorithm
provides definitive results that can be used to test the output of
other implementations.  Applications may implement relative reference
resolution by using some other algorithm, provided that the results
match what would be given by this one.</p></blockquote><p>この節では与えられた基底 URI に相対かもしれない URI 参照を構文解析して参照の対象の部品に分ける方法を説明します。
分かれた部品は5.3節で説明するように再合成して対象 URI
を作ることができます。この方法は他の実装の出力を試験するために使うことができる、
定義的な結果を提供します。応用は結果がこの方法で得られるものと一致する限りにおいて他の方法を使って相対参照を解決するように実装しても構いません。</p><section><h1>5.2.1.  Pre-parse the Base URI</h1><blockquote><p>The base URI (Base) is established according to the procedure of
Section 5.1 and parsed into the five main components described in
Section 3.  Note that only the scheme component is required to be
present in a base URI; the other components may be empty or
undefined.  A component is undefined if its associated delimiter does
not appear in the URI reference; the path component is never
undefined, though it may be empty.</p></blockquote><p>基底 URI (<code><var>基底</var></code>) は5.1節の手続きに従って確立し、
構文解析して3章で説明している5つの主要な部品に分けます。
基底 URI では <code class="ABNF">scheme</code> 部品だけが必須であることに注意してください。
他の部品は空または未定義かもしれません。部品は、対応する区切子が URI
参照に現れなければ、未定義です。 <code class="ABNF">path</code>
部品は空でも良いので、決して未定義となることはありません。</p><blockquote><p>Normalization of the base URI, as described in Sections 6.2.2 and
6.2.3, is optional.  A URI reference must be transformed to its
target URI before it can be normalized.</p></blockquote><p>6.2.2節と6.2.3節で説明している基底 URI の正規化は必須ではありません。
URI 参照は正規化する前に対象 URI に変形しなければなりません。</p></section><section><h1>5.2.2.  Transform References</h1><blockquote><p>For each URI reference (R), the following pseudocode describes an
algorithm for transforming R into its target URI (T):</p></blockquote><p>ある URI 参照 (<code><var>R</var></code>) に対して、
次の擬似符号は <code><var>R</var></code> をその対象 URI
(<code><var>T</var></code>) に変形する算法を説明しています。</p><blockquote><pre>      -- The URI reference is parsed into the five URI components
      --
      (R.scheme, R.authority, R.path, R.query, R.fragment) = parse(R);
      -- A non-strict parser may ignore a scheme in the reference
      -- if it is identical to the base URI's scheme.
      --
      if ((not strict) and (R.scheme == Base.scheme)) then
         undefine(R.scheme);
      endif;
      if defined(R.scheme) then
         T.scheme    = R.scheme;
         T.authority = R.authority;
         T.path      = remove_dot_segments(R.path);
         T.query     = R.query;
      else
         if defined(R.authority) then
            T.authority = R.authority;
            T.path      = remove_dot_segments(R.path);
            T.query     = R.query;
         else
            if (R.path == &quot;&quot;) then
               T.path = Base.path;
               if defined(R.query) then
                  T.query = R.query;
               else
                  T.query = Base.query;
               endif;
            else
               if (R.path starts-with &quot;/&quot;) then
                  T.path = remove_dot_segments(R.path);
               else
                  T.path = merge(Base.path, R.path);
                  T.path = remove_dot_segments(T.path);
               endif;
               T.query = R.query;
            endif;
            T.authority = Base.authority;
         endif;
         T.scheme = Base.scheme;
      endif;
      T.fragment = R.fragment;</pre></blockquote><ol><li><code><code class="comment">URI 参照を構文解析して5つの URI 部品に分割</code></code></li><li><code>(<var>R</var>.<code class="ABNF">scheme</code>, <var>R</var>.<code class="ABNF">authority</code>, <var>R</var>.<code class="ABNF">path</code>, <var>R</var>.<code class="ABNF">query</code>, <var>R</var>.<code class="ABNF">fragment</code>) = 構文解析(<var>R</var>)。</code></li><li><code><code class="comment">非厳密構文解析器は参照の <code class="ABNF">scheme</code> が基底 URI の <code class="ABNF">scheme</code> と同じなら無視しても構いません</code></code></li><li><code>もし ((厳密でない) かつ (<var>R</var>.<code class="ABNF">scheme</code> == <var>基底</var>.<code class="ABNF">scheme</code>)) なら</code><ol><li><code>未定義化(<var>R</var>.<code class="ABNF">scheme</code>)。</code></li></ol></li><li><code>もし 定義済(<var>R</var>.<code class="ABNF">scheme</code>) なら</code><ol><li><code><var>T</var>.<code class="ABNF">scheme</code> ← <var>R</var>.<code class="ABNF">scheme</code>。</code></li><li><code><var>T</var>.<code class="ABNF">authority</code> ← <var>R</var>.<code class="ABNF">authority</code>。</code></li><li><code><var>T</var>.<code class="ABNF">path</code> ← 点部分削除(<var>R</var>.<code class="ABNF">path</code>)。</code></li><li><code><var>T</var>.<code class="ABNF">query</code> ← <var>R</var>.<code class="ABNF">query</code>。</code></li></ol></li><li><code>さもなくば</code><ol><li><code>もし 定義済(<var>R</var>.<code class="ABNF">authority</code>) なら</code><ol><li><code><var>T</var>.<code class="ABNF">authority</code> ← <var>R</var>.<code class="ABNF">authority</code>。</code></li><li><code><var>T</var>.<code class="ABNF">path</code> ← 点部分削除(<var>R</var>.<code class="ABNF">path</code>)。</code></li><li><code><var>T</var>.<code class="ABNF">query</code> ← <var>R</var>.<code class="ABNF">query</code>。</code></li></ol></li><li><code>さもなくば</code><ol><li><code>もし (<var>R</var>.<code class="ABNF">path</code> == “”) なら</code><ol><li><code><var>T</var>.<code class="ABNF">path</code> ← <var>基底</var>.<code class="ABNF">path</code>。</code></li><li><code>もし 定義済(<var>R</var>.<code class="ABNF">query</code>) なら</code><ol><li><code><var>T</var>.<code class="ABNF">query</code> ← <var>R</var>.<code class="ABNF">query</code>。</code></li></ol></li><li><code>さもなくば</code><ol><li><code><var>T</var>.<code class="ABNF">query</code> ← <var>基底</var>.<code class="ABNF">query</code>。</code></li></ol></li></ol></li><li><code>さもなくば</code><ol><li><code>もし (<var>R</var>.<code class="ABNF">path</code> が “/” で始まる) なら</code><ol><li><code><var>T</var>.<code class="ABNF">path</code> ← 点部分削除(<var>R</var>.<code class="ABNF">path</code>)。</code></li></ol></li><li><code>さもなくば</code><ol><li><code><var>T</var>.<code class="ABNF">path</code> ← 併合(<var>基底</var>.<code class="ABNF">path</code>, <var>R</var>.<code class="ABNF">path</code>)。</code></li><li><code><var>T</var>.<code class="ABNF">path</code> ← 点部分削除(<var>T</var>.<code class="ABNF">path</code>)。</code></li></ol></li><li><code><var>T</var>.<code class="ABNF">query</code> ← <var>R</var>.<code class="ABNF">query</code>。</code></li></ol></li><li><code><var>T</var>.<code class="ABNF">authority</code> ← <var>基底</var>.<code class="ABNF">authority</code>。</code></li></ol></li><li><code><var>T</var>.<code class="ABNF">scheme</code> ← <var>基底</var>.<code class="ABNF">scheme</code>。</code></li></ol></li><li><code><var>T</var>.<code class="ABNF">fragment</code> ← <var>R</var>.<code class="ABNF">fragment</code>。</code></li></ol></section><section><h1>5.2.3.  Merge Paths</h1><blockquote><p>The pseudocode above refers to a &quot;merge&quot; routine for merging a
relative-path reference with the path of the base URI.  This is
accomplished as follows:</p></blockquote><p>前期擬似符号で基底 URI の <code class="ABNF">path</code> と相対経路参照を併合する
<q>併合</q>手順を使っていました。これは次のように実現します。</p><blockquote><ul><li>o  If the base URI has a defined authority component and an empty
path, then return a string consisting of &quot;/&quot; concatenated with the
reference's path; otherwise,</li><li>o  return a string consisting of the reference's path component
appended to all but the last segment of the base URI's path (i.e.,
excluding any characters after the right-most &quot;/&quot; in the base URI
path, or excluding the entire base URI path if it does not contain
any &quot;/&quot; characters).</li></ul></blockquote><ul><li>基底 URI が <code class="ABNF">authority</code> 部品を定義しており、
<code class="ABNF">path</code> が空であれば、 <code class="URI">/</code> に参照の <code class="ABNF">path</code>
を連結した文字列を返します。</li><li>前項を満たさない時は、基底 URI の <code class="ABNF">path</code> の最後の
<code class="ABNF">segment</code> 以外のすべて
(つまり、基底 URI の <code class="ABNF">path</code> の一番右の <code class="URI">/</code>
の後の文字を除いたものまたは <code class="URI">/</code> が含まれなければ基底 URI の
<code class="ABNF">path</code> 全体を除いたもの) に参照の <code class="ABNF">path</code>
部品をつなげた文字列を返します。</li></ul></section><section><h1>5.2.4.  Remove Dot Segments</h1><blockquote><p>The pseudocode also refers to a &quot;remove_dot_segments&quot; routine for
interpreting and removing the special &quot;.&quot; and &quot;..&quot; complete path
segments from a referenced path.  This is done after the path is
extracted from a reference, whether or not the path was relative, in
order to remove any invalid or extraneous dot-segments prior to
forming the target URI.  Although there are many ways to accomplish
this removal process, we describe a simple method using two string buffers.</p></blockquote><p>擬似符号は参照された <code class="ABNF">path</code> の特別な <code class="URI">.</code> または
<code class="URI">..</code> だけの <code class="ABNF">path</code> <code class="ABNF">segment</code>
を解釈・削除する<q>点部分削除</q>手順も参照しています。
これは不当な点部分や余分な点部分を対象 URI を作る前に除去するために 
<code class="ABNF">path</code> を参照から取り出した後にその 
<code class="ABNF">path</code> が相対であろうとなかろうと行います。</p><blockquote><ol><li>1.  The input buffer is initialized with the now-appended path
components and the output buffer is initialized to the empty string.</li><li>2.  While the input buffer is not empty, loop as follows:<ol><li>A.  If the input buffer begins with a prefix of &quot;../&quot; or &quot;./&quot;,
then remove that prefix from the input buffer; otherwise,</li><li>B.  if the input buffer begins with a prefix of &quot;/./&quot; or &quot;/.&quot;,
where &quot;.&quot; is a complete path segment, then replace that
prefix with &quot;/&quot; in the input buffer; otherwise,</li><li>C.  if the input buffer begins with a prefix of &quot;/../&quot; or &quot;/..&quot;,
where &quot;..&quot; is a complete path segment, then replace that
prefix with &quot;/&quot; in the input buffer and remove the last
segment and its preceding &quot;/&quot; (if any) from the output
buffer; otherwise,</li><li>D.  if the input buffer consists only of &quot;.&quot; or &quot;..&quot;, then remove
that from the input buffer; otherwise,</li><li>E.  move the first path segment in the input buffer to the end of
the output buffer, including the initial &quot;/&quot; character (if
any) and any subsequent characters up to, but not including,
the next &quot;/&quot; character or the end of the input buffer.</li></ol></li><li>3.  Finally, the output buffer is returned as the result of
remove_dot_segments.</li></ol></blockquote><ol><li>入力バッファを今つなげた <code class="ABNF">path</code> 部品で初期化し、
出力バッファを空文字列で初期化します。</li><li>入力バッファが空ではない間、次を繰り返します。<ol><li>入力バッファの最初が <code class="URI">../</code> または <code class="URI">./</code>
であるなら、これらを入力バッファから取り除きます。</li><li>前項の条件を満たさず、入力バッファの最初が <code class="URI">/./</code> または
<code class="URI">/.</code> で <code class="URI">.</code> が <code class="ABNF">path</code> <code class="ABNF">segment</code>
全体であるなら、これらを入力バッファで <code class="URI">/</code> に置き換えます。</li><li>前項までの条件を満たさず、入力バッファの最初が <code class="URI">/../</code> または
<code class="URI">/..</code> で <code class="URI">..</code> が <code class="ABNF">path</code> <code class="ABNF">segment</code>
全体であるなら、これらを入力バッファで <code class="URI">/</code> に置き換え、
出力バッファの最後の <code class="ABNF">segment</code> とその前の <code class="URI">/</code>
を (あれば) 削除します。</li><li>前項までの条件を満たさず、入力バッファが <code class="URI">.</code> または
<code class="URI">..</code> だけであるなら、入力バッファからこれらを削除します。</li><li>前項までの条件を満たさないなら、入力バッファの最初の <code class="ABNF">path</code>
<code class="ABNF">segment</code> を出力バッファの最後に移動します。
移動するのは (あれば) 最初の <code class="URI">/</code> 文字とその次の
<code class="URI">/</code> 文字または入力バッファの最後までのすべての文字で、
2番目の <code class="URI">/</code> 文字は含みません。</li></ol></li><li>最後に、出力バッファを点部分削除の結果として返します。</li></ol><blockquote><p>Note that dot-segments are intended for use in URI references to
express an identifier relative to the hierarchy of names in the base
URI.  The remove_dot_segments algorithm respects that hierarchy by
removing extra dot-segments rather than treat them as an error or
leaving them to be misinterpreted by dereference implementations.</p></blockquote><p>点部分は URI 参照で基底 URI の名前の階層に相対な識別子を表現するために
使うのを想定していることに注意してください。点部分削除の算法は余分な点部分を削除した階層を選び、
それを誤りとしたり残しておいて参照を解く実装が誤解するようにしたりはしていません。</p><blockquote><p>The following illustrates how the above steps are applied for two
examples of merged paths, showing the state of the two buffers after each step.</p></blockquote><p>次に <code class="ABNF">path</code> を併合する例2つにより先の手順がどう適用されるかを各段階におけるバッファの内容と共に示します。</p><blockquote><table><tbody><tr><td>STEP</td><td>OUTPUT BUFFER</td><td>INPUT BUFFER</td></tr><tr><td></td></tr><tr><td>1 :</td><td></td><td>/a/b/c/./../../g</td></tr><tr><td>2E:</td><td>/a</td><td>/b/c/./../../g</td></tr><tr><td>2E:</td><td>/a/b</td><td>/c/./../../g</td></tr><tr><td>2E:</td><td>/a/b/c</td><td>/./../../g</td></tr><tr><td>2B:</td><td>/a/b/c</td><td>/../../g</td></tr><tr><td>2C:</td><td>/a/b</td><td>/../g</td></tr><tr><td>2C:</td><td>/a</td><td>/g</td></tr><tr><td>2E:</td><td>/a/g</td></tr></tbody></table><table><tbody><tr><td>STEP</td><td>OUTPUT BUFFER</td><td>INPUT BUFFER</td></tr><tr><td></td></tr><tr><td>1 :</td><td></td><td>mid/content=5/../6</td></tr><tr><td>2E:</td><td>mid</td><td>/content=5/../6</td></tr><tr><td>2E:</td><td>mid/content=5</td><td>/../6</td></tr><tr><td>2C:</td><td>mid</td><td>/6</td></tr><tr><td>2E:</td><td>mid/6</td></tr></tbody></table></blockquote><blockquote><p>Some applications may find it more efficient to implement the
remove_dot_segments algorithm by using two segment stacks rather than strings.</p></blockquote><p>応用によっては点部分削除の算法を文字列ではなく2つの <code class="ABNF">segment</code>
スタックを使って実装した方が効率が良いかもしれません。</p><blockquote><p>Note: Beware that some older, erroneous implementations will fail
to separate a reference's query component from its path component
prior to merging the base and reference paths, resulting in an
interoperability failure if the query component contains the
strings &quot;/../&quot; or &quot;/./&quot;.</p></blockquote><p>注意: 古い誤った実装は参照の <code class="ABNF">query</code> 部品を
基底 <code class="ABNF">path</code> および参照の <code class="ABNF">path</code> を併合する前に
<code class="ABNF">path</code> 部品から分離していないので、 <code class="ABNF">query</code> 部品が
<code class="URI">/../</code> や <code class="URI">/./</code> のような文字列を含んでいると相互運用できなくなることがあります。</p></section></section><section><h1>5.3.  Component Recomposition</h1><blockquote><p>Parsed URI components can be recomposed to obtain the corresponding
URI reference string.  Using pseudocode, this would be:</p></blockquote><p>構文解析した URI 部品は再合成して対応する URI 参照文字列を得ることができます。
擬似符号を使うと次のようになります。</p><blockquote><pre>      result = &quot;&quot;
      if defined(scheme) then
         append scheme to result;
         append &quot;:&quot; to result;
      endif;
      if defined(authority) then
         append &quot;//&quot; to result;
         append authority to result;
      endif;
      append path to result;
      if defined(query) then
         append &quot;?&quot; to result;
         append query to result;
      endif;
      if defined(fragment) then
         append &quot;#&quot; to result;
         append fragment to result;
      endif;
      return result;</pre></blockquote><blockquote><p>Note that we are careful to preserve the distinction between a
component that is undefined, meaning that its separator was not
present in the reference, and a component that is empty, meaning that
the separator was present and was immediately followed by the next
component separator or the end of the reference.</p></blockquote><p>部品が未定義であって参照に分離子が現れない場合と部品が空であって分離子が現れてその後にすぐ次の部品の分離子が続くかすぐに参照の終わりになる場合の区別を注意して保存していることに注意してください。</p></section><section><h1>5.4.  Reference Resolution Examples</h1><blockquote><p>Within a representation with a well defined base URI of</p></blockquote><p>ある表現において基底 URI が</p><blockquote><p><samp class="URI">http://a/b/c/d;p?q</samp></p></blockquote><blockquote><p>a relative reference is transformed to its target URI as follows.</p></blockquote><p>とよく定義されている時、相対参照は次のように対象 URI
に変形します。</p><section><h1>5.4.1.  Normal Examples</h1><blockquote><table><tbody><tr><td>g:h</td><td>=  &quot;g:h&quot;</td></tr><tr><td>g</td><td>=  &quot;http://a/b/c/g&quot;</td></tr><tr><td>./g</td><td>=  &quot;http://a/b/c/g&quot;</td></tr><tr><td>g/</td><td>=  &quot;http://a/b/c/g/&quot;</td></tr><tr><td>/g</td><td>=  &quot;http://a/g&quot;</td></tr><tr><td>//g</td><td>=  &quot;http://g&quot;</td></tr><tr><td>?y</td><td>=  &quot;http://a/b/c/d;p?y&quot;</td></tr><tr><td>g?y</td><td>=  &quot;http://a/b/c/g?y&quot;</td></tr><tr><td>#s</td><td>=  &quot;http://a/b/c/d;p?q#s&quot;</td></tr><tr><td>g#s</td><td>=  &quot;http://a/b/c/g#s&quot;</td></tr><tr><td>g?y#s</td><td>=  &quot;http://a/b/c/g?y#s&quot;</td></tr><tr><td>;x</td><td>=  &quot;http://a/b/c/;x&quot;</td></tr><tr><td>g;x</td><td>=  &quot;http://a/b/c/g;x&quot;</td></tr><tr><td>g;x?y#s</td><td>=  &quot;http://a/b/c/g;x?y#s&quot;</td></tr><tr><td></td><td>=  &quot;http://a/b/c/d;p?q&quot;</td></tr><tr><td>.</td><td>=  &quot;http://a/b/c/&quot;</td></tr><tr><td>./</td><td>=  &quot;http://a/b/c/&quot;</td></tr><tr><td>..</td><td>=  &quot;http://a/b/&quot;</td></tr><tr><td>../</td><td>=  &quot;http://a/b/&quot;</td></tr><tr><td>../g</td><td>=  &quot;http://a/b/g&quot;</td></tr><tr><td>../..</td><td>=  &quot;http://a/&quot;</td></tr><tr><td>../../</td><td>=  &quot;http://a/&quot;</td></tr><tr><td>../../g</td><td>=  &quot;http://a/g&quot;</td></tr></tbody></table></blockquote></section><section><h1>5.4.2.  Abnormal Examples</h1><blockquote><p>Although the following abnormal examples are unlikely to occur in
normal practice, all URI parsers should be capable of resolving them
consistently.  Each example uses the same base as that above.</p></blockquote><p>次の異常な例は実際には起こりそうもありませんが、
すべての URI 構文解析器は一貫した形で解決できるべきです。
各例は先と同じ基底を使います。</p><blockquote><p>Parsers must be careful in handling cases where there are more &quot;..&quot;
segments in a relative-path reference than there are hierarchical
levels in the base URI's path.  Note that the &quot;..&quot; syntax cannot be
used to change the authority component of a URI.</p></blockquote><p>構文解析器は相対経路参照が基底 URI の <code class="ABNF">path</code>
の階層の水準よりも多くの <code class="URI">..</code> <code class="ABNF">segment</code>
を持っている場合の取扱いに注意しなければなりません。
なお、 <code class="ABNF">..</code> 構文は URI の <code class="ABNF">authority</code>
部品を変えるために使うことはできません。</p><blockquote><table><tbody><tr><td>../../../g</td><td>=</td><td>http://a/g</td></tr><tr><td>../../../../g</td><td>=</td><td>http://a/g</td></tr></tbody></table></blockquote><blockquote><p>Similarly, parsers must remove the dot-segments &quot;.&quot; and &quot;..&quot; when
they are complete components of a path, but not when they are only
part of a segment.</p></blockquote><p>同様に、構文解析器は点部分 <code class="URI">.</code> および <code class="URI">..</code>
が <code class="ABNF">path</code> の完全な部品である時には削除しなければなりませんが、 
<code class="ABNF">segment</code> の一部である時には削除してはなりません。</p><blockquote><table><tbody><tr><td>/./g</td><td>=</td><td>http://a/g</td></tr><tr><td>/../g</td><td>=</td><td>http://a/g</td></tr><tr><td>g.</td><td>=</td><td>http://a/b/c/g.</td></tr><tr><td>.g</td><td>=</td><td>http://a/b/c/.g</td></tr><tr><td>g..</td><td>=</td><td>http://a/b/c/g..</td></tr><tr><td>..g</td><td>=</td><td>http://a/b/c/..g</td></tr></tbody></table></blockquote><blockquote><p>Less likely are cases where the relative reference uses unnecessary
or nonsensical forms of the &quot;.&quot; and &quot;..&quot; complete path segments.</p></blockquote><p>相対参照が不必要・非本質的な形で <code class="URI">.</code> や <code class="URI">..</code>
を完全な <code class="ABNF">path</code> <code class="ABNF">segment</code> としている場合。</p><blockquote><table><tbody><tr><td>./../g</td><td>=</td><td>http://a/b/g</td></tr><tr><td>./g/.</td><td>=</td><td>http://a/b/c/g/</td></tr><tr><td>g/./h</td><td>=</td><td>http://a/b/c/g/h</td></tr><tr><td>g/../h</td><td>=</td><td>http://a/b/c/h</td></tr><tr><td>g;x=1/./y</td><td>=</td><td>http://a/b/c/g;x=1/y</td></tr><tr><td>g;x=1/../y</td><td>=</td><td>http://a/b/c/y</td></tr></tbody></table></blockquote><blockquote><p>Some applications fail to separate the reference's query and/or
fragment components from the path component before merging it with
the base path and removing dot-segments.  This error is rarely
noticed, as typical usage of a fragment never includes the hierarchy
(&quot;/&quot;) character and the query component is not normally used within
relative references.</p></blockquote><p>参照の <code class="ABNF">query</code> 部品や <code class="ABNF">fragment</code>
部品を <code class="ABNF">path</code> 部品と基底 <code class="ABNF">path</code> を併合して点部分を削除する前に分離しておかない応用もあります。
<code class="ABNF">fragment</code> は普通階層文字 (<code class="URI">/</code>)
を含みませんし、 <code class="ABNF">query</code> 部品は相対参照では普通使いませんから、
この誤りは滅多に気づかれません。</p><blockquote><table><tbody><tr><td>g?y/./x</td><td>=</td><td>http://a/b/c/g?y/./x</td></tr><tr><td>g?y/../x</td><td>=</td><td>http://a/b/c/g?y/../x</td></tr><tr><td>g#s/./x</td><td>=</td><td>http://a/b/c/g#s/./x</td></tr><tr><td>g#s/../x</td><td>=</td><td>http://a/b/c/g#s/../x</td></tr></tbody></table></blockquote><blockquote><p>Some parsers allow the scheme name to be present in a relative
reference if it is the same as the base URI scheme.  This is
considered to be a loophole in prior specifications of partial URI
[RFC1630].  Its use should be avoided but is allowed for backward compatibility.</p></blockquote><p>構文解析器によっては相対参照に基底 URI scheme と同じ <code class="ABNF">scheme</code> 
名が現れるのを認めています。これは部分 URI についての以前の仕様の抜け穴と考えられています。
これを使うのは避けるべきですが、後方互換性のために認めています。</p><blockquote><table><tbody><tr><td>http:g</td><td>=</td><td>http:g</td><td>; for strict parsers</td></tr><tr><td></td><td>/</td><td>http://a/b/c/g</td><td>; for backward compatibility</td></tr></tbody></table></blockquote></section></section></section><section><h1>License</h1><p><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">RFCのライセンス</anchor></p></section><section><h1>メモ</h1></section></body></html>