forked from idhmc-tamu/eMOP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxml_to_box.xsl
51 lines (48 loc) · 2.03 KB
/
xml_to_box.xsl
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
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:pr="http://schema.primaresearch.org/PAGE/gts/pagecontent/2010-03-19"
version="1.0">
<xsl:output method="text" omit-xml-declaration="yes" />
<xsl:variable name="imageHeight" select="number(//pr:Page/@imageHeight)"/>
<xsl:variable name="imageWidth" select="number(//pr:Page/@imageWidth)"/>
<xsl:template match="pr:Glyph">
<xsl:value-of select="pr:TextEquiv/pr:Unicode/."/>
<xsl:text> </xsl:text>
<!-- get left -->
<xsl:for-each select="pr:Coords/pr:Point">
<xsl:sort select="@x" data-type="number" order="ascending"/>
<xsl:if test="position() = 1">
<xsl:value-of select="@x"/>
</xsl:if>
</xsl:for-each>
<xsl:text> </xsl:text>
<!-- get bottom -->
<xsl:for-each select="pr:Coords/pr:Point">
<xsl:sort select="@y" data-type="number" order="descending"/>
<xsl:if test="position() = 1">
<xsl:value-of select="$imageHeight - @y"/>
</xsl:if>
</xsl:for-each>
<xsl:text> </xsl:text>
<!-- get right -->
<xsl:for-each select="pr:Coords/pr:Point">
<xsl:sort select="@x" data-type="number" order="descending"/>
<xsl:if test="position() = 1">
<xsl:value-of select="@x"/>
</xsl:if>
</xsl:for-each>
<xsl:text> </xsl:text>
<!-- get top -->
<xsl:for-each select="pr:Coords/pr:Point">
<xsl:sort select="@y" data-type="number" order="ascending"/>
<xsl:if test="position() = 1">
<xsl:value-of select="$imageHeight - @y"/>
</xsl:if>
</xsl:for-each>
<xsl:text> 0</xsl:text> <!-- not sure what this is -->
<xsl:text>
</xsl:text> <!-- line break -->
</xsl:template>
<xsl:template match="/">
<xsl:apply-templates select="//pr:Glyph"/>
</xsl:template>
</xsl:stylesheet>