Unidata / threddsIso

A THREDDS Data Server extension which generates NCML, a metadata rubric, and ISO 19115.
7 stars 17 forks source link

strip white space from keywords #22

Closed pacioos closed 7 years ago

pacioos commented 8 years ago

If the NetCDF global attribute "keywords" is a comma-separated list and there are spaces between entries (e.g. "temperature, salinity"), this small update adds "normalize-space( )" to prevent such space from appearing before the tokenized topic categories in the resulting ISO XML document (e.g. " temperature" will become "temperature").

For example, if your NetCDF global attributes look like this:

          <attribute name="keywords" value="Earth Science Services &gt; Models &gt; Ocean General Circulation Models (OGCM)/Regional Ocean Models, Earth Science Services &gt; Models &gt; Weather Research/Forecast Models, Earth Science &gt; Oceans &gt; Ocean Temperature &gt; Potential Temperature, Earth Science &gt; Oceans &gt; Salinity/Density &gt; Salinity, Earth Science &gt; Oceans &gt; Sea Surface Topography &gt; Sea Surface Height, Earth Science &gt; Oceans &gt; Ocean Circulation &gt; Ocean Currents"/>
          <attribute name="keywords_vocabulary" value="GCMD Science Keywords"/>

This update avoids having this kind of ISO XML output:

         <theme>
            <themekt>GCMD Science Keywords</themekt>
            <themekey>Earth Science Services &gt; Models &gt; Ocean General Circulation Models (OGCM)/Regional Ocean Models</themekey>
            <themekey> Earth Science Services &gt; Models &gt; Weather Research/Forecast Models</themekey>
            <themekey> Earth Science &gt; Oceans &gt; Ocean Temperature &gt; Potential Temperature</themekey>
            <themekey> Earth Science &gt; Oceans &gt; Salinity/Density &gt; Salinity</themekey>
            <themekey> Earth Science &gt; Oceans &gt; Sea Surface Topography &gt; Sea Surface Height</themekey>
            <themekey> Earth Science &gt; Oceans &gt; Ocean Circulation &gt; Ocean Currents</themekey>
         </theme>

and will instead result in this output (with leading spaces before "Earth Science" stripped out):

         <theme>
            <themekt>GCMD Science Keywords</themekt>
            <themekey>Earth Science Services &gt; Models &gt; Ocean General Circulation Models (OGCM)/Regional Ocean Models</themekey>
            <themekey>Earth Science Services &gt; Models &gt; Weather Research/Forecast Models</themekey>
            <themekey>Earth Science &gt; Oceans &gt; Ocean Temperature &gt; Potential Temperature</themekey>
            <themekey>Earth Science &gt; Oceans &gt; Salinity/Density &gt; Salinity</themekey>
            <themekey>Earth Science &gt; Oceans &gt; Sea Surface Topography &gt; Sea Surface Height</themekey>
            <themekey>Earth Science &gt; Oceans &gt; Ocean Circulation &gt; Ocean Currents</themekey>
         </theme>
amilan17 commented 8 years ago

Looks like this will be a great little change!