-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdiggs-validation.xsl
More file actions
134 lines (102 loc) · 6 KB
/
diggs-validation.xsl
File metadata and controls
134 lines (102 loc) · 6 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:map="http://www.w3.org/2005/xpath-functions/map"
xmlns:diggs="http://diggsml.org/schema-dev"
xmlns:gml="http://www.opengis.net/gml/3.2"
exclude-result-prefixes="xs map diggs gml">
<!--
************ Master stylesheet for DIGGS semantic validation *************
* *
* DIGGS files should be schema valid before *
* running symantic validation *
* *
**************************************************************************
-->
<!-- Output method -->
<xsl:output method="xml" indent="yes"/>
<!-- Global variables -->
<xsl:variable name="whiteListFile" select="'./whiteList.xml'"/>
<xsl:variable name="whiteList" select="if (doc-available($whiteListFile)) then doc($whiteListFile) else ()"/>
<!-- Store the original XML document -->
<xsl:variable name="originalXml" select="/"/>
<!-- Convert the XML to a string -->
<xsl:variable name="originalXmlString">
<xsl:value-of select="serialize($originalXml)"/>
</xsl:variable>
<!-- Import function module first -->
<xsl:import href="modules/diggs-functions.xsl"/>
<!-- Import DIGGS structure check module -->
<xsl:import href="modules/diggs-check.xsl"/>
<!-- Import schema validation module -->
<xsl:import href="modules/schema-check.xsl"/>
<!-- Import codeType-validation module -->
<xsl:import href="modules/codeType-validation.xsl"/>
<!-- Import dictionary-validation module -->
<xsl:import href="modules/dictionary-validation.xsl"/>
<!-- Import schematron-validation module -->
<xsl:import href="modules/schematron-validation.xsl"/>
<!-- Import geometry-validation module -->
<xsl:import href="modules/geometry-validation.xsl"/>
<!-- Import CRS-validation module -->
<xsl:import href="modules/crs-validation.xsl"/>
<!-- Import coordinate-validation.xsl -->
<xsl:import href="modules/coordinate-validation.xsl"/>
<!-- Import other modules here once they are developed -->
<!-- Main template -->
<xsl:template match="/">
<validationReport>
<timestamp><xsl:value-of select="current-dateTime()"/></timestamp>
<fileName><xsl:value-of select="tokenize(document-uri(/), '/')[last()]"/></fileName>
<originalXml><xsl:value-of select="$originalXmlString"/></originalXml>
<!-- Run DIGGS structure check first -->
<xsl:variable name="diggsCheckResults">
<xsl:call-template name="diggsCheck"/>
</xsl:variable>
<!-- Include DIGGS structure check results in the report -->
<xsl:copy-of select="$diggsCheckResults"/>
<!-- Only proceed with other validations if DIGGS structure check allows continuation -->
<xsl:if test="$diggsCheckResults/messageSet/continuable = 'true'">
<!-- Run schema validation, passing the whitelist -->
<xsl:variable name="schemaCheckResults">
<xsl:call-template name="schemaCheck">
<xsl:with-param name="whiteList" select="$whiteList"/>
</xsl:call-template>
</xsl:variable>
<!-- Include schema validation results in the report -->
<xsl:copy-of select="$schemaCheckResults"/>
<!-- Only proceed with other validations if schema validation allows continuation -->
<xsl:if test="$schemaCheckResults/messageSet/continuable = 'true'">
<!-- Run codeType validation -->
<xsl:call-template name="codeTypeValidation">
<xsl:with-param name="sourceDocument" select="$originalXml"/>
</xsl:call-template>
<!-- Run dictionary validation, passing the whitelist -->
<xsl:call-template name="dictionaryValidation">
<xsl:with-param name="whiteList" select="$whiteList"/>
</xsl:call-template>
<!-- Run schematron validation, passing the whitelist ans xoriginalXML -->
<xsl:call-template name="schematronValidation">
<xsl:with-param name="whiteList" select="$whiteList"/>
<xsl:with-param name="sourceDocument" select="$originalXml"/>
</xsl:call-template>
<!-- Run geometry validaiton -->
<xsl:call-template name="geometryValidation">
<xsl:with-param name="sourceDocument" select="$originalXml"/>
</xsl:call-template>
<!-- Run CRS validation -->
<xsl:call-template name="crsValidation">
<xsl:with-param name="whiteList" select="$whiteList"/>
<xsl:with-param name="sourceDocument" select="$originalXml"/>
</xsl:call-template>
<!-- Run coordinate validation -->
<xsl:call-template name="coordinateValidation">
<xsl:with-param name="sourceDocument" select="$originalXml"/>
</xsl:call-template>
<!-- Other validation modules will be called here as they are developed -->
</xsl:if>
</xsl:if>
</validationReport>
</xsl:template>
</xsl:stylesheet>