SRU
Extra Data / Extensions
List of Registered Extensions
Messages in all of the operations, both in the request and in the response,
have a field in which additional information may be provided. This is
a built in extension mechanism where profiles may specify a schema for
what to include in this section without requiring the developers to change
the basic messages and thus render their implementation uninteroperable
with other servers and clients. It is expected that if there is sufficient
demand for a particular piece of additional information, that piece of
information will be migrated into the protocol in a later version. In
this way, only implemented and useful features will be added in future
versions, rather than features which just seem like a good idea.
Rules and Semantics
- If the server does not understand a piece of information in an
extraRequestData field, it may silently ignore it.
This is unlike many other request parameters, where if the server does
not implement that particular feature it should respond with a diagnostic.
If the particular request requires some confirmation that it has been
carried out rather than ignored, then the profile designer should include
a field in the extraResponseData.
- The semantics of parameters in the request MAY NOT be modified
by extraRequestData.
For example, a x-qt-queryType parameter could not change query
to be an SQL query, as a server that does not understand the x-qt-queryType
extension would expect the query to be in CQL, and thus be unable to
parse it. Instead, the extraData should create a new element for the
information.
- The semantics of parts of the response MAY be modified by
extensions.
The response semantics may be changed in this way only if the client
specifically requests the change. Clients should also expect to receive
the regular semantics, as servers are at liberty to ignore extraRequestData
fields.
- ExtraResponseData may be sent that is not connected to the search
in the request.
For example it may contain cost information regarding the query
or information on the server or database supplying the results. (This
data must, however, have been requested. See next rule.)
- ExtraResponseData MAY NOT be sent unless explicitly requested in
the request.
SRU Parameter
Request
For SRU the name for an extra-data parameter must begin with 'x-'
-- lower case x followed by hyphen. (The SRU protocol will never include
an official parameter with a name beginning with 'x-'.) It is suggested,
but not required, that the parameter name be 'x-' followed by an identifier
for the extension (again followed by hyphen), followed by the name of
the element within the XML namespace associated with the extension. For
example 'x-info-4-onSearchFail' for <theo:onSearchFail>.
http://lx2.loc.gov:210/LCDB?...&x-info4-onSearchFail=scan
(In this
example 'info-4' identifies the namespace; see next paragraph.). Note
that this convention does not guarantee uniqueness since (in contrast
to SRW - see SRW Parameter below.) the parameter name
will not include a URI. The extension owner should try to make the name
as unique as possible.
If the namespace is identified by an 'info:srw'
URI (and note that there is no such requirement, the namespace may
be identified by a URI of a different scheme, for example 'http'), then
a convention that may be used (as in the example above) is to name the
parameter "x-info-<nnn>-<element name>" where <nnn>
is the 'srw:info' authority
string. This convention (suggested but not required) should guarantee
uniqueness. It is strongly suggested that an extension name never be assigned
with this form except by the proper authority for the given 'info' namespace.
Response
Every response has an extraResponseData section.
This section can include any well-formed XML, and hence servers can include
namespaced XML fragments within it in order to convey information back to
the client. The extension MUST supply a namespace and the element names
with which to do this, if feedback to the client is necessary. For example:
<sru:extraResponseData>
<auth:token xmlns:auth="info:srw/extension/2/auth-1.0">
277c6d19-3e5d-4f2d-9659-86a77fb2b7c8
</auth:token>
</sru:extraResponseData>
As the request may be echoed in SRU, the server must be able to transform
the parameters into their XML form. If it encounters an unrecognised parameter,
the server may either make its best guess as to how to transform the parameter,
or simply not return it at all. It should not, however, add an undefined
namespace to the element as this would invalidate the response.
If the contents of the parameter is an XML structure, then the profile
designer should also specify how to encode this structure for SRU. This
may simply be to escape all of the special characters, but the designer
could also create a string encoding form with rules as to how to generate
the XML in much the same fashion as the relationship between CQL and XCQL.
SRW Parameter
For SRW, The extra data fields is an XML structure. Even if there is
only one piece of additional information supplied, it must be within a
namespaced XML element. This is in order to ensure that servers can distinguish
a field from one profile from another. Examples:
<extraRequestData>
< theo:onSearchFail xmlns:theo="info:srw/extension/4/searchextensions">
scan
< /theo:onSearchFail>
</extraRequestData>
<extraResponseData>
<rob:relevancyAlgorithm xmlns:rob="info:srw/extension/2/relevancy">CORI
< /rob:relevancyAlgorithm>
< /extraResponseData>
Extra data fields are identified by the root XML element qualified by
the supplied namespace. In the above examples, for the extra request data
the extension's identifier is 'onSearchFail' from namespace info:srw/extension/4/searchExtensions.
The extra response data has identifier 'relevancyAlgorithm' from namespace
info:srw/extension/2/relevancy. Below there is another example, where
the extension's identifier is 'rank', also from the latter namespace.
Extra Data Example
For an example of how to create an extension, see the Record
Schema Negotiation Extension whose purpose is to allow the client
to propose multiple record schemas that it will accept in response and
let the server select one, rather than the client giving the server an
ultimatum as to which record schema to return. This extension modifies
the base semantics of the protocol, as the record schema URI in the response
might not be the one in the recordSchema parameter of the request.
Record, Term and Query Extensions
In addition to extra information
being included at the top level of the response, there are three further elements
in which information can be returned.
These are:
- extraRecordData: Extra information relating to the record
in the searchRetrieve responses. For example, extraRecordData
might include a field with the relevance associated with the record in
a relevance ranked search.
- extraTermData: Extra information relating to the term
in the scan response.
- extraOperandData: Extra information relation to the query
clause echoed back to the client in XCQL.
extraRecordData example (highlighted in orange):
<record> <recordSchema>info:srw/schema/1/dc-v1.1</recordSchema>
<recordPacking>xml</recordPacking>
<recordData>
<srw_dc:dc>
<dc:title>Thisis
a Sample Record</dc:title>
</srw_dc:dc>
</recordData>
<recordPosition>1</recordPosition>
<extraRecordData>
<rel:rank xmlns:rel="xmlns:rob="info:srw/extension/2/relevancy">0.965</rel:rank>
</extraRecordData>
</record>
extraTermData
And in addition "extra data" can occur within the term element
for any term in a scanResponse message containing profiled information
about the term. This data can include (but is not limited to) metadata
about the term. For example, extraTermData might include a link
to the term within a thesaurus.
|