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