URI: Difference between revisions

From COLLADA Public Wiki
Jump to navigation Jump to search
SteveT (talk | contribs)
Elf (talk | contribs)
a little editing
 
(4 intermediate revisions by one other user not shown)
Line 1: Line 1:
A '''uniform resource identifier''' (URI) is a standard way of referencing elements, objects, files, and so on.
A '''uniform resource identifier''' (URI) is a standard way of referencing elements, objects, files, and so on.


==URIs==
==About URIs==
The basic [http://gbiv.com/protocols/uri/rfc/rfc3986.html#components URI syntax] is:
The basic [http://gbiv.com/protocols/uri/rfc/rfc3986.html#components URI syntax] is
  ''scheme''://''authority''/''path''?''query''#''fragment''
  ''scheme''://''authority''/''path''?''query''#''fragment''


Line 23: Line 23:


==URI references==
==URI references==
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.
Many XML-based formats (including COLLADA) primarily use ''[http://gbiv.com/protocols/uri/rfc/rfc3986.html#usage URI references]'', which 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 URI reference]''. A relative URI reference (''relative reference'' for short) 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.


Below are some examples of URI references. These examples are full URIs (since they include the <code>scheme:</code> prefix). Since these are full URIs, they can be used directly by an application without being resolved.
The following are some examples of URI references. These examples are full URIs (because they include the <code>scheme:</code> prefix). Because these are full URIs, an application  can use them directly without being resolved.


  file:///home/sthomas/models/cube.dae
  file:///home/sthomas/models/cube.dae
Line 31: Line 31:
  <nowiki>http://www.google.com/</nowiki>
  <nowiki>http://www.google.com/</nowiki>


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.
Here are more examples of URI references. Because these references don't include a <code>scheme:</code> prefix, they're relative references and must be resolved before an application can use them.


  /home/sthomas/models/cube.dae
  /home/sthomas/models/cube.dae
Line 39: Line 39:


==Relative reference resolution==
==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].
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
Assuming a base URI of
Line 62: Line 62:
|
|
  file:///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 an absolute path. That way the path from the base URI is discarded.
In the last example, a leading "/" character is added to make it a relative reference. Otherwise, the string <code>c:/path/document.dae</code> would be interpreted as a URI with scheme ''c'', which probably isn't what the author intended.


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

Latest revision as of 03:50, 28 May 2007

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

About URIs

The basic URI syntax is

scheme://authority/path?query#fragment

Examples of URIs include

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

The following table shows the breakdown of each URI component in the previous examples.

URI Scheme Authority Path Query Fragment
file:///home/sthomas/models/cube.dae file - /home/sthomas/models/cube.dae - -
file:///C:/models/sphere.dae#myGeometry file - /C:/models/sphere.dae - myGeometry
http://www.google.com/ http www.google.com - - -

URI references

Many XML-based formats (including COLLADA) primarily use URI references, which are a superset of URIs. A URI reference is either a URI or a relative URI reference. A relative URI reference (relative reference for short) 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.

The following are some examples of URI references. These examples are full URIs (because they include the scheme: prefix). Because these are full URIs, an application can use them directly without being resolved.

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

Here are more examples of URI references. Because these references don't include a scheme: prefix, they're relative references and must be resolved before an application can use them.

/home/sthomas/models/cube.dae
/C:/models/sphere.dae#myGeometry
../../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

In the last example, a leading "/" character is added to make it a relative reference. Otherwise, the string c:/path/document.dae would be interpreted as a URI with scheme c, which probably isn't what the author intended.

See also

External links