-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjhove-xml2csv-transform.xslt
54 lines (44 loc) · 2.78 KB
/
jhove-xml2csv-transform.xslt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?xml version="1.0" encoding="utf-8"?>
<!--
Basic XSLT to transform JHOVE XML output to a CSV file
Usage:
xsltproc jhove-xml2csv-transform.xslt jhove_output.xml > processed_jhove_output.csv
James Mooney, 2017
Version 1.01
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:jhove="http://hul.harvard.edu/ois/xml/ns/jhove" xmlns:mix="http://www.loc.gov/mix/v20">
<xsl:output method="text" />
<xsl:template match="jhove:jhove">
<xsl:text>path,size,format,version,module,status,lastModified,imageWidth,imageHeight,byteOrder,compressionScheme,colorSpace,samplingFrequencyUnit,xSamplingFrequency,ySamplingFrequency,bitsPerSampleValue,samplesPerPixel</xsl:text>
<xsl:text> </xsl:text>
<xsl:for-each select="jhove:repInfo" >
<xsl:value-of select="@uri"/><xsl:text>,</xsl:text>
<xsl:value-of select="jhove:size"/><xsl:text>,</xsl:text>
<xsl:value-of select="jhove:format"/><xsl:text>,</xsl:text>
<xsl:value-of select="jhove:version"/><xsl:text>,</xsl:text>
<xsl:value-of select="jhove:sigMatch/jhove:module"/><xsl:text>,</xsl:text>
<xsl:value-of select="jhove:status"/><xsl:text>,</xsl:text>
<xsl:value-of select="jhove:lastModified"/><xsl:text>,</xsl:text>
<xsl:value-of select="descendant::mix:imageWidth"/><xsl:text>,</xsl:text>
<xsl:value-of select="descendant::mix:imageHeight"/><xsl:text>,</xsl:text>
<xsl:value-of select="descendant::mix:byteOrder"/><xsl:text>,</xsl:text>
<xsl:value-of select="descendant::mix:compressionScheme"/><xsl:text>,</xsl:text>
<xsl:value-of select="descendant::mix:colorSpace"/><xsl:text>,</xsl:text>
<xsl:value-of select="descendant::mix:samplingFrequencyUnit"/><xsl:text>,</xsl:text>
<xsl:variable name="xNumerator" select="descendant::mix:xSamplingFrequency/mix:numerator"/>
<xsl:variable name="xDenominator" select="descendant::mix:xSamplingFrequency/mix:denominator"/>
<xsl:value-of select="round($xNumerator div $xDenominator)"/><xsl:text>,</xsl:text>
<xsl:variable name="yNumerator" select="descendant::mix:ySamplingFrequency/mix:numerator"/>
<xsl:variable name="yDenominator" select="descendant::mix:ySamplingFrequency/mix:denominator"/>
<xsl:value-of select="round($yNumerator div $yDenominator)"/><xsl:text>,</xsl:text>
<xsl:for-each select="descendant::mix:bitsPerSampleValue">
<xsl:value-of select="."/>
<xsl:if test="not(position() = last())">
<xsl:value-of select="string(' ')"/>
</xsl:if>
</xsl:for-each><xsl:text>,</xsl:text>
<xsl:value-of select="descendant::mix:samplesPerPixel"/>
<xsl:text> </xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>