aboutsummaryrefslogtreecommitdiffstats
path: root/test/java/org/apache/fop/fo/extract-events.xsl
blob: 8edc0ee49aa81da9eb6aab9776a99298b9dd4cc6 (plain)
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
55
56
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:fo="http://www.w3.org/1999/XSL/Format"
  exclude-result-prefixes="fo">

  <xsl:output indent="yes" omit-xml-declaration="yes"/>

  <xsl:template match="fo:root">
    <event>
      <xsl:text>start root</xsl:text>
    </event>
    <xsl:apply-templates select="fo:page-sequence"/>
    <event>
      <xsl:text>end   root</xsl:text>
    </event>
  </xsl:template>

  <xsl:template match="fo:*">
    <xsl:call-template name="process.node">
      <xsl:with-param name="id">
        <xsl:apply-templates select="@id"/>
      </xsl:with-param>
    </xsl:call-template>
  </xsl:template>

  <!-- Those elements do not retrieve the id property.
    This will have to be fixed at some point. -->
  <xsl:template match="fo:footnote|fo:footnote-body">
    <xsl:call-template name="process.node"/>
  </xsl:template>

  <xsl:template name="process.node">
    <xsl:param name="id" select="''"/>
    <event>
      <xsl:text>start </xsl:text>
      <xsl:value-of select="local-name()"/>
      <xsl:value-of select="$id"/>
    </event>
    <xsl:apply-templates/>
    <event>
      <xsl:text>end   </xsl:text>
      <xsl:value-of select="local-name()"/>
      <xsl:value-of select="$id"/>
    </event>
  </xsl:template>

  <xsl:template match="@id">
    <xsl:text> id="</xsl:text>
    <xsl:value-of select="."/>
    <xsl:text>"</xsl:text>
  </xsl:template>

  <xsl:template match="text()"/>

</xsl:stylesheet>