Revision 2821
Added by Matt Jones almost 19 years ago
src/query-client/run-query.sh | ||
---|---|---|
1 |
#!/bin/bash |
|
2 |
# Matt Jones |
|
3 |
# Metacat query using WGET to launch the query and an XSL document to |
|
4 |
# transform it into a comma-separated text file |
|
5 |
# 26 August 2005 |
|
6 |
# '$Id$' |
|
7 |
LIB=../../lib |
|
8 |
PARSER=$LIB/xalan/xalan.jar:$LIB/xercesImpl.jar:$LIB/xalan/xml-apis.jar |
|
9 |
TEMP=temp.xml |
|
10 |
STYLE=wg-data-list.xsl |
|
11 |
OUT=nceas-packages.txt |
|
12 |
QUERY=http://knb.ecoinformatics.org/knb/metacat?action=query\&operator=INTERSECT\&organizationName=National%20Center%20for%20Ecological%20Analysis%20and%20Synthesis\&qformat=xml\&returndoctype=eml://ecoinformatics.org/eml-2.0.0\&returndoctype=eml://ecoinformatics.org/eml-2.0.1\&returndoctype=-//ecoinformatics.org//eml-dataset-2.0.0beta6//EN\&returndoctype=-//ecoinformatics.org//eml-dataset-2.0.0beta4//EN\&returnfield=originator/organizationName\&returnfield=creator/organizationName |
|
13 |
wget -O $TEMP $QUERY |
|
14 |
echo "Query finished. Transforming XML results to CSV format..." |
|
15 |
java -cp $PARSER org.apache.xalan.xslt.Process -IN $TEMP -XSL $STYLE -OUT $OUT |
|
16 |
rm $TEMP |
|
17 |
echo "Done. Results are in file \"$OUT\"." |
|
0 | 18 |
src/query-client/wg-data-list.xsl | ||
---|---|---|
1 |
<?xml version="1.0"?> |
|
2 |
<!-- |
|
3 |
* '$RCSfile$' |
|
4 |
* Copyright: 2005 Regents of the University of California and the |
|
5 |
* National Center for Ecological Analysis and Synthesis |
|
6 |
* |
|
7 |
* '$Author$' |
|
8 |
* '$Date$' |
|
9 |
* '$Revision$' |
|
10 |
* |
|
11 |
* This program is free software; you can redistribute it and/or modify |
|
12 |
* it under the terms of the GNU General Public License as published by |
|
13 |
* the Free Software Foundation; either version 2 of the License, or |
|
14 |
* (at your option) any later version. |
|
15 |
* |
|
16 |
* This program is distributed in the hope that it will be useful, |
|
17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19 |
* GNU General Public License for more details. |
|
20 |
* |
|
21 |
* You should have received a copy of the GNU General Public License |
|
22 |
* along with this program; if not, write to the Free Software |
|
23 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
24 |
--> |
|
25 |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> |
|
26 |
<xsl:output method="text"/> |
|
27 |
<xsl:template match="/"> |
|
28 |
<xsl:for-each select="resultset/document"> |
|
29 |
<xsl:sort select="./param[@name='dataset/creator/organizationName']"/> |
|
30 |
<xsl:value-of select="./docid"/>,<xsl:value-of select="./param[@name='creator/organizationName' and starts-with(text(),'NCEAS ')]"/><xsl:text> |
|
31 |
</xsl:text> |
|
32 |
</xsl:for-each> |
|
33 |
</xsl:template> |
|
34 |
</xsl:stylesheet> |
|
0 | 35 |
Also available in: Unified diff
Simple bash script to query metacat (using wget) and transform the XML
resultset into a text file using an XSLT stylesheet.