Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

export as csv not working as expected #13

Open
sylar11 opened this issue Nov 15, 2019 · 3 comments
Open

export as csv not working as expected #13

sylar11 opened this issue Nov 15, 2019 · 3 comments

Comments

@sylar11
Copy link
Contributor

sylar11 commented Nov 15, 2019

I would like to customize the export as csv function in Geonetwork 3.8.1.
The documentation I found here seems to be old.

[https://geonetwork-opensource.org/manuals/3.8.x/en/user-guide/export/index.html]

I think that the file to edit is the tpl-csv.xsl which, in my case, is located here

geonetwork/WEB-INF/data/config/schema_plugins/iso19115-3.2018/layout/tpl-csv.xsl

The output I would like to have is the following one:

"title","cloud coverage","category","date-creation" "S2A_MSIL1C_20151127T103352_N0204_R108_T32TLS_20151127T103440","36.6172","dataset","2015-11-27T10:34:40"

I did some test but I'm only able to have

"schema","uuid","id","cit:title","gco:Real","category","date-creation" "iso19115-3.2018","89d82f0a-051e-11ea-80ac-02000a08f492","1155","S2A_MSIL1C_20151127T103352_N0204_R108_T32TLS_20151127T103440","36.6172","dataset","2015-11-27T10:34:40",

How can I edit in a more correct way the tpl-csv.xsl?

@sylar11
Copy link
Contributor Author

sylar11 commented Nov 22, 2019

I found the solution to customize the output of the EXPORT(CSV) function.

These are the two files to consider:

  1. geonetwork/WEB-INF/data/config/schema_plugins/iso19115-3.2018/layout/tpl-csv.xsl
  2. geonetwork/xslt/services/csv/csv-search.xsl

In the first one, as suggested to me by @josegar74, you have to add a similar line in between the abstract and category elements:
<myfield>myfieldvalue</myfield>
In my case I inserted:

<title><xsl:copy-of select="mdb:identificationInfo/*/mri:citation/*/cit:title"/></title>
<cloud_coverage_percentage><xsl:copy-of select="mdb:contentInfo/mrc:MD_ImageDescription/mrc:cloudCoverPercentage/gco:Real"/></cloud_coverage_percentage>

About cloud coverage percentage in particular, please remember to add the namespace in the header because it is missing:
xmlns:mrc="http://standards.iso.org/iso/19115/-3/mrc/2.0"

Then aI commented all the other lines I'm not interested in but:
<xsl:copy-of select="gn:info"/>

About the second file, csv-search.xsl, I found that to avoid printing automatically the 3 columns:
"schema","uuid","id",
you have to comment the following lines:

<xsl:text>"schema"</xsl:text>
<xsl:value-of select="$sep"/>
<xsl:text>"uuid"</xsl:text>
<xsl:value-of select="$sep"/>
<xsl:text>"id"</xsl:text><xsl:value-of select="$sep"/>

and

<xsl:value-of select="concat('&quot;', $metadata/geonet:info/schema, '&quot;', $sep,
                  '&quot;', $metadata/geonet:info/uuid, '&quot;', $sep,
                  '&quot;', $metadata/geonet:info/id, '&quot;', $sep)"/>

In this way I had the possibility to get the desired output:

"uuid","title","cloud_coverage_percentage","category","date-creation"
"c94da70e-066e-11ea-aa22-02000a08f492","S2A_MSIL1C_20180320T101021_N0206_R022_T33TUM_20180320T122057","36.0368","dataset","2018-03-20T12:20:57",
"7caf22dc-066f-11ea-a038-02000a08f492","S2A_MSIL1C_20180320T101021_N0206_R022_T33TVN_20180320T122057","100.0","dataset","2018-03-20T12:20:57",

If you do not want to see the last comma after the last value (date-creation in my case) you can add a small piece of code at the end of the file:

  • comment the line
    <xsl:value-of select="$sep"/> (l.185)

  • add the following lines of codes:

<xsl:if test="position() != last()">
    <xsl:value-of select="$sep"/>
</xsl:if>

I will try to open a pull request for this.

I hope this additional information could be useful for someone else.

@fxprunayre
Copy link
Contributor

Next week we are organizing a documentation codesprint https://github.com/geonetwork/core-geonetwork/wiki/Documentation-codesprint-November-2019, maybe you would have time to update the doc page containing old info with this new instruction ?

@sylar11
Copy link
Contributor Author

sylar11 commented Nov 27, 2019

I will do it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants