Skip to content
Snippets Groups Projects
Commit 0a51451e authored by Oliver Bock's avatar Oliver Bock
Browse files

Adding first XSL transformations for VOTable output conversions

- First feature: gnuplot command and data files (XSLT 2.0 might eventually create both files in one transformation)
- TODO: parameterize various things (i.e. plot properties, filenames etc.)

git-svn-id: https://svn.origo.ethz.ch/fidelity@24 53d1999f-d1a8-4366-aa61-588fded17473
parent 9042439b
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="UTF-8" />
<!-- match whole document and apply selected templates -->
<xsl:template match="/">
<!-- header processing (see below) -->
<xsl:apply-templates select="descendant::VOTABLE | descendant::RESOURCE | descendant::TABLE"/>
<!-- gnuplot command processing -->
<xsl:text>set title &apos;</xsl:text>
<xsl:value-of select="VOTABLE/DESCRIPTION" />
<xsl:text>&apos;&#x0a;</xsl:text>
<xsl:text>set grid&#x0a;</xsl:text>
<xsl:text>&#x0a;</xsl:text>
<xsl:text>set xlabel &apos;</xsl:text>
<xsl:value-of select="VOTABLE/RESOURCE/TABLE/FIELD[1]/@name" />
<xsl:text> [</xsl:text>
<xsl:value-of select="VOTABLE/RESOURCE/TABLE/FIELD[1]/@unit" />
<xsl:text>]&apos;&#x0a;</xsl:text>
<xsl:text>set ylabel &apos;</xsl:text>
<xsl:value-of select="VOTABLE/RESOURCE/TABLE/FIELD[2]/@name" />
<xsl:text> [</xsl:text>
<xsl:value-of select="VOTABLE/RESOURCE/TABLE/FIELD[2]/@unit" />
<xsl:text>]&apos;&#x0a;</xsl:text>
<!-- TODO: add if-condition for 2nd channel -->
<xsl:text>set y2label &apos;</xsl:text>
<xsl:value-of select="VOTABLE/RESOURCE/TABLE/FIELD[3]/@name" />
<xsl:text> [</xsl:text>
<xsl:value-of select="VOTABLE/RESOURCE/TABLE/FIELD[3]/@unit" />
<xsl:text>]&apos;&#x0a;</xsl:text>
<!-- TODO: use parameters scaling/ticks -->
<xsl:text>&#x0a;</xsl:text>
<xsl:text>set yrange [0:1]&#x0a;</xsl:text>
<xsl:text>set ytics 0, 0.1&#x0a;</xsl:text>
<!-- TODO: add if-condition for 2nd channel -->
<xsl:text>set y2range [0:400]&#x0a;</xsl:text>
<xsl:text>set y2tics 0, 40&#x0a;</xsl:text>
<xsl:text>set ytics nomirror&#x0a;</xsl:text>
<xsl:text>&#x0a;</xsl:text>
<!-- TODO: use parameters for line styles -->
<xsl:text>set style line 1 lt 1&#x0a;</xsl:text>
<!-- TODO: add if-condition for 2nd channel -->
<xsl:text>set style line 2 lt 3&#x0a;</xsl:text>
<xsl:text>&#x0a;</xsl:text>
<!-- TODO: filename and format should be defined via parameters -->
<xsl:text>set output &apos;gnuplot.png&apos;&#x0a;</xsl:text>
<xsl:text>set terminal png enhanced size 800,600&#x0a;</xsl:text>
<xsl:text>&#x0a;</xsl:text>
<!-- TODO: use parameters for data source filename and "with lines" -->
<xsl:text>plot &apos;gnuplot.dat&apos; using 1:2 axis x1y1 ls 1 title &apos;</xsl:text>
<xsl:value-of select="VOTABLE/RESOURCE/TABLE/FIELD[2]/@name" />
<xsl:text>&apos; with lines, \&#x0a;</xsl:text>
<!-- TODO: add if-condition for 2nd channel -->
<xsl:text> &apos;gnuplot.dat&apos; using 1:3 axis x1y2 ls 2 title &apos;</xsl:text>
<xsl:value-of select="VOTABLE/RESOURCE/TABLE/FIELD[3]/@name" />
<xsl:text>&apos; with lines&#x0a;</xsl:text>
</xsl:template>
<!-- header processing -->
<xsl:template match="VOTABLE">
<xsl:text># Fidelity Output Transformation (DataStorage Plugin)&#x0a;</xsl:text>
<xsl:text># Input: VOTable </xsl:text>
<xsl:value-of select="@version" />
<xsl:text> - Output: gnuplot&#x0a;</xsl:text>
<xsl:text>#&#x0a;</xsl:text>
<xsl:text># Description: </xsl:text>
<xsl:value-of select="child::DESCRIPTION" />
<xsl:text>&#x0a;</xsl:text>
</xsl:template>
<xsl:template match="RESOURCE">
<xsl:text># Resource: </xsl:text>
<xsl:value-of select="child::DESCRIPTION" />
<xsl:text>&#x0a;</xsl:text>
</xsl:template>
<xsl:template match="TABLE">
<xsl:text># Table: </xsl:text>
<xsl:value-of select="child::DESCRIPTION" />
<xsl:text>&#x0a;</xsl:text>
<xsl:text>#&#x0a;</xsl:text>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="UTF-8" />
<!-- match whole document and apply selected templates -->
<xsl:template match="/">
<xsl:apply-templates select="descendant::VOTABLE | descendant::RESOURCE | descendant::TABLE | descendant::TABLEDATA"/>
</xsl:template>
<!-- header processing -->
<xsl:template match="VOTABLE">
<xsl:text># Fidelity Output Transformation (DataStorage Plugin)&#x0a;</xsl:text>
<xsl:text># Input: VOTable </xsl:text>
<xsl:value-of select="@version" />
<xsl:text> - Output: gnuplot&#x0a;</xsl:text>
<xsl:text>#&#x0a;</xsl:text>
<xsl:text># Description: </xsl:text>
<xsl:value-of select="child::DESCRIPTION" />
<xsl:text>&#x0a;</xsl:text>
</xsl:template>
<xsl:template match="RESOURCE">
<xsl:text># Resource: </xsl:text>
<xsl:value-of select="child::DESCRIPTION" />
<xsl:text>&#x0a;</xsl:text>
</xsl:template>
<xsl:template match="TABLE">
<xsl:text># Table: </xsl:text>
<xsl:value-of select="child::DESCRIPTION" />
<xsl:text>&#x0a;</xsl:text>
<xsl:text>#&#x0a;</xsl:text>
</xsl:template>
<!-- table data processing -->
<xsl:template match="TABLEDATA">
<xsl:for-each select="TR">
<xsl:value-of select="TD[1]" />
<xsl:text>&#x09;</xsl:text>
<xsl:value-of select="TD[2]" />
<!-- TODO: add if-condition for 2nd channel -->
<xsl:text>&#x09;</xsl:text>
<xsl:value-of select="TD[3]" />
<xsl:text>&#x0a;</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment