SeisComP3 / seiscomp3

SeisComP is a seismological software for data acquisition, processing, distribution and interactive analysis.
Other
111 stars 88 forks source link

Use custom namespace to keep non-QuakeML nodes #209

Closed Brtle closed 5 years ago

Brtle commented 5 years ago

In the QuakeML format, there is the possibility to create custom nodes. This PR modify the XSLT stylesheets to put the seiscomp nodes that are not mapped in QuakeML in these custom fields. This allows some round-trip conversion without loss of data. For instance, the pdf node doesn't exist in QuakeML:

<?xml version="1.0" encoding="UTF-8"?>
<seiscomp xmlns="http://geofon.gfz-potsdam.de/ns/seiscomp3-schema/0.11" version="0.11">
  <EventParameters publicID="smi:test/EventParameters">
    <origin publicID="smi:test/origin">
      <time>
        <value>2018-12-12T00:00:00.000000Z</value>
        <pdf>
          <variable>2018-12-12T00:00:00 2018-12-12T00:00:00 2018-12-12T00:00:00</variable>
          <probability>0.4 1.1 1.3</probability>
        </pdf>
      </time>
      <latitude>
        <value>20</value>
      </latitude>
      <longitude>
        <value>100</value>
      </longitude>
    </origin>
    <event publicID="smi:test/event">
      <originReference>smi:test/origin</originReference>
    </event>
  </EventParameters>
</seiscomp>

The XSLT conversion puts this pdf node in a custom tags.

<?xml version="1.0" encoding="UTF-8"?>
<q:quakeml xmlns:q="http://quakeml.org/xmlns/quakeml/1.2" xmlns="http://quakeml.org/xmlns/bed/1.2">
  <eventParameters publicID="smi:test/EventParameters">
    <event publicID="smi:test/event">
      <origin publicID="smi:test/origin">
        <time>
          <value>2018-12-12T00:00:00.000000Z</value>
          <scs:pdf xmlns:scs="http://geofon.gfz-potsdam.de/ns/seiscomp3-schema/0.11">
            <scs:variable>2018-12-12T00:00:00 2018-12-12T00:00:00 2018-12-12T00:00:00</scs:variable>
            <scs:probability>0.4 1.1 1.3</scs:probability>
          </scs:pdf>
        </time>
        <latitude>
          <value>20</value>
        </latitude>
        <longitude>
          <value>100</value>
        </longitude>
      </origin>
    </event>
  </eventParameters>
</q:quakeml>

This QuakeML file contains the pdf node in a custom namespace and is still valid. Moreover, the reverse conversion (using this stylesheet) generates exactly the same sc3ml file.

The custom namespace can also be defined in the header:

@@ -183,7 +183,7 @@
         xmlns:qml="http://quakeml.org/xmlns/quakeml/1.0"
         xmlns="http://quakeml.org/xmlns/bed/1.2"
         xmlns:q="http://quakeml.org/xmlns/quakeml/1.2"
-        exclude-result-prefixes="scs qml xsl">
+        exclude-result-prefixes="qml xsl">
     <xsl:output method="xml" encoding="UTF-8" indent="yes"/>
     <xsl:strip-space elements="*"/>

The generated file looks like:

<?xml version="1.0" encoding="UTF-8"?>
<q:quakeml xmlns:q="http://quakeml.org/xmlns/quakeml/1.2" xmlns:scs="http://geofon.gfz-potsdam.de/ns/seiscomp3-schema/0.11" xmlns="http://quakeml.org/xmlns/bed/1.2">
  <eventParameters publicID="smi:test/EventParameters">
    <event publicID="smi:test/event">
      <origin publicID="smi:test/origin">
        <time>
          <value>2018-12-12T00:00:00.000000Z</value>
          <scs:pdf>
            <scs:variable>2018-12-12T00:00:00 2018-12-12T00:00:00 2018-12-12T00:00:00</scs:variable>
            <scs:probability>0.4 1.1 1.3</scs:probability>
          </scs:pdf>
        </time>
        <latitude>
          <value>20</value>
        </latitude>
        <longitude>
          <value>100</value>
        </longitude>
      </origin>
    </event>
  </eventParameters>
</q:quakeml>

But it will always be there even if there are no custom tags in the file. I don't know if it's better or not.

Let me know what you think about this!

gempa-stephan commented 5 years ago

Thanks for your contribution and sorry for the long delay.

We prefer excluding the scs prefix (exclude-result-prefixes="scs qml xsl").

Could you please rebase your merge request against the current master.

Brtle commented 5 years ago

Thanks for your contribution and sorry for the long delay.

Thanks for looking into it!

We prefer excluding the scs prefix (exclude-result-prefixes="scs qml xsl").

Could you please rebase your merge request against the current master.

Done.

gempa-stephan commented 5 years ago

I successfully tested round trip conversion using the 0.11 schema. Thanks for your contribution!