File size: 1,992 Bytes
64940d7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Jinja template."""


SHEX_JINJA = """
{%- for prefix, uri in namespaces.items() %}
PREFIX {{prefix}} <{{uri}}>
{%- endfor %}

{%- for shape in shapes %}
{{shape.shapeID}}{{" "}}
  {%- if shape.closed == 'True' -%} 
    {{"CLOSED"}} 
  {%- elif shape.extra is defined -%}
    {{"EXTRA "}}{{shape.extra}}
  {%- endif -%}
    {{" {"}}
  {%- for statement in shape.statement_templates %}
    {{statement.propertyID}}
    {%- if statement._dot %} {{" . "}} {% endif -%}
    {%- if statement.valueNodeType %} {{statement.valueNodeType|upper}}{% endif -%}
    {%- if statement.valueDataType %} {{statement.valueDataType}}{% endif -%}
    {%- if statement.valueShape %} @{{statement.valueShape}}{% endif -%}
    {%- if statement.valueConstraint is defined -%} 
          {%- if not statement.valueConstraintType is defined -%}
              {{" "}}[{{ statement.valueConstraint }}]
          {%- elif statement.valueConstraintType == 'picklist_quoted' -%}
              {{" "}}[{{ statement.valueConstraint | map('tojson') | join(" ") }}]
          {%- elif statement.valueConstraintType == "picklist" -%}
              {{" "}}[{{ statement.valueConstraint | join(" ") }}]
          {%- endif -%}
    {%- endif -%}
    {%- if statement.minoccurs is defined %} { {{- statement.minoccurs -}}
          {%- if statement.maxoccurs is not defined -%}
              ,}
      	{%- elif statement.maxoccurs|int == -1 -%}
              ,}
      	{%- else -%}
      	 ,{{statement.maxoccurs}}}
      	{%- endif -%} 
    {%- endif -%}
    {%- if statement.mininclusive %} MinInclusive {{statement.mininclusive}} {%- endif -%}
    {%- if statement.maxinclusive %} MaxInclusive {{statement.maxinclusive}} {%- endif -%}
    {%- if not loop.last -%} ;{%- endif -%}
  {%- endfor %}
}
{%- endfor %}
"""
#            {%- elif statement.valueDataType == 'xsd:integer' or statement.valueDataType == "http://www.w3.org/2001/XMLSchema#integer " -%}
#                {{" "}}[{{ statement.valueConstraint | join(" ") }}]