7. Resource Descriptions Selection(RDの選択)
The Resource Description Document provides lists of Resource descriptions grouped together. Once the document has been obtained, the Consumer typically performs Resource descriptions selection, to extract the descriptions of the Resources relevant to it. The selection process centers around iterating through the list of Resource descriptions, filtering them based on their type and media-type, and selecting them based on their relative priorities.
The Resource descriptions selection process includes two steps:
- Identify the XRD element describing the desired Resource or group of Resources.
- Select the Service elements matching against the Consumer’s desired criteria.
7.1. XRD Identification(<XRD/>識別方法)
Identifying an XRD element within an XRDS-Simple document is done by following the identification rules:
- The Consumer MUST find all the XRDS-Simple compliant XRD elements as defined in Section 6.1 (Declarations and Requirements), excluding any expired elements as defined by the Expired child element (XRD Element). Any other elements SHALL be ignored in the steps that follow. The Consumer MAY choose to filter the list of XRD elements further by looking for additional Type elements matches at the XRD level.
- If the document’s location includes a URI fragment as defined in Section 5.2 (Requesting Document), the Consumer MUST look for an XRD element with an xml:id attribute value matching the XRD identifier indicated by the URI fragment. If a match is found, the XRD element is used as defined in Section 7.2 (Service Selection), otherwise the discovery process ends unsuccessfully.
- If the document contains a single XRD element, it is used as defined in Section 7.2 (Service Selection).
- If the document contains multiple XRD elements, the last element is used as defined in Section 7.2 (Service Selection).
7.2. Service Selection(<Service/>の選択)
Based on the Consumer’s needs, the Consumer defines a selection criteria based on the presence (or lack of) certain Resource types and media-types. The selection criteria can be any combination of type and media-type values desired by the Consumer, as well as looking for specific Endpoint URIs. For example, a Consumer can look for all Resource descriptions with an image media-type, an Endpoint with OpenID authentication type, or the description of a specific Resource given its Endpoint URI.
If the selection criteria places higher preference on the presence of certain types or media-types over others, it is handled by performing multiple selections. Each selection is assigned preference order based on the Consumer needs and the selection results are compared to determine the most desired set. For example, if a Consumer is looking for all image Resources, giving higher preference to the JPEG formats over PNG, it will perform two selection processes, one for each media-type, and assign the Resources in the JPEG set a higher preference value.
Once an XRD element has been identified, the Consumer performs the following steps in order to select the desired Resource descriptions:
- Each Service element is compared against the selection criteria by comparing the values of the Type, MediaType, and URI elements to those defined by the selection criteria.
- The Consumer SHOULD inspect the matching Service elements for simple:MustSupport elements, and remove from the list any Service elements with unknown simple:MustSupport values.
- If more than one Service element is matched, the Consumer MUST use the priority attribute values to find the highest priority element as defined in Section 6.4 (priority Attribute).
- Within the priority sorted list of matching Service elements, if more than one URI or LocalID elements are present, the Consumer MUST use the priority attribute values of each element type to find the highest priority element as defined in Section 6.4 (priority Attribute).
At the conclusion of the selection process, if any of the Resource descriptions matched the selection criteria, the Consumer will obtain a list of Resource descriptions, sorted by their matching preference and priorities.