URI共通構文(C)

広告

広告

原文

最終更新
2006-04-14T01:01:00+09:00
この記事のURI参照
https://www.7key.jp/rfc/2396/rfc2396_c.html#source

URI共通構文(和訳)

最終更新
2006-09-27T23:12:00+09:00
この記事のURI参照
https://www.7key.jp/rfc/2396/rfc2396_c.html#translation

C. Examples of Resolving Relative URI References

   Within an object with a well-defined base URI of

      http://a/b/c/d;p?q

   the relative URI would be resolved as follows:

形式の整った基底URIhttp://a/b/c/d;p?qを持つオブジェクト内で、相対URIは次のように解決されるだろう。

C.1. Normal Examples

      g:h           =  g:h
      g             =  http://a/b/c/g
      ./g           =  http://a/b/c/g
      g/            =  http://a/b/c/g/
      /g            =  http://a/g
      //g           =  http://g
      ?y            =  http://a/b/c/?y
      g?y           =  http://a/b/c/g?y
      #s            =  (current document)#s
      g#s           =  http://a/b/c/g#s
      g?y#s         =  http://a/b/c/g?y#s
      ;x            =  http://a/b/c/;x
      g;x           =  http://a/b/c/g;x
      g;x?y#s       =  http://a/b/c/g;x?y#s
      .             =  http://a/b/c/
      ./            =  http://a/b/c/
      ..            =  http://a/b/
      ../           =  http://a/b/
      ../g          =  http://a/b/g
      ../..         =  http://a/
      ../../        =  http://a/
      ../../g       =  http://a/g

C.2. Abnormal Examples

   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 above.

以下の異常な例は通常起こり得ないが、全てのURIパーサはこれらも同様に解決できることが望ましい。各例ともに基底URIにはhttp://a/b/c/d;p?qを用いる。

   An empty reference refers to the start of the current document.

      <>            =  (current document)

空の参照は、現在の文書の先頭を参照する。

   Parsers must be careful in handling the case where there are more
   relative path ".." segments than there are hierarchical levels in the
   base URI's path.  Note that the ".." syntax cannot be used to change
   the authority component of a URI.

      ../../../g    =  http://a/../g
      ../../../../g =  http://a/../../g

基底URIのパスに含まれる階層よりも相対パスの".."セグメントの数が多い場合、パーサはその扱いに注意しなければならない。".."という構文がURIのオーソリティ成分の変更には用い得ないことに注意せよ。

   In practice, some implementations strip leading relative symbolic
   elements (".", "..") after applying a relative URI calculation, based
   on the theory that compensating for obvious author errors is better
   than allowing the request to fail.  Thus, the above two references
   will be interpreted as "http://a/g" by some implementations.

実際は、要求を失敗に終らせるよりも作者の明白なエラーを補正した方がより良いとの考えから、処理系によっては相対URIの確定後に相対記号要素("."と"..")を取り除くものもある。したがって、上記の2つの参照は処理系によってはhttp://a/gと解釈されることとなる。

   Similarly, parsers must avoid treating "." and ".." as special when
   they are not complete components of a relative path.

      /./g          =  http://a/./g
      /../g         =  http://a/../g
      g.            =  http://a/b/c/g.
      .g            =  http://a/b/c/.g
      g..           =  http://a/b/c/g..
      ..g           =  http://a/b/c/..g

同様に、パーサは"."と".."が相対パスの完全なコンポーネントではない場合、特別な扱いを避けなければならない。

   Less likely are cases where the relative URI uses unnecessary or
   nonsensical forms of the "." and ".." complete path segments.

      ./../g        =  http://a/b/g
      ./g/.         =  http://a/b/c/g/
      g/./h         =  http://a/b/c/g/h
      g/../h        =  http://a/b/c/h
      g;x=1/./y     =  http://a/b/c/g;x=1/y
      g;x=1/../y    =  http://a/b/c/y

あまりないことではあるが、"."や".."の完全なパスセグメントが相対URIにおいて不必要或いは無意味な形式で用いられることもある。

   All client applications remove the query component from the base URI
   before resolving relative URI.  However, some applications fail to
   separate the reference's query and/or fragment components from a
   relative path before merging it with the base path.  This error is
   rarely noticed, since typical usage of a fragment never includes the
   hierarchy ("/") character, and the query component is not normally
   used within relative references.

      g?y/./x       =  http://a/b/c/g?y/./x
      g?y/../x      =  http://a/b/c/g?y/../x
      g#s/./x       =  http://a/b/c/g#s/./x
      g#s/../x      =  http://a/b/c/g#s/../x

あらゆるクライアントアプリケーションは、相対URIを解決する前に基底URIからクエリコンポーネントを除去する。しかし、アプリケーションによっては基となるパスと結合する前に、相対パスからクエリー成分とフラグメント識別子の両方或いは片方を分割できないものがある。フラグメント識別子は通常階層文字("/")を含まず、クエリコンポーネントは通常相対参照内では用いられないため、このエラーはあまり注意を払われない。

   Some parsers allow the scheme name to be present in a relative URI 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.

      http:g        =  http:g           ; for validating parsers
                    |  http://a/b/c/g   ; for backwards compatibility

パーサによっては、基底URIのスキームと同じであれば相対URI中にスキーム名を含むことを許すものがある。これは既知の一部URI仕様書[RFC1630]のための抜け道と考えられるが、この方法は避けるべきである。

広告

Copyright (C) 2006 七鍵 key@do.ai 初版:2006年04月14日 最終更新:2006年09月27日