|
7 | 7 | xmlns:dts="https://distributed-text-services.github.io/specifications/" |
8 | 8 | exclude-result-prefixes="#all" xpath-default-namespace="http://www.tei-c.org/ns/1.0" version="3.0"> |
9 | 9 |
|
10 | | - <xsl:param name="resource" as="xs:string?" select="()"/> |
11 | | - |
12 | 10 | <xsl:param name="ref" as="xs:string?" select="()"/> |
13 | 11 |
|
14 | 12 | <xsl:param name="start" as="xs:string?" select="()"/> |
|
22 | 20 | contained in the constructed subtree of the parent member. --> |
23 | 21 | <xsl:param name="marked-virtual-children" as="xs:boolean" select="false()"/> |
24 | 22 |
|
25 | | - <!-- turn this to false() to make processing DTS endpoint conformant --> |
26 | | - <xsl:param name="absent-resource-from-baseuri" as="xs:boolean" static="true" select="true()"/> |
| 23 | + <xsl:use-package name="https://scdh.github.io/dts-transformations/xsl/resource.xsl" |
| 24 | + package-version="1.0.0"> |
| 25 | + <xsl:accept component="variable" names="resource" visibility="public"/> |
| 26 | + <xsl:accept component="function" names="dts:validate-resource-parameter#1" visibility="public"/> |
| 27 | + </xsl:use-package> |
27 | 28 |
|
28 | 29 | <xsl:use-package name="https://scdh.github.io/dts-transformations/xsl/errors.xsl" |
29 | 30 | package-version="1.0.0"/> |
|
33 | 34 |
|
34 | 35 | <xsl:function name="dts:validate-parameters" as="map(xs:string, item())" visibility="final"> |
35 | 36 | <xsl:param name="context" as="node()"/> |
36 | | - <xsl:map> |
37 | | - <xsl:choose> |
38 | | - <xsl:when test="not(empty($resource))"> |
39 | | - <xsl:map-entry key="'resource'" select="$resource"/> |
40 | | - </xsl:when> |
41 | | - <xsl:when test="$absent-resource-from-baseuri"> |
42 | | - <xsl:map-entry key="'resource'" select="base-uri($context)"/> |
43 | | - </xsl:when> |
44 | | - <xsl:otherwise> |
45 | | - <xsl:message terminate="yes" error-code="{$dts:http400 => dts:error-to-eqname()}"> |
46 | | - <xsl:value-of xml:space="preserve">ERROR: resource parameter missing</xsl:value-of> |
47 | | - </xsl:message> |
48 | | - </xsl:otherwise> |
49 | | - </xsl:choose> |
50 | | - <xsl:choose> |
51 | | - <xsl:when test="$ref and ($start or $end)"> |
52 | | - <xsl:message terminate="yes" error-code="{$dts:http400 => dts:error-to-eqname()}"> |
53 | | - <xsl:value-of xml:space="preserve">ERROR: bad parameter combination: when ref is used, start and end must not</xsl:value-of> |
54 | | - </xsl:message> |
55 | | - </xsl:when> |
56 | | - <xsl:when test="$ref"> |
57 | | - <xsl:map-entry key="'ref'" select="$ref"/> |
58 | | - </xsl:when> |
59 | | - <xsl:when test="$start and $end"> |
60 | | - <xsl:map-entry key="'start'" select="$start"/> |
61 | | - <xsl:map-entry key="'end'" select="$end"/> |
62 | | - </xsl:when> |
63 | | - <xsl:when test="not($start or $end)"/> |
64 | | - <xsl:otherwise> |
65 | | - <xsl:message terminate="yes" error-code="{$dts:http400 => dts:error-to-eqname()}"> |
66 | | - <xsl:value-of xml:space="preserve">ERROR: bad parameter combination: start required end and vice versa</xsl:value-of> |
67 | | - </xsl:message> |
68 | | - </xsl:otherwise> |
69 | | - </xsl:choose> |
70 | | - <xsl:if test="$tree"> |
71 | | - <xsl:map-entry key="'tree'" select="$tree"/> |
72 | | - </xsl:if> |
73 | | - </xsl:map> |
| 37 | + <xsl:variable name="parms" as="map(xs:string, item())"> |
| 38 | + <xsl:map> |
| 39 | + <xsl:choose> |
| 40 | + <xsl:when test="$ref and ($start or $end)"> |
| 41 | + <xsl:message terminate="yes" error-code="{$dts:http400 => dts:error-to-eqname()}"> |
| 42 | + <xsl:value-of xml:space="preserve">ERROR: bad parameter combination: when ref is used, start and end must not</xsl:value-of> |
| 43 | + </xsl:message> |
| 44 | + </xsl:when> |
| 45 | + <xsl:when test="$ref"> |
| 46 | + <xsl:map-entry key="'ref'" select="$ref"/> |
| 47 | + </xsl:when> |
| 48 | + <xsl:when test="$start and $end"> |
| 49 | + <xsl:map-entry key="'start'" select="$start"/> |
| 50 | + <xsl:map-entry key="'end'" select="$end"/> |
| 51 | + </xsl:when> |
| 52 | + <xsl:when test="not($start or $end)"/> |
| 53 | + <xsl:otherwise> |
| 54 | + <xsl:message terminate="yes" error-code="{$dts:http400 => dts:error-to-eqname()}"> |
| 55 | + <xsl:value-of xml:space="preserve">ERROR: bad parameter combination: start required end and vice versa</xsl:value-of> |
| 56 | + </xsl:message> |
| 57 | + </xsl:otherwise> |
| 58 | + </xsl:choose> |
| 59 | + <xsl:if test="$tree"> |
| 60 | + <xsl:map-entry key="'tree'" select="$tree"/> |
| 61 | + </xsl:if> |
| 62 | + </xsl:map> |
| 63 | + </xsl:variable> |
| 64 | + <xsl:sequence select="map:merge(($parms, dts:validate-resource-parameter($context)))"/> |
74 | 65 | </xsl:function> |
75 | 66 |
|
76 | 67 |
|
|
0 commit comments