* demo/xml2doc/templates/html/main.xsl,
* demo/xml2doc/templates/html/main_base64.xsl: Here.
---
scribo/ChangeLog | 7 +
scribo/demo/xml2doc/templates/html/main.xsl | 398 ++++++++-----
scribo/demo/xml2doc/templates/html/main_base64.xsl | 621 +++++++++++++-------
3 files changed, 654 insertions(+), 372 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 43577d5..8683016 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,12 @@
2011-01-26 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Make use of paragraph information in HTML output.
+
+ * demo/xml2doc/templates/html/main.xsl,
+ * demo/xml2doc/templates/html/main_base64.xsl: Here.
+
+2011-01-26 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Regen generated files.
* headers.mk,
diff --git a/scribo/demo/xml2doc/templates/html/main.xsl
b/scribo/demo/xml2doc/templates/html/main.xsl
index 9c90970..8159e98 100644
--- a/scribo/demo/xml2doc/templates/html/main.xsl
+++ b/scribo/demo/xml2doc/templates/html/main.xsl
@@ -21,15 +21,10 @@
margin:0px;
font-family:"Times New Roman", Times, serif;
}
- .para
- {
- position:absolute;
- z-index:6;
- }
.region
{
position:absolute;
- z-index:5;
+ z-index:6;
}
.image
{
@@ -40,14 +35,74 @@
</head>
<body>
- <xsl:for-each select="pcGts/page/graphic_region|
- pcGts/page/image_region|
- pcGts/page/chart_region|
- pcGts/page/table_region|
- pcGts/page/separator_region|
- pcGts/page/text_region|
- pcGts/page/text_region/paragraph|
- pcGts/page/text_region/paragraph/line">
+ <xsl:apply-templates select="pcGts/page/text_region"/>
+ <xsl:apply-templates select="pcGts/page/graphic_region|
+ pcGts/page/image_region|
+ pcGts/page/chart_region|
+ pcGts/page/table_region|
+ pcGts/page/separator_region"/>
+
+ </body>
+ </html>
+ </xsl:template>
+
+
+ <xsl:template match="pcGts/page/text_region">
+
+ <!-- Regions Coordinates -->
+
+ <!-- y1 -->
+ <xsl:variable name="y1">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@y" order="ascending"
data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@y" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <!-- x2 -->
+ <xsl:variable name="x2">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@x" order="descending"
data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@x" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <!-- y2 -->
+ <xsl:variable name="y2">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@y" order="descending"
data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@y" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <!-- x1 -->
+ <xsl:variable name="x1">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@x" order="ascending"
data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@x" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <!-- END OF Regions Coordinates -->
+
+ <xsl:apply-templates select="line"/>
+
+ </xsl:template>
+
+
+
+
+
+
+ <xsl:template match="line">
<!-- Regions Coordinates -->
@@ -94,158 +149,179 @@
<!-- END OF Regions Coordinates -->
<!-- TEXT LINE-->
- <xsl:if test="name() = 'line'">
-
- <xsl:variable name="colour">
- <xsl:choose>
- <xsl:when test="../../@txt_colour != ''">
- <xsl:value-of select="../../@txt_colour" />
- </xsl:when>
- <xsl:otherwise>
- Black
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <!-- x_height -->
- <xsl:variable name="x_height">
- <xsl:value-of select="../../@x_height" />
- </xsl:variable>
-
- <!-- a_height -->
- <xsl:variable name="a_height">
- <xsl:value-of select="../../@a_height" />
- </xsl:variable>
-
- <!-- ABS(d_height) -->
- <xsl:variable name="d_height_abs">
- <xsl:choose>
- <xsl:when test="../../@d_height < 0">
- <xsl:value-of select="-../../@d_height" />
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="../../@d_height" />
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <!-- a_height computed, i.e>
- if (A - X < |D|)
- A = X + |D|
- -->
- <xsl:variable name="a">
- <xsl:choose>
- <xsl:when test="($a_height - $x_height) < $d_height_abs">
- <xsl:value-of select="$x_height + $d_height_abs" />
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$a_height" />
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <!-- d_height computed, i.e>
- if (A - A > |D|)
- |D| = A - X
- -->
- <xsl:variable name="d">
- <xsl:choose>
- <xsl:when test="($a_height - $x_height) > $d_height_abs">
- <xsl:value-of select="$a_height - $x_height" />
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$d_height_abs" />
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <div class="line">
- <xsl:attribute name="style">
- height:auto;
- font-size:<xsl:value-of select="$a+$d" />px;
- width:<xsl:value-of select="$x2 - $x1" />px;
- left:<xsl:value-of select="$x1 " />px;
- top:<xsl:value-of select="$y1 " />px;
- color:<xsl:value-of select="$colour" />;
- </xsl:attribute>
- <xsl:value-of select="@text"/>
- </div>
- </xsl:if>
+ <xsl:variable name="colour">
+ <xsl:choose>
+ <xsl:when test="@txt_colour != ''">
+ <xsl:value-of select="@txt_colour" />
+ </xsl:when>
+ <xsl:otherwise>
+ Black
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <!-- x_height -->
+ <xsl:variable name="x_height">
+ <xsl:value-of select="@x_height" />
+ </xsl:variable>
+
+ <!-- a_height -->
+ <xsl:variable name="a_height">
+ <xsl:value-of select="@a_height" />
+ </xsl:variable>
+
+ <!-- ABS(d_height) -->
+ <xsl:variable name="d_height_abs">
+ <xsl:choose>
+ <xsl:when test="@d_height < 0">
+ <xsl:value-of select="-@d_height" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="@d_height" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <!-- a_height computed, i.e>
+ if (A - X < |D|)
+ A = X + |D|
+ -->
+ <xsl:variable name="a">
+ <xsl:choose>
+ <xsl:when test="($a_height - $x_height) < $d_height_abs">
+ <xsl:value-of select="$x_height + $d_height_abs" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$a_height" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <!-- d_height computed, i.e>
+ if (A - A > |D|)
+ |D| = A - X
+ -->
+ <xsl:variable name="d">
+ <xsl:choose>
+ <xsl:when test="($a_height - $x_height) > $d_height_abs">
+ <xsl:value-of select="$a_height - $x_height" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$d_height_abs" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <span class="line">
+ <xsl:attribute name="style">
+ height:auto;
+ font-size:<xsl:value-of select="$a + $d" />px;
+ width:<xsl:value-of select="$x2 - $x1" />px;
+ left:<xsl:value-of select="$x1 " />px;
+ top:<xsl:value-of select="$y1 " />px;
+ color:<xsl:value-of select="$colour" />;
+ </xsl:attribute>
+ <xsl:value-of select="@text"/>
+ </span>
<!-- ENF OF TEXT LINE -->
+ </xsl:template>
- <!-- TEXT REGION -->
-<!-- <xsl:if test="name() = 'text_region'">
- <div class="region">
- <xsl:attribute name="style">
- height:<xsl:value-of select="$y2 - $y1" />px;
- width:<xsl:value-of select="$x2 - $x1" />px;
- left:<xsl:value-of select="$x1" />px;
- top:<xsl:value-of select="$y1" />px;
- </xsl:attribute>
- </div>
- </xsl:if>-->
- <!-- ENF OF TEXT REGION -->
-
- <!-- PARAGRAPH -->
-<!-- <xsl:if test="name() = 'paragraph'">
- <div class="para">
- <xsl:attribute name="style">
- height:<xsl:value-of select="$y2 - $y1" />px;
- width:<xsl:value-of select="$x2 - $x1" />px;
- left:<xsl:value-of select="$x1" />px;
- top:<xsl:value-of select="$y1" />px;
- </xsl:attribute>
- </div>
- </xsl:if>-->
- <!-- ENF OF PARAGRAPH -->
+
+
+
+
+ <xsl:template match="pcGts/page/graphic_region|
+ pcGts/page/image_region|
+ pcGts/page/chart_region|
+ pcGts/page/table_region|
+ pcGts/page/separator_region">
+
+ <!-- Regions Coordinates -->
+
+ <!-- y1 -->
+ <xsl:variable name="y1">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@y" order="ascending"
data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@y" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <!-- x2 -->
+ <xsl:variable name="x2">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@x" order="descending"
data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@x" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <!-- y2 -->
+ <xsl:variable name="y2">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@y" order="descending"
data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@y" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <!-- x1 -->
+ <xsl:variable name="x1">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@x" order="ascending"
data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@x" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <!-- END OF Regions Coordinates -->
<!-- NON-TEXT REGIONS -->
- <xsl:if test="name() = 'image_region' or name() =
'separator_region' or name() = 'graphic_region' or name() =
'chart_region' or name() = 'table_region'">
-
- <!-- id -->
- <xsl:variable name="id">
- <xsl:value-of select="@id" />
- </xsl:variable>
-
- <!-- depth -->
- <xsl:variable name="depth">
- <xsl:choose>
- <xsl:when test="name() = 'separator_region'">
- 1
- </xsl:when>
- <xsl:otherwise>
- 4
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <div class="image">
- <xsl:attribute name="style">
- top:<xsl:value-of select="$y1" />px;
- left:<xsl:value-of select="$x1" />px;
- width:<xsl:value-of select="$x2 - $x1"/>px;
- height:<xsl:value-of select="$y2 - $y1"/>px;
- z-index:<xsl:value-of select="$depth"/>;
+ <!-- id -->
+ <xsl:variable name="id">
+ <xsl:value-of select="@id" />
+ </xsl:variable>
+
+ <!-- depth -->
+ <xsl:variable name="depth">
+ <xsl:choose>
+ <xsl:when test="name() = 'separator_region'">
+ 1
+ </xsl:when>
+ <xsl:otherwise>
+ 4
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <div class="image">
+ <xsl:attribute name="style">
+ top:<xsl:value-of select="$y1" />px;
+ left:<xsl:value-of select="$x1" />px;
+ width:<xsl:value-of select="$x2 - $x1"/>px;
+ height:<xsl:value-of select="$y2 - $y1"/>px;
+ z-index:<xsl:value-of select="$depth"/>;
+ </xsl:attribute>
+ <img>
+ <xsl:attribute name="alt">
+ <xsl:value-of select="name()" />
+ </xsl:attribute>
+ <xsl:attribute name="width">
+ <xsl:value-of select="$x2 - $x1" />
</xsl:attribute>
- <img>
- <xsl:attribute name="alt">
- <xsl:value-of select="name()" />
- </xsl:attribute>
- <xsl:attribute name="width">
- <xsl:value-of select="$x2 - $x1" />
- </xsl:attribute>
- <xsl:attribute name="height">
- <xsl:value-of select="$y2 - $y1" />
- </xsl:attribute>
- <xsl:attribute name="src"><xsl:value-of
select="$id"/>.png</xsl:attribute>
- </img>
- </div>
-
- </xsl:if>
+ <xsl:attribute name="height">
+ <xsl:value-of select="$y2 - $y1" />
+ </xsl:attribute>
+ <xsl:attribute name="src"><xsl:value-of
select="$id"/>.png</xsl:attribute>
+ </img>
+ </div>
+
<!-- END NON-TEXT REGIONS -->
- </xsl:for-each>
- </body>
- </html>
- </xsl:template>
+ </xsl:template>
+
</xsl:stylesheet>
diff --git a/scribo/demo/xml2doc/templates/html/main_base64.xsl
b/scribo/demo/xml2doc/templates/html/main_base64.xsl
index b24f02d..fe3f1db 100644
--- a/scribo/demo/xml2doc/templates/html/main_base64.xsl
+++ b/scribo/demo/xml2doc/templates/html/main_base64.xsl
@@ -39,222 +39,421 @@
border:0;
}
</style>
-<!-- <link rel="stylesheet" type="text/css"
href="css.css" /> -->
+ <!-- <link rel="stylesheet" type="text/css"
href="css.css" /> -->
</head>
<body>
- <xsl:for-each select="pcGts/page/graphic_region|
- pcGts/page/image_region|
- pcGts/page/chart_region|
- pcGts/page/table_region|
- pcGts/page/separator_region|
- pcGts/page/text_region|
- pcGts/page/text_region/paragraph|
- pcGts/page/text_region/paragraph/line">
-
- <!-- Regions Coordinates -->
-
- <!-- y1 -->
- <xsl:variable name="y1">
- <xsl:for-each select="coords/point">
- <xsl:sort select="@y" order="ascending"
data-type="number"/>
- <xsl:if test="position() = 1">
- <xsl:value-of select="@y" />
- </xsl:if>
- </xsl:for-each>
- </xsl:variable>
-
- <!-- x2 -->
- <xsl:variable name="x2">
- <xsl:for-each select="coords/point">
- <xsl:sort select="@x" order="descending"
data-type="number"/>
- <xsl:if test="position() = 1">
- <xsl:value-of select="@x" />
- </xsl:if>
- </xsl:for-each>
- </xsl:variable>
-
- <!-- y2 -->
- <xsl:variable name="y2">
- <xsl:for-each select="coords/point">
- <xsl:sort select="@y" order="descending"
data-type="number"/>
- <xsl:if test="position() = 1">
- <xsl:value-of select="@y" />
- </xsl:if>
- </xsl:for-each>
- </xsl:variable>
-
- <!-- x1 -->
- <xsl:variable name="x1">
- <xsl:for-each select="coords/point">
- <xsl:sort select="@x" order="ascending"
data-type="number"/>
- <xsl:if test="position() = 1">
- <xsl:value-of select="@x" />
- </xsl:if>
- </xsl:for-each>
- </xsl:variable>
-
- <!-- END OF Regions Coordinates -->
-
- <!-- TEXT LINE-->
- <xsl:if test="name() = 'line'">
-
- <xsl:variable name="colour">
- <xsl:choose>
- <xsl:when test="../../@txt_colour != ''">
- <xsl:value-of select="../../@txt_colour" />
- </xsl:when>
- <xsl:otherwise>
- Black
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <!-- x_height -->
- <xsl:variable name="x_height">
- <xsl:value-of select="../../@x_height" />
- </xsl:variable>
-
- <!-- a_height -->
- <xsl:variable name="a_height">
- <xsl:value-of select="../../@a_height" />
- </xsl:variable>
-
- <!-- ABS(d_height) -->
- <xsl:variable name="d_height_abs">
- <xsl:choose>
- <xsl:when test="../../@d_height < 0">
- <xsl:value-of select="-../../@d_height" />
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="../../@d_height" />
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <!-- a_height computed, i.e>
- if (A - X < |D|)
- A = X + |D|
- -->
- <xsl:variable name="a">
- <xsl:choose>
- <xsl:when test="($a_height - $x_height) < $d_height_abs">
- <xsl:value-of select="$x_height + $d_height_abs" />
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$a_height" />
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <!-- d_height computed, i.e>
- if (A - A > |D|)
- |D| = A - X
- -->
- <xsl:variable name="d">
- <xsl:choose>
- <xsl:when test="($a_height - $x_height) > $d_height_abs">
- <xsl:value-of select="$a_height - $x_height" />
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$d_height_abs" />
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <div class="line"
onmouseover="this.style.opacity=0.2;this.filters.alpha.opacity=20"
- onmouseout="this.style.opacity=1;this.filters.alpha.opacity=100">
- <xsl:attribute name="style">
- opacity:1;
- height:auto;
- font-size:<xsl:value-of select="$a+$d" />px;
- width:<xsl:value-of select="$x2 - $x1" />px;
- left:<xsl:value-of select="$x1 " />px;
- top:<xsl:value-of select="$y1 " />px;
- color:<xsl:value-of select="$colour" />;
- </xsl:attribute>
- <xsl:value-of select="@text"/>
- </div>
- </xsl:if>
- <!-- ENF OF TEXT LINE -->
-
- <!-- TEXT REGION -->
- <xsl:if test="name() = 'text_region'">
- <div class="region">
- <xsl:attribute name="style">
- height:<xsl:value-of select="$y2 - $y1" />px;
- width:<xsl:value-of select="$x2 - $x1" />px;
- left:<xsl:value-of select="$x1" />px;
- top:<xsl:value-of select="$y1" />px;
- </xsl:attribute>
- </div>
- </xsl:if>
- <!-- ENF OF TEXT REGION -->
-
- <!-- PARAGRAPH -->
- <xsl:if test="name() = 'paragraph'">
- <div class="para">
- <xsl:attribute name="style">
- height:<xsl:value-of select="$y2 - $y1" />px;
- width:<xsl:value-of select="$x2 - $x1" />px;
- left:<xsl:value-of select="$x1" />px;
- top:<xsl:value-of select="$y1" />px;
- </xsl:attribute>
- </div>
- </xsl:if>
- <!-- ENF OF PARAGRAPH -->
-
- <!-- NON-TEXT REGIONS -->
- <xsl:if test="name() = 'image_region' or name() =
'separator_region' or name() = 'graphic_region' or name() =
'chart_region' or name() = 'table_region'">
-
- <xsl:if test="container">
- <!-- data -->
- <xsl:variable name="data">
- <xsl:value-of select="container/data" />
- </xsl:variable>
-
- <!-- depth -->
- <xsl:variable name="depth">
- <xsl:choose>
- <xsl:when test="name() = 'separator_region'">
- 1
- </xsl:when>
- <xsl:otherwise>
- 4
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <div class="image">
- <xsl:attribute name="style">
- top:<xsl:value-of select="$y1" />px;
- left:<xsl:value-of select="$x1" />px;
- width:<xsl:value-of select="$x2 - $x1"/>px;
- height:<xsl:value-of select="$y2 - $y1"/>px;
- z-index:<xsl:value-of select="$depth"/>;
- </xsl:attribute>
- <img>
- <xsl:attribute name="alt">
- <xsl:value-of select="name()" />
- </xsl:attribute>
- <xsl:attribute name="width">
- <xsl:value-of select="$x2 - $x1" />
- </xsl:attribute>
- <xsl:attribute name="height">
- <xsl:value-of select="$y2 - $y1" />
- </xsl:attribute>
- <xsl:attribute name="src">
- data:image/png;base64,<xsl:value-of select="$data"/>
- </xsl:attribute>
- </img>
- </div>
- </xsl:if>
-
- </xsl:if>
- <!-- END NON-TEXT REGIONS -->
- </xsl:for-each>
+ <xsl:apply-templates select="pcGts/page/text_region"/>
+ <xsl:apply-templates select="pcGts/page/graphic_region|
+ pcGts/page/image_region|
+ pcGts/page/chart_region|
+ pcGts/page/table_region|
+ pcGts/page/separator_region"/>
</body>
</html>
</xsl:template>
+
+
+ <!--
+ TEXT REGION
+ ===========
+ -->
+
+ <xsl:template match="pcGts/page/text_region">
+
+ <!-- Regions Coordinates -->
+
+ <!-- y1 -->
+ <xsl:variable name="y1">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@y" order="ascending"
data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@y" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <!-- x2 -->
+ <xsl:variable name="x2">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@x" order="descending"
data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@x" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <!-- y2 -->
+ <xsl:variable name="y2">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@y" order="descending"
data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@y" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <!-- x1 -->
+ <xsl:variable name="x1">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@x" order="ascending"
data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@x" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <!-- END OF Regions Coordinates -->
+
+ <xsl:apply-templates select="line"/>
+
+ </xsl:template>
+
+
+
+
+ <!--
+ TEXT LINES
+ ==========
+ -->
+ <xsl:template match="line">
+
+ <!-- Regions Coordinates -->
+
+ <!-- y1 -->
+ <xsl:variable name="y1">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@y" order="ascending"
data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@y" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <!-- x2 -->
+ <xsl:variable name="x2">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@x" order="descending"
data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@x" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <!-- y2 -->
+ <xsl:variable name="y2">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@y" order="descending"
data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@y" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <!-- x1 -->
+ <xsl:variable name="x1">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@x" order="ascending"
data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@x" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <!-- END OF Regions Coordinates -->
+
+ <!-- TEXT LINE-->
+ <xsl:variable name="colour">
+ <xsl:choose>
+ <xsl:when test="@txt_colour != ''">
+ <xsl:value-of select="@txt_colour" />
+ </xsl:when>
+ <xsl:otherwise>
+ Black
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <!-- x_height -->
+ <xsl:variable name="x_height">
+ <xsl:value-of select="@x_height" />
+ </xsl:variable>
+
+ <!-- a_height -->
+ <xsl:variable name="a_height">
+ <xsl:value-of select="@a_height" />
+ </xsl:variable>
+
+ <!-- ABS(d_height) -->
+ <xsl:variable name="d_height_abs">
+ <xsl:choose>
+ <xsl:when test="@d_height < 0">
+ <xsl:value-of select="-@d_height" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="@d_height" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <!-- a_height computed, i.e>
+ if (A - X < |D|)
+ A = X + |D|
+ -->
+ <xsl:variable name="a">
+ <xsl:choose>
+ <xsl:when test="($a_height - $x_height) < $d_height_abs">
+ <xsl:value-of select="$x_height + $d_height_abs" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$a_height" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <!-- d_height computed, i.e>
+ if (A - A > |D|)
+ |D| = A - X
+ -->
+ <xsl:variable name="d">
+ <xsl:choose>
+ <xsl:when test="($a_height - $x_height) > $d_height_abs">
+ <xsl:value-of select="$a_height - $x_height" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$d_height_abs" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <span class="line">
+ <xsl:attribute name="style">
+ height:auto;
+ font-size:<xsl:value-of select="$a + $d" />px;
+ width:<xsl:value-of select="$x2 - $x1" />px;
+ left:<xsl:value-of select="$x1 " />px;
+ top:<xsl:value-of select="$y1 " />px;
+ color:<xsl:value-of select="$colour" />;
+ </xsl:attribute>
+ <xsl:value-of select="@text"/>
+ </span>
+ <!-- ENF OF TEXT LINE -->
+ </xsl:template>
+
+
+
+
+ <!--
+ MISC. REGIONS
+ =============
+ -->
+ <xsl:template match="pcGts/page/graphic_region|
+ pcGts/page/image_region|
+ pcGts/page/chart_region|
+ pcGts/page/table_region|
+ pcGts/page/separator_region">
+
+ <!-- Regions Coordinates -->
+
+ <!-- y1 -->
+ <xsl:variable name="y1">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@y" order="ascending"
data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@y" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <!-- x2 -->
+ <xsl:variable name="x2">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@x" order="descending"
data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@x" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <!-- y2 -->
+ <xsl:variable name="y2">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@y" order="descending"
data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@y" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <!-- x1 -->
+ <xsl:variable name="x1">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@x" order="ascending"
data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@x" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <!-- END OF Regions Coordinates -->
+
+ <!-- TEXT LINE-->
+ <xsl:if test="name() = 'line'">
+
+ <xsl:variable name="colour">
+ <xsl:choose>
+ <xsl:when test="../../@txt_colour != ''">
+ <xsl:value-of select="../../@txt_colour" />
+ </xsl:when>
+ <xsl:otherwise>
+ Black
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <!-- x_height -->
+ <xsl:variable name="x_height">
+ <xsl:value-of select="../../@x_height" />
+ </xsl:variable>
+
+ <!-- a_height -->
+ <xsl:variable name="a_height">
+ <xsl:value-of select="../../@a_height" />
+ </xsl:variable>
+
+ <!-- ABS(d_height) -->
+ <xsl:variable name="d_height_abs">
+ <xsl:choose>
+ <xsl:when test="../../@d_height < 0">
+ <xsl:value-of select="-../../@d_height" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="../../@d_height" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <!-- a_height computed, i.e>
+ if (A - X < |D|)
+ A = X + |D|
+ -->
+ <xsl:variable name="a">
+ <xsl:choose>
+ <xsl:when test="($a_height - $x_height) < $d_height_abs">
+ <xsl:value-of select="$x_height + $d_height_abs" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$a_height" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <!-- d_height computed, i.e>
+ if (A - A > |D|)
+ |D| = A - X
+ -->
+ <xsl:variable name="d">
+ <xsl:choose>
+ <xsl:when test="($a_height - $x_height) > $d_height_abs">
+ <xsl:value-of select="$a_height - $x_height" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$d_height_abs" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <div class="line"
onmouseover="this.style.opacity=0.2;this.filters.alpha.opacity=20"
+ onmouseout="this.style.opacity=1;this.filters.alpha.opacity=100">
+ <xsl:attribute name="style">
+ opacity:1;
+ height:auto;
+ font-size:<xsl:value-of select="$a+$d" />px;
+ width:<xsl:value-of select="$x2 - $x1" />px;
+ left:<xsl:value-of select="$x1 " />px;
+ top:<xsl:value-of select="$y1 " />px;
+ color:<xsl:value-of select="$colour" />;
+ </xsl:attribute>
+ <xsl:value-of select="@text"/>
+ </div>
+ </xsl:if>
+ <!-- ENF OF TEXT LINE -->
+
+ <!-- TEXT REGION -->
+ <xsl:if test="name() = 'text_region'">
+ <div class="region">
+ <xsl:attribute name="style">
+ height:<xsl:value-of select="$y2 - $y1" />px;
+ width:<xsl:value-of select="$x2 - $x1" />px;
+ left:<xsl:value-of select="$x1" />px;
+ top:<xsl:value-of select="$y1" />px;
+ </xsl:attribute>
+ </div>
+ </xsl:if>
+ <!-- ENF OF TEXT REGION -->
+
+ <!-- PARAGRAPH -->
+ <xsl:if test="name() = 'paragraph'">
+ <div class="para">
+ <xsl:attribute name="style">
+ height:<xsl:value-of select="$y2 - $y1" />px;
+ width:<xsl:value-of select="$x2 - $x1" />px;
+ left:<xsl:value-of select="$x1" />px;
+ top:<xsl:value-of select="$y1" />px;
+ </xsl:attribute>
+ </div>
+ </xsl:if>
+ <!-- ENF OF PARAGRAPH -->
+
+ <!-- NON-TEXT REGIONS -->
+ <xsl:if test="name() = 'image_region' or name() =
'separator_region' or name() = 'graphic_region' or name() =
'chart_region' or name() = 'table_region'">
+
+ <xsl:if test="container">
+ <!-- data -->
+ <xsl:variable name="data">
+ <xsl:value-of select="container/data" />
+ </xsl:variable>
+
+ <!-- depth -->
+ <xsl:variable name="depth">
+ <xsl:choose>
+ <xsl:when test="name() = 'separator_region'">
+ 1
+ </xsl:when>
+ <xsl:otherwise>
+ 4
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <div class="image">
+ <xsl:attribute name="style">
+ top:<xsl:value-of select="$y1" />px;
+ left:<xsl:value-of select="$x1" />px;
+ width:<xsl:value-of select="$x2 - $x1"/>px;
+ height:<xsl:value-of select="$y2 - $y1"/>px;
+ z-index:<xsl:value-of select="$depth"/>;
+ </xsl:attribute>
+ <img>
+ <xsl:attribute name="alt">
+ <xsl:value-of select="name()" />
+ </xsl:attribute>
+ <xsl:attribute name="width">
+ <xsl:value-of select="$x2 - $x1" />
+ </xsl:attribute>
+ <xsl:attribute name="height">
+ <xsl:value-of select="$y2 - $y1" />
+ </xsl:attribute>
+ <xsl:attribute name="src">
+ data:image/png;base64,<xsl:value-of select="$data"/>
+ </xsl:attribute>
+ </img>
+ </div>
+ </xsl:if>
+
+ </xsl:if>
+ <!-- END NON-TEXT REGIONS -->
+ </xsl:template>
+
</xsl:stylesheet>
--
1.5.6.5