From 7caeedc5667076b5bdf0ba3d46b61e8d26eb7b30 Mon Sep 17 00:00:00 2001 From: Timofey Arkhangelskiy <timofey.arkhangelskiy@uni-hamburg.de> Date: Wed, 7 Dec 2022 22:06:15 +0100 Subject: [PATCH] Extend explain response templates --- notes.txt | 4 ++++ static/endpoint_description.xml | 26 ++++++++++++++++---------- static/explain_response_1.2.xml | 1 + 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/notes.txt b/notes.txt index 26bb1de..1c86462 100644 --- a/notes.txt +++ b/notes.txt @@ -1,3 +1,7 @@ +p. 3: "The value of the @version attribute MUST be 2." But SRU 1.2 EndpointDescription will have version="1", per example on p. 12. (By the way, some examples are numbered and some are not.) + +p. 4: Link 'section "Layers"' leads to a CLARIN-internal Trac instance. + p. 10: "Send explain request without version and operation parameter" -- but an explain request has to have the operation parameter with 'explain' as its value p. 14: x-cmd-resource-info parameter present in the query example, but never explained (mentioned in some 2013 slides on FCS; should now probably be x-fcs-endpoint-description) diff --git a/static/endpoint_description.xml b/static/endpoint_description.xml index d68eaa5..2aac1cb 100644 --- a/static/endpoint_description.xml +++ b/static/endpoint_description.xml @@ -1,20 +1,26 @@ <sru:extraResponseData> - <ed:EndpointDescription xmlns:ed="http://clarin.eu/fcs/endpoint-description" version="1"> - <ed:Capabilities> - <ed:Capability>http://clarin.eu/fcs/capability/basic-search</ed:Capability> + <ed:EndpointDescription xmlns:ed="http://clarin.eu/fcs/endpoint-description" version="{{ ep_version }}"> + <ed:Capabilities>{% if capability_basic_search %} + <ed:Capability>http://clarin.eu/fcs/capability/basic-search</ed:Capability>{% endif %}{% if capability_advanced_search and ep_version >= 2 %} + <ed:Capability>http://clarin.eu/fcs/capability/advanced-search</ed:Capability>{% endif %} </ed:Capabilities> - <ed:SupportedDataViews> - <ed:SupportedDataView id="hits" delivery-policy="send-by-default">application/x-clarin-fcs-hits+xml</ed:SupportedDataView> - </ed:SupportedDataViews> + <ed:SupportedDataViews>{% if hits_supported %} + <ed:SupportedDataView id="hits" delivery-policy="send-by-default">application/x-clarin-fcs-hits+xml</ed:SupportedDataView>{% endif %}{% if adv_supported and ep_version >= 2%} + <ed:SupportedDataView id="adv" delivery-policy="send-by-default">application/x-clarin-fcs-adv+xml</ed:SupportedDataView>{% endif %} + </ed:SupportedDataViews>{% if capability_advanced_search and ep_version >= 2 %} + <ed:SupportedLayers>{% for layer in supported_layers %} + <ed:SupportedLayer id="{{ layer.id }}" result-id="{{ layer.result_id }}"{% if layer.alt_value_info %} alt-value-info="{{ layer.alt_value_info }}"{% endif %}{% if layer.alt_value_info_uri %} alt-value-info-uri="{{ layer.alt_value_info_uri }}"{% endif %}{% if layer.qualifier %} qualifier="{{ layer.qualifier }}"{% endif %}>{{ layer.layer_type }}</ed:SupportedLayer>{% endfor %} + </ed:SupportedLayers> + {% endif %} <ed:Resources>{% for r in resources %} <ed:Resource pid="{{ r.pid }}">{% for title in r.titles %} <ed:Title xml:lang="{{ title.lang }}">{{ title.content }}</ed:Title>{% endfor %}{% for desc in r.descriptions %} - <ed:Description xml:lang="{{ desc.lang }}">{{ desc.content }}</ed:Description> - <ed:LandingPageURI>{{ r.landing_page }}</ed:LandingPageURI>{% if r.languages|length > 0 %} + <ed:Description xml:lang="{{ desc.lang }}">{{ desc.content }}</ed:Description>{% if landing_page|length > 0%} + <ed:LandingPageURI>{{ r.landing_page }}</ed:LandingPageURI>{% endif %} <ed:Languages>{% for lang in r.languages %} <ed:Language>{{ lang }}</ed:Language>{% endfor %} - </ed:Languages>{% endif %} - <ed:AvailableDataViews ref="hits"/> + </ed:Languages> + <ed:AvailableDataViews ref="{{ r.data_views }}"/> </ed:Resource>{% endfor %} </ed:Resources> </ed:EndpointDescription> diff --git a/static/explain_response_1.2.xml b/static/explain_response_1.2.xml index 1cedcb7..0b80d08 100644 --- a/static/explain_response_1.2.xml +++ b/static/explain_response_1.2.xml @@ -1,3 +1,4 @@ +{% set ep_version = 1 %} <?xml version='1.0' encoding='utf-8'?> <sru:explainResponse xmlns:sru="http://www.loc.gov/zing/srw/"> <sru:version>1.2</sru:version> -- GitLab