URI: Difference between revisions
No edit summary |
|||
Line 12: | Line 12: | ||
file:///home/sthomas/models/cube.dae | file:///home/sthomas/models/cube.dae | ||
file:///C:/models/sphere.dae | file:///C:/models/sphere.dae | ||
http://www.google.com/ | <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 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. |
Revision as of 21:08, 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.