DocumentID: ECMA-376/Part2/AnnexB Title: ECMA-376, Part2: Annex B. Pack URI Extracted-From: ECMA-376 Office Open XML File Formats, 1st Edition / December 2006 Warning: Coverted to HTML format by a script known to have bugs
A package is a logical entity that holds a collection of parts. This Open Packaging specification defines a way to use URIs to reference part resources inside a package. This approach defines a new scheme in accordance with the guidelines in RFC 3986.
The following terms are used as they are defined in RFC 3986: scheme, authority, path, segment, reserved characters, sub-delims, unreserved characters, pchar, pct-encoded characters, query, fragment, and resource.
RFC 3986 provides an extensible mechanism for defining new kinds of URIs based on new schemes. Schemes are the prefix in a URI before the colon. [Example: "http", "ftp", "file" end example] This Open Packaging specification defines a specific URI scheme used to refer to parts in a package: the pack scheme. A URI that uses the pack scheme is called a pack URI.
The pack URI grammar is defined as follows:
pack_URI = "pack://" authority [ "/" | path ]
authority = *( unreserved | sub-delims | pct-encoded )
path = 1*( "/" segment )
segment = 1*( pchar )
unreserved, sub-delims, pchar and pct-encoded are defined in RFC 3986
The authority component contains an embedded URI that points to a package. The package implementer shall create an embedded URI that meets the requirements defined in RFC 3986 for a valid URI. [M7.1] §B.3 describes the rules for composing pack URIs by combining the URI of an entire package resource with a part name.
The package implementer shall not create an authority component with an unescaped colon (:) character. [M7.4] Consumer applications, based on the obsolete URI specification RFC 2396, might tolerate the presence of an unescaped colon character in an authority component. [O7.1]
The optional path component identifies a particular part within the package. The package implementer shall only create path components that conform to the part naming rules. When the path component is missing, the resource identified by the pack URI is the package as a whole. [M7.2]
In order to be able to embed the URI of the package in the pack URI, it is necessary either to replace or to percent-encode occurrences of certain characters in the embedded URI. For example, forward slashes (/) are replaced with commas (,). The rules for these substitutions are described in §B.3.
The optional query component in a pack URI is ignored when resolving the URI to a part.
A pack URI might have a fragment identifier as specified in RFC 3986. If present, this fragment applies to whatever resource the pack URI identifies.
[Example:
Example B--1. Using the pack URI to identify a part
The following URI identifies the "/a/b/foo.xml" part within the "http://www.openxmlformats.org/my.container" package resource:
pack://http%3c,,www.openxmlformats.org,my.container/a/b/foo.xml
end example]
[Example:
Example B--2. Equivalent pack URIs
The following pack URIs are equivalent:
pack://http%3c,,www.openxmlformats.org,my.container
pack://http%3c,,www.openxmlformats.org,my.container/
end example]
[Example:
Example B--3. A pack URI with percent-encoded characters
The following URI identifies the "/c/d/bar.xml" part within the "http://myalias:pswr@www.my.com/containers.aspx?my.container" package:
pack://http%3c,,myalias%3cpswr%40www.my.com,containers.aspx%3fmy.container
/c/d/bar.xml
end example]
The following is an algorithm for resolving a pack URI to a resource (either a package or a part):
[Example:
Example B--4. Resolving a pack URI to a resource
Given the pack URI:
pack://http%3c,,www.my.com,packages.aspx%3fmy.package/a/b/foo.xml
The components:
<authority>= http%3c,,www.my.com,packages.aspx%3fmy.package
<path>= /a/b/foo.xml
Are converted to the package URI:
http://www.my.com/packages.aspx?my.package
And the path:
/a/b/foo.xml
Therefore, this URI refers to a part named "/a/b/foo.xml" in the package at the following URI: http://www.my.com/packages.aspx?my.package.
end example]
The following is an algorithm for composing a pack URI from the URI of an entire package resource and a part name.
In order to be suitable for creating a pack URI, the URI reference of a package resource shall conform to RFC 3986 requirements for valid absolute URIs.
To compose a pack URI from the absolute package URI and a part name, the following steps shall be performed, in order:
The result of this operation will be the pack URI that refers to the resource specified by the part name.
[Example:
Example B--5. Composing a pack URI
Given the package URI:
http://www.my.com/packages.aspx?my.package
And the part name:
/a/foo.xml
The pack URI is:
pack://http%3c,,www.my.com,packages.aspx%3fmy.package/a/foo.xml
end example]
In some scenarios, such as caching or writing parts to a package, it is necessary to determine if two pack URIs are equivalent without resolving them.
The package implementer shall consider pack URIs equivalent if:
[M7.3]