From 2e865bc45455239b1a923a9073c856f04ad27a0c Mon Sep 17 00:00:00 2001
From: Rolf Niepraschk <Rolf.Niepraschk@ptb.de>
Date: Fri, 4 Mar 2022 10:21:27 +0100
Subject: [PATCH] "dcc:statements ..."

---
 templates/xml/core_data.xml  |  2 +-
 templates/xml/dcc.xml        |  3 +-
 templates/xml/statements.xml | 69 ++++++++++++++++++++++++++++++++++++
 3 files changed, 72 insertions(+), 2 deletions(-)
 create mode 100644 templates/xml/statements.xml

diff --git a/templates/xml/core_data.xml b/templates/xml/core_data.xml
index dbd155d..1789c05 100644
--- a/templates/xml/core_data.xml
+++ b/templates/xml/core_data.xml
@@ -28,7 +28,7 @@
         {% endfor -%}
       </dcc:identifications>
       {%- if x.receiptDate %}         
-      <dcc:receiptDate> <hugo
+      <dcc:receiptDate> 
         {{x.receiptDate}}
       </dcc:receiptDate>
       {% endif -%}
diff --git a/templates/xml/dcc.xml b/templates/xml/dcc.xml
index 8aec756..7e25798 100644
--- a/templates/xml/dcc.xml
+++ b/templates/xml/dcc.xml
@@ -4,7 +4,7 @@
     xsi:schemaLocation="https://ptb.de/dcc https://ptb.de/dcc/v3.0.0/dcc.xsd"
     xmlns:dcc="https://ptb.de/dcc"
     xmlns:si="https://ptb.de/si"
-    schemaVersion="3.0.0">   
+    schemaVersion="3.1.1">   
   <!--
   DCC - Digital Calibration Certificate
   Copyright (C) 2021 - Physikalisch-Technische Bundesanstalt
@@ -38,6 +38,7 @@
     {% include 'xml/calibration_item.xml' %}
     {% include 'xml/responsible_persons.xml' %}
     {% include 'xml/customer.xml' %}
+    {% include 'xml/statements.xml' %}
   </dcc:administrativeData>
   <dcc:measurementResults>
     <dcc:measurementResult>
diff --git a/templates/xml/statements.xml b/templates/xml/statements.xml
new file mode 100644
index 0000000..27caefd
--- /dev/null
+++ b/templates/xml/statements.xml
@@ -0,0 +1,69 @@
+{% set x = doc.administrativeData['statements'] %}
+{%- if x is defined %}
+                                          {#  TODO: weitere Einträge ergänzen #}
+<dcc:statements>
+  {%- for i in x['statement'] %}
+    <dcc:statement> 
+    {%- if i['convention'] is defined %} 
+    <dcc:convention>{{i.convention}}</dcc:convention>  
+    {% endif -%} 
+    {% if i['traceable'] is defined %}
+    <dcc:traceable>{{i.traceable|lower}}</dcc:traceable> 
+    {% endif -%} 
+    {%- if i['norm'] is defined %} 
+    <dcc:norm>{{i.norm}}</dcc:norm> 
+    {% endif -%}  
+    {%- if i['reference'] is defined %} 
+    <dcc:reference>{{i.reference}}</dcc:reference> 
+    {% endif -%} 
+    {%- if i['declaration'] is defined %}   
+    <dcc:declaration>
+      {%- for j in i['declaration'] %}
+        <dcc:content lang="{{j.lang}}">
+          <![CDATA[{%- for k in j.content %}{{k|safe}}{% endfor -%}]]>
+        </dcc:content>
+      {% endfor -%}
+    </dcc:declaration>
+    {% endif -%}   
+    {% if i['valid'] is defined %}
+    <dcc:valid>{{i.valid|lower}}</dcc:valid> 
+    {% endif -%}
+    {%- if i['date'] is defined %} 
+    <dcc:date>{{i.date}}</dcc:date> 
+    {% endif -%}  
+    {% if i['respAuthority'] is defined %}
+    <dcc:respAuthority>               {#  TODO: auch bei customer übernehmen. #}
+      {% set x1 = i['respAuthority'] %}
+      {%- if x1['name'] is defined %}
+      <dcc:name>   
+        {%- for j in x1['name'] %}
+        <dcc:content lang="{{j.lang}}">
+          <![CDATA[{%- for k in j.content %}{{k|safe}}{% endfor -%}]]>
+        </dcc:content>
+        {% endfor -%}
+      </dcc:name>
+      {% endif -%}
+      {% if x1['eMail'] is defined %}
+      <dcc:eMail>{{x1.eMail}}</dcc:eMail>
+      {% endif -%}
+      <dcc:location>
+        <dcc:street>{{x1.location.street}}</dcc:street>
+        {%- if x1.location.streetNo is defined %}
+        <dcc:streetNo>{{x1.location.streetNo}}</dcc:streetNo>
+        {% endif -%}
+        {%- if x1.location.postCode is defined %}
+        <dcc:postCode>{{x1.location.postCode}}</dcc:postCode>
+        {% endif -%}
+        {%- if x1.location.city is defined %}
+        <dcc:city>{{x1.location.city}}</dcc:city>
+        {% endif -%}
+        {%- if x1.location.countryCode is defined %}
+        <dcc:countryCode>{{x1.location.countryCode}}</dcc:countryCode>
+        {% endif -%}
+      </dcc:location>
+    </dcc:respAuthority>    
+    {% endif -%}
+    </dcc:statement>
+  {% endfor -%}
+</dcc:statements>
+{% endif -%}
-- 
GitLab