URI: Difference between revisions

From COLLADA Public Wiki
Jump to navigation Jump to search
SteveT (talk | contribs)
No edit summary
SteveT (talk | contribs)
No edit summary
Line 4: Line 4:
  ''scheme''://''authority''/''path''?''query''#''fragment''
  ''scheme''://''authority''/''path''?''query''#''fragment''


URIs are either absolute or relative:
==URI references==
*An ''absolute URI'' contains a scheme and a colon separator.  
Many XML-based formats (including COLLADA) primarily use [http://gbiv.com/protocols/uri/rfc/rfc3986.html#usage URI references]. URI references are a superset of URIs. A URI reference is either a URI or a [http://gbiv.com/protocols/uri/rfc/rfc3986.html#relative-ref relative reference]. A URI reference is a relative reference if it doesn't include the <code>scheme:</code> prefix. Before a relative reference can be used, it must be converted to a URI in a process called [http://gbiv.com/protocols/uri/rfc/rfc3986.html#reference-resolution reference resolution]. The reference resolution algorithm combines the relative reference with a [http://gbiv.com/protocols/uri/rfc/rfc3986.html#base-uri base URI] to form the full URI that is then used by the application.
*A ''relative URI'' is any URI that does not contain both a scheme and a colon separator. A relative URI can be a relative path, an absolute path, or just a fragment.


The ''fragment'' portion references an element that can be found within the same document as the URI. An example of this:
==Examples of URI references==
Below are some examples of URI references. These examples are full URIs (since they include the <code>scheme:</code> prefix). In the first two examples, the scheme is ''file''. In the last example the scheme is ''http''. Since these are full URIs, they can be used directly by an application without being resolved.
 
file:///home/sthomas/models/cube.dae
file:///C:/models/sphere.dae
http://www.google.com/
 
Here are some more examples of URI references. Since these references don't include a <code>scheme:</code> prefix, they're relative references and will need to be resolved before they can be used by an application.
 
/home/sthomas/models/cube.dae
/C:/models/sphere.dae
../../image.jpg
  #redMaterial
  #redMaterial
==Relative reference resolution==
A relative reference is combined with a base URI to yield a full URI in a process called reference resolution. The full algorithm is given [http://gbiv.com/protocols/uri/rfc/rfc3986.html#relative-transform here].
Assuming a base URI of
file:///C:/A/B/C/D/doc.dae
here are some examples of how relative references would be resolved:
{| border=1 cellspacing=0 cellpadding=4
|-
!Relative Reference||Resolved URI
|-
|
./path/document.dae                 
|
file:///c:/A/B/C/D/path/document.dae
|-
|
../../../path/document.dae#elementID 
|
file:///A/path/document.dae#elementID
|-
|
/c:/path/document.dae#Light01       
|
file:///c:/path/document.dae#Light01
|-
|
c:/path/document.dae                 
|
file:///c:/A/B/C/D/c:/path/document.dae
|}
The last example probably doesn't resolve the way the author intended. An initial "/" character as in the third example is necessary to make the reference as being an absolute path. That way the path from the base URI is discarded.


==See also==
==See also==

Revision as of 21:06, 25 May 2007

A uniform resource identifier (URI) is a standard way of referencing elements, objects, files, and so on.

The basic URI syntax is:

scheme://authority/path?query#fragment

URI references

Many XML-based formats (including COLLADA) primarily use URI references. URI references are a superset of URIs. A URI reference is either a URI or a relative reference. A URI reference is a relative reference if it doesn't include the scheme: prefix. Before a relative reference can be used, it must be converted to a URI in a process called reference resolution. The reference resolution algorithm combines the relative reference with a base URI to form the full URI that is then used by the application.

Examples of URI references

Below are some examples of URI references. These examples are full URIs (since they include the scheme: prefix). In the first two examples, the scheme is file. In the last example the scheme is http. Since these are full URIs, they can be used directly by an application without being resolved.

file:///home/sthomas/models/cube.dae
file:///C:/models/sphere.dae
http://www.google.com/

Here are some more examples of URI references. Since these references don't include a scheme: prefix, they're relative references and will need to be resolved before they can be used by an application.

/home/sthomas/models/cube.dae
/C:/models/sphere.dae
../../image.jpg
#redMaterial

Relative reference resolution

A relative reference is combined with a base URI to yield a full URI in a process called reference resolution. The full algorithm is given here.

Assuming a base URI of

file:///C:/A/B/C/D/doc.dae

here are some examples of how relative references would be resolved:

Relative Reference Resolved URI
./path/document.dae                   
file:///c:/A/B/C/D/path/document.dae
../../../path/document.dae#elementID  
file:///A/path/document.dae#elementID
/c:/path/document.dae#Light01         
file:///c:/path/document.dae#Light01
c:/path/document.dae                  
file:///c:/A/B/C/D/c:/path/document.dae

The last example probably doesn't resolve the way the author intended. An initial "/" character as in the third example is necessary to make the reference as being an absolute path. That way the path from the base URI is discarded.

See also

External links