URI: Difference between revisions
No edit summary |
a little editing |
||
(7 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 10: | Line 10: | ||
<nowiki>http://www.google.com/</nowiki> | <nowiki>http://www.google.com/</nowiki> | ||
The following table shows the breakdown of each URI component in the previous examples. | |||
{|border=1 cellpadding=3 cellspacing=0 | {|border=1 cellpadding=3 cellspacing=0 | ||
|- | |- | ||
! | !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 | |||
|- | |||
|<nowiki>http://www.google.com/</nowiki>||http||www.google.com||-||-||- | |||
|} | |} | ||
==URI references== | ==URI references== | ||
Many XML-based formats (including COLLADA) primarily use [http://gbiv.com/protocols/uri/rfc/rfc3986.html#usage URI references] | 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. | ||
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 28: | Line 31: | ||
<nowiki>http://www.google.com/</nowiki> | <nowiki>http://www.google.com/</nowiki> | ||
Here are | 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 36: | 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 59: | Line 62: | ||
| | | | ||
file:///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 <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.