-
Notifications
You must be signed in to change notification settings - Fork 4
/
xsdval.xpl
executable file
·81 lines (69 loc) · 2.33 KB
/
xsdval.xpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?xml version="1.0" encoding="utf-8"?>
<p:declare-step xmlns:p="http:https://www.w3.org/ns/xproc"
xmlns:c="http:https://www.w3.org/ns/xproc-step"
xmlns:xsl="http:https://www.w3.org/1999/XSL/Transform"
xmlns:svrl="http:https://purl.oclc.org/dsdl/svrl"
xmlns:tr="http:https://transpect.io"
xmlns:cx="http:https://xmlcalabash.com/ns/extensions"
version="1.0"
name="xsdval"
type="tr:validate-with-xsd">
<p:input port="source" primary="true" />
<p:input port="schema" sequence="true"/>
<p:output port="report" primary="true">
<p:pipe step="validate" port="report" />
</p:output>
<p:serialization port="report" indent="true"/>
<p:option name="use-location-hints" select="'true'">
<p:documentation>Apparently does not work with Calabash 1.1.5 (“Array index out of range: 0”)</p:documentation>
</p:option>
<p:option name="fail-on-error" select="'true'">
<p:documentation>Whether to throw an error when validation fails.</p:documentation>
</p:option>
<p:variable name="var-file-uri" select="base-uri()"/>
<p:try name="validate">
<p:group>
<p:output port="report" primary="true"/>
<p:validate-with-xml-schema>
<!-- <p:with-option name="use-location-hints" select="$use-location-hints"/>-->
<p:input port="source">
<p:pipe step="xsdval" port="source"/>
</p:input>
<p:input port="schema">
<p:pipe step="xsdval" port="schema"/>
</p:input>
</p:validate-with-xml-schema>
<p:sink/>
<p:identity name="ok">
<p:input port="source">
<p:inline>
<c:report>ok</c:report>
</p:inline>
</p:input>
</p:identity>
</p:group>
<p:catch name="catch1">
<p:output port="report" primary="true">
<p:pipe step="fwd-errors" port="result"/>
</p:output>
<p:identity name="fwd-errors">
<p:input port="source">
<p:pipe step="catch1" port="error"/>
</p:input>
</p:identity>
<p:choose>
<p:when test="$fail-on-error = 'true'">
<p:error code="tr:XSD1">
<p:input port="source">
<p:pipe step="catch1" port="error"/>
</p:input>
</p:error>
</p:when>
<p:otherwise>
<p:identity/>
</p:otherwise>
</p:choose>
<p:sink/>
</p:catch>
</p:try>
</p:declare-step>